From a91258913fb597db7f409f3534512cf2249bceb6 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 14 Feb 2018 17:01:15 -0800 Subject: [PATCH] Prepare SPL repo to merge with ZFS repo This commit removes everything from the repository except the core SPL implementation for Linux. Those files which remain have been moved to non-conflicting locations to facilitate the merge. The README.md and associated files have been updated accordingly. Signed-off-by: Brian Behlendorf --- .gitignore | 52 - DISCLAIMER | 24 - COPYING => LICENSE | 0 META | 8 - Makefile.am | 55 - NOTICE | 16 + README.markdown | 36 - README.md | 21 + autogen.sh | 4 - cmd/Makefile.am | 1 - cmd/splat/.gitignore | 1 - cmd/splat/Makefile.am | 11 - cmd/splat/splat.c | 836 --------- cmd/splat/splat.h | 70 - cmd/splslab/Makefile.am | 2 - cmd/splslab/splslab.py | 202 --- config/.gitignore | 9 - config/Rules.am | 14 - config/config.awk | 15 - config/deb.am | 58 - config/kernel-fallocate-pax.m4 | 19 + config/kernel-fallocate.m4 | 68 - config/kernel-kmem.m4 | 58 + config/kernel-truncate-range.m4 | 19 - config/rpm.am | 87 - config/spl-build.m4 | 755 -------- config/spl-meta.m4 | 170 -- config/tgz.am | 44 - configure.ac | 88 - copy-builtin | 126 -- include/Makefile.am | 18 - include/fs/Makefile.am | 13 - include/fs/fs_subr.h | 28 - include/linux/Makefile.am | 23 - include/linux/bitops_compat.h | 30 - include/linux/compiler_compat.h | 47 - include/linux/delay_compat.h | 47 - include/linux/file_compat.h | 140 -- include/linux/list_compat.h | 50 - include/linux/math64_compat.h | 33 - include/linux/proc_compat.h | 35 - include/linux/rwsem_compat.h | 68 - include/linux/zlib_compat.h | 37 - include/rpc/Makefile.am | 14 - include/rpc/types.h | 30 - include/sharefs/Makefile.am | 13 - include/sharefs/share.h | 28 - include/spl-ctl.h | 45 - include/{ => spl}/rpc/xdr.h | 3 +- include/{ => spl}/sys/acl.h | 0 include/spl/sys/atomic.h | 79 + include/{ => spl}/sys/byteorder.h | 5 + include/{ => spl}/sys/callb.h | 0 include/{ => spl}/sys/callo.h | 0 include/{ => spl}/sys/cmn_err.h | 6 +- include/{ => spl}/sys/condvar.h | 3 +- include/{ => spl}/sys/console.h | 0 include/{ => spl}/sys/cred.h | 1 + include/{ => spl}/sys/ctype.h | 0 include/{ => spl}/sys/debug.h | 0 include/{ => spl}/sys/disp.h | 0 include/{ => spl}/sys/dkio.h | 0 include/{ => spl}/sys/dkioc_free_util.h | 0 include/{ => spl}/sys/fcntl.h | 0 include/{ => spl}/sys/file.h | 25 +- include/{ => spl}/sys/inttypes.h | 0 include/{ => spl}/sys/isa_defs.h | 0 include/{ => spl}/sys/kmem.h | 0 include/{ => spl}/sys/kmem_cache.h | 0 include/{ => spl}/sys/kobj.h | 0 include/{ => spl}/sys/kstat.h | 2 +- include/{ => spl}/sys/list.h | 11 - include/{ => spl}/sys/mode.h | 0 include/{ => spl}/sys/mutex.h | 1 - include/{ => spl}/sys/param.h | 0 include/{ => spl}/sys/proc.h | 7 + include/{ => spl}/sys/processor.h | 0 include/{ => spl}/sys/random.h | 0 include/{ => spl}/sys/rwlock.h | 39 +- .../{linux/mm_compat.h => spl/sys/shrinker.h} | 6 +- include/{ => spl}/sys/sid.h | 0 include/{ => spl}/sys/signal.h | 0 include/{ => spl}/sys/stat.h | 0 include/{sys/idmap.h => spl/sys/strings.h} | 14 +- include/{ => spl}/sys/sunddi.h | 1 - include/{ => spl}/sys/sysmacros.h | 17 +- include/{ => spl}/sys/systeminfo.h | 0 include/{ => spl}/sys/taskq.h | 2 +- include/{ => spl}/sys/thread.h | 4 +- include/{ => spl}/sys/time.h | 0 include/{ => spl}/sys/timer.h | 16 + include/{ => spl}/sys/tsd.h | 0 include/{ => spl}/sys/types.h | 58 +- include/{ => spl}/sys/types32.h | 1 - include/{ => spl}/sys/uio.h | 0 include/{ => spl}/sys/user.h | 0 include/{ => spl}/sys/vfs.h | 0 include/{ => spl}/sys/vmem.h | 0 include/{ => spl}/sys/vmsystm.h | 0 include/{ => spl}/sys/vnode.h | 1 - .../{linux/wait_compat.h => spl/sys/wait.h} | 6 +- include/{ => spl}/sys/zmod.h | 8 + include/{ => spl}/sys/zone.h | 0 include/splat-ctl.h | 109 -- include/strings.h | 28 - include/sys/Makefile.am | 113 -- include/sys/acl_impl.h | 28 - include/sys/atomic.h | 313 ---- include/sys/attr.h | 28 - include/sys/bitmap.h | 28 - include/sys/bootconf.h | 28 - include/sys/bootprops.h | 28 - include/sys/buf.h | 28 - include/sys/compress.h | 28 - include/sys/conf.h | 28 - include/sys/cpupart.h | 28 - include/sys/cpuvar.h | 28 - include/sys/crc32.h | 28 - include/sys/ddi.h | 28 - include/sys/dirent.h | 28 - include/sys/dklabel.h | 28 - include/sys/dnlc.h | 28 - include/sys/dumphdr.h | 28 - include/sys/efi_partition.h | 28 - include/sys/errno.h | 28 - include/sys/extdirent.h | 29 - include/sys/fm/Makefile.am | 14 - include/sys/fm/protocol.h | 28 - include/sys/fm/util.h | 28 - include/sys/fs/Makefile.am | 13 - include/sys/fs/swapnode.h | 28 - include/sys/int_limits.h | 28 - include/sys/int_types.h | 30 - include/sys/kidmap.h | 30 - include/sys/mkdev.h | 28 - include/sys/mntent.h | 28 - include/sys/modctl.h | 28 - include/sys/mount.h | 28 - include/sys/note.h | 28 - include/sys/open.h | 28 - include/sys/pathname.h | 35 - include/sys/policy.h | 47 - include/sys/pool.h | 30 - include/sys/priv_impl.h | 28 - include/sys/pset.h | 38 - include/sys/refstr.h | 28 - include/sys/resource.h | 30 - include/sys/sdt.h | 30 - include/sys/stropts.h | 28 - include/sys/sunldi.h | 43 - include/sys/sysdc.h | 28 - include/sys/systm.h | 32 - include/sys/t_lock.h | 33 - include/sys/u8_textprep.h | 28 - include/sys/unistd.h | 28 - include/sys/va_list.h | 28 - include/sys/varargs.h | 30 - include/sys/vfs_opreg.h | 28 - include/unistd.h | 28 - include/util/Makefile.am | 14 - include/util/qsort.h | 32 - include/util/sscanf.h | 28 - include/vm/Makefile.am | 15 - include/vm/anon.h | 28 - include/vm/pvn.h | 28 - include/vm/seg_kmem.h | 30 - lib/Makefile.am | 6 - lib/list.c | 837 --------- lib/list.h | 279 --- man/Makefile.am | 1 - man/man1/Makefile.am | 4 - man/man1/splat.1 | 94 - man/man5/Makefile.am | 4 - module/.gitignore | 13 - module/Makefile.in | 54 - module/spl/Makefile.in | 30 - module/spl/THIRDPARTYLICENSE.gplv2 | 339 ++++ module/spl/THIRDPARTYLICENSE.gplv2.descrip | 1 + module/spl/spl-generic.c | 9 +- module/spl/spl-kmem-cache.c | 4 +- module/spl/spl-kstat.c | 1 + module/spl/spl-proc.c | 2 +- module/spl/spl-vmem.c | 2 +- module/spl/spl-vnode.c | 76 +- module/spl/spl-xdr.c | 4 +- module/spl/spl-zlib.c | 1 - module/splat/Makefile.in | 28 - module/splat/splat-atomic.c | 233 --- module/splat/splat-condvar.c | 511 ------ module/splat/splat-cred.c | 299 ---- module/splat/splat-ctl.c | 753 -------- module/splat/splat-generic.c | 367 ---- module/splat/splat-internal.h | 150 -- module/splat/splat-kmem.c | 1410 --------------- module/splat/splat-kobj.c | 166 -- module/splat/splat-linux.c | 237 --- module/splat/splat-list.c | 475 ----- module/splat/splat-mutex.c | 447 ----- module/splat/splat-random.c | 130 -- module/splat/splat-rwlock.c | 747 -------- module/splat/splat-taskq.c | 1548 ----------------- module/splat/splat-thread.c | 390 ----- module/splat/splat-time.c | 119 -- module/splat/splat-vnode.c | 355 ---- module/splat/splat-zlib.c | 166 -- rpm/Makefile.am | 1 - rpm/generic/.gitignore | 3 - rpm/generic/Makefile.am | 1 - rpm/generic/spl-dkms.spec.in | 94 - rpm/generic/spl-kmod.spec.in | 172 -- rpm/generic/spl.spec.in | 49 - rpm/redhat/.gitignore | 3 - rpm/redhat/Makefile.am | 1 - rpm/redhat/spl-dkms.spec.in | 1 - rpm/redhat/spl-kmod.spec.in | 110 -- rpm/redhat/spl.spec.in | 1 - scripts/Makefile.am | 4 - scripts/check.sh | 97 -- scripts/dkms.mkconf | 79 - scripts/dkms.postbuild | 24 - scripts/kmodtool | 592 ------- spl.release.in | 1 - 222 files changed, 777 insertions(+), 16870 deletions(-) delete mode 100644 .gitignore delete mode 100644 DISCLAIMER rename COPYING => LICENSE (100%) delete mode 100644 META delete mode 100644 Makefile.am create mode 100644 NOTICE delete mode 100644 README.markdown create mode 100644 README.md delete mode 100755 autogen.sh delete mode 100644 cmd/Makefile.am delete mode 100644 cmd/splat/.gitignore delete mode 100644 cmd/splat/Makefile.am delete mode 100644 cmd/splat/splat.c delete mode 100644 cmd/splat/splat.h delete mode 100644 cmd/splslab/Makefile.am delete mode 100755 cmd/splslab/splslab.py delete mode 100644 config/.gitignore delete mode 100644 config/Rules.am delete mode 100644 config/config.awk delete mode 100644 config/deb.am create mode 100644 config/kernel-fallocate-pax.m4 delete mode 100644 config/kernel-fallocate.m4 create mode 100644 config/kernel-kmem.m4 delete mode 100644 config/kernel-truncate-range.m4 delete mode 100644 config/rpm.am delete mode 100644 config/spl-build.m4 delete mode 100644 config/spl-meta.m4 delete mode 100644 config/tgz.am delete mode 100644 configure.ac delete mode 100755 copy-builtin delete mode 100644 include/Makefile.am delete mode 100644 include/fs/Makefile.am delete mode 100644 include/fs/fs_subr.h delete mode 100644 include/linux/Makefile.am delete mode 100644 include/linux/bitops_compat.h delete mode 100644 include/linux/compiler_compat.h delete mode 100644 include/linux/delay_compat.h delete mode 100644 include/linux/file_compat.h delete mode 100644 include/linux/list_compat.h delete mode 100644 include/linux/math64_compat.h delete mode 100644 include/linux/proc_compat.h delete mode 100644 include/linux/rwsem_compat.h delete mode 100644 include/linux/zlib_compat.h delete mode 100644 include/rpc/Makefile.am delete mode 100644 include/rpc/types.h delete mode 100644 include/sharefs/Makefile.am delete mode 100644 include/sharefs/share.h delete mode 100644 include/spl-ctl.h rename include/{ => spl}/rpc/xdr.h (99%) rename include/{ => spl}/sys/acl.h (100%) create mode 100644 include/spl/sys/atomic.h rename include/{ => spl}/sys/byteorder.h (89%) rename include/{ => spl}/sys/callb.h (100%) rename include/{ => spl}/sys/callo.h (100%) rename include/{ => spl}/sys/cmn_err.h (91%) rename include/{ => spl}/sys/condvar.h (98%) rename include/{ => spl}/sys/console.h (100%) rename include/{ => spl}/sys/cred.h (99%) rename include/{ => spl}/sys/ctype.h (100%) rename include/{ => spl}/sys/debug.h (100%) rename include/{ => spl}/sys/disp.h (100%) rename include/{ => spl}/sys/dkio.h (100%) rename include/{ => spl}/sys/dkioc_free_util.h (100%) rename include/{ => spl}/sys/fcntl.h (100%) rename include/{ => spl}/sys/file.h (50%) rename include/{ => spl}/sys/inttypes.h (100%) rename include/{ => spl}/sys/isa_defs.h (100%) rename include/{ => spl}/sys/kmem.h (100%) rename include/{ => spl}/sys/kmem_cache.h (100%) rename include/{ => spl}/sys/kobj.h (100%) rename include/{ => spl}/sys/kstat.h (99%) rename include/{ => spl}/sys/list.h (95%) rename include/{ => spl}/sys/mode.h (100%) rename include/{ => spl}/sys/mutex.h (99%) rename include/{ => spl}/sys/param.h (100%) rename include/{ => spl}/sys/proc.h (89%) rename include/{ => spl}/sys/processor.h (100%) rename include/{ => spl}/sys/random.h (100%) rename include/{ => spl}/sys/rwlock.h (78%) rename include/{linux/mm_compat.h => spl/sys/shrinker.h} (98%) rename include/{ => spl}/sys/sid.h (100%) rename include/{ => spl}/sys/signal.h (100%) rename include/{ => spl}/sys/stat.h (100%) rename include/{sys/idmap.h => spl/sys/strings.h} (71%) rename include/{ => spl}/sys/sunddi.h (98%) rename include/{ => spl}/sys/sysmacros.h (91%) rename include/{ => spl}/sys/systeminfo.h (100%) rename include/{ => spl}/sys/taskq.h (99%) rename include/{ => spl}/sys/thread.h (97%) rename include/{ => spl}/sys/time.h (100%) rename include/{ => spl}/sys/timer.h (86%) rename include/{ => spl}/sys/tsd.h (100%) rename include/{ => spl}/sys/types.h (57%) rename include/{ => spl}/sys/types32.h (97%) rename include/{ => spl}/sys/uio.h (100%) rename include/{ => spl}/sys/user.h (100%) rename include/{ => spl}/sys/vfs.h (100%) rename include/{ => spl}/sys/vmem.h (100%) rename include/{ => spl}/sys/vmsystm.h (100%) rename include/{ => spl}/sys/vnode.h (99%) rename include/{linux/wait_compat.h => spl/sys/wait.h} (95%) rename include/{ => spl}/sys/zmod.h (91%) rename include/{ => spl}/sys/zone.h (100%) delete mode 100644 include/splat-ctl.h delete mode 100644 include/strings.h delete mode 100644 include/sys/Makefile.am delete mode 100644 include/sys/acl_impl.h delete mode 100644 include/sys/atomic.h delete mode 100644 include/sys/attr.h delete mode 100644 include/sys/bitmap.h delete mode 100644 include/sys/bootconf.h delete mode 100644 include/sys/bootprops.h delete mode 100644 include/sys/buf.h delete mode 100644 include/sys/compress.h delete mode 100644 include/sys/conf.h delete mode 100644 include/sys/cpupart.h delete mode 100644 include/sys/cpuvar.h delete mode 100644 include/sys/crc32.h delete mode 100644 include/sys/ddi.h delete mode 100644 include/sys/dirent.h delete mode 100644 include/sys/dklabel.h delete mode 100644 include/sys/dnlc.h delete mode 100644 include/sys/dumphdr.h delete mode 100644 include/sys/efi_partition.h delete mode 100644 include/sys/errno.h delete mode 100644 include/sys/extdirent.h delete mode 100644 include/sys/fm/Makefile.am delete mode 100644 include/sys/fm/protocol.h delete mode 100644 include/sys/fm/util.h delete mode 100644 include/sys/fs/Makefile.am delete mode 100644 include/sys/fs/swapnode.h delete mode 100644 include/sys/int_limits.h delete mode 100644 include/sys/int_types.h delete mode 100644 include/sys/kidmap.h delete mode 100644 include/sys/mkdev.h delete mode 100644 include/sys/mntent.h delete mode 100644 include/sys/modctl.h delete mode 100644 include/sys/mount.h delete mode 100644 include/sys/note.h delete mode 100644 include/sys/open.h delete mode 100644 include/sys/pathname.h delete mode 100644 include/sys/policy.h delete mode 100644 include/sys/pool.h delete mode 100644 include/sys/priv_impl.h delete mode 100644 include/sys/pset.h delete mode 100644 include/sys/refstr.h delete mode 100644 include/sys/resource.h delete mode 100644 include/sys/sdt.h delete mode 100644 include/sys/stropts.h delete mode 100644 include/sys/sunldi.h delete mode 100644 include/sys/sysdc.h delete mode 100644 include/sys/systm.h delete mode 100644 include/sys/t_lock.h delete mode 100644 include/sys/u8_textprep.h delete mode 100644 include/sys/unistd.h delete mode 100644 include/sys/va_list.h delete mode 100644 include/sys/varargs.h delete mode 100644 include/sys/vfs_opreg.h delete mode 100644 include/unistd.h delete mode 100644 include/util/Makefile.am delete mode 100644 include/util/qsort.h delete mode 100644 include/util/sscanf.h delete mode 100644 include/vm/Makefile.am delete mode 100644 include/vm/anon.h delete mode 100644 include/vm/pvn.h delete mode 100644 include/vm/seg_kmem.h delete mode 100644 lib/Makefile.am delete mode 100644 lib/list.c delete mode 100644 lib/list.h delete mode 100644 man/Makefile.am delete mode 100644 man/man1/Makefile.am delete mode 100644 man/man1/splat.1 delete mode 100644 man/man5/Makefile.am delete mode 100644 module/.gitignore delete mode 100644 module/Makefile.in delete mode 100644 module/spl/Makefile.in create mode 100644 module/spl/THIRDPARTYLICENSE.gplv2 create mode 100644 module/spl/THIRDPARTYLICENSE.gplv2.descrip delete mode 100644 module/splat/Makefile.in delete mode 100644 module/splat/splat-atomic.c delete mode 100644 module/splat/splat-condvar.c delete mode 100644 module/splat/splat-cred.c delete mode 100644 module/splat/splat-ctl.c delete mode 100644 module/splat/splat-generic.c delete mode 100644 module/splat/splat-internal.h delete mode 100644 module/splat/splat-kmem.c delete mode 100644 module/splat/splat-kobj.c delete mode 100644 module/splat/splat-linux.c delete mode 100644 module/splat/splat-list.c delete mode 100644 module/splat/splat-mutex.c delete mode 100644 module/splat/splat-random.c delete mode 100644 module/splat/splat-rwlock.c delete mode 100644 module/splat/splat-taskq.c delete mode 100644 module/splat/splat-thread.c delete mode 100644 module/splat/splat-time.c delete mode 100644 module/splat/splat-vnode.c delete mode 100644 module/splat/splat-zlib.c delete mode 100644 rpm/Makefile.am delete mode 100644 rpm/generic/.gitignore delete mode 100644 rpm/generic/Makefile.am delete mode 100644 rpm/generic/spl-dkms.spec.in delete mode 100644 rpm/generic/spl-kmod.spec.in delete mode 100644 rpm/generic/spl.spec.in delete mode 100644 rpm/redhat/.gitignore delete mode 100644 rpm/redhat/Makefile.am delete mode 120000 rpm/redhat/spl-dkms.spec.in delete mode 100644 rpm/redhat/spl-kmod.spec.in delete mode 120000 rpm/redhat/spl.spec.in delete mode 100644 scripts/Makefile.am delete mode 100755 scripts/check.sh delete mode 100755 scripts/dkms.mkconf delete mode 100755 scripts/dkms.postbuild delete mode 100644 scripts/kmodtool delete mode 100644 spl.release.in diff --git a/.gitignore b/.gitignore deleted file mode 100644 index de9d87808..000000000 --- a/.gitignore +++ /dev/null @@ -1,52 +0,0 @@ -# -# N.B. -# This is the toplevel .gitignore file. -# This is not the place for entries that are specific to -# a subdirectory. Instead add those files to the -# .gitignore file in that subdirectory. -# -# N.B. -# Please use 'git ls-files -i --exclude-standard' -# command after changing this file, to see if there are -# any tracked files which get ignored after the change. - -# -# Normal rules -# -*.[oad] -*.lo -*.la -*~ -*.swp -.deps -.libs -.DS_Store -Makefile -Makefile.in - -# -# Top level generated files specific to this top level dir -# -/configure -/config.log -/config.status -/libtool -/spl_config.h -/spl_config.h.in -/spl.release -/stamp-h1 -/aclocal.m4 -/autom4te.cache - -# -# Top level generic files -# -!.gitignore -tags -TAGS -cscope.* -*.rpm -*.deb -*.tar.gz -*.patch -*.orig diff --git a/DISCLAIMER b/DISCLAIMER deleted file mode 100644 index 1bb04be7e..000000000 --- a/DISCLAIMER +++ /dev/null @@ -1,24 +0,0 @@ -This work was produced at the Lawrence Livermore National Laboratory -(LLNL) under Contract No. DE-AC52-07NA27344 (Contract 44) between -the U.S. Department of Energy (DOE) and Lawrence Livermore National -Security, LLC (LLNS) for the operation of LLNL. - -This work was prepared as an account of work sponsored by an agency of -the United States Government. Neither the United States Government nor -Lawrence Livermore National Security, LLC nor any of their employees, -makes any warranty, express or implied, or assumes any liability or -responsibility for the accuracy, completeness, or usefulness of any -information, apparatus, product, or process disclosed, or represents -that its use would not infringe privately-owned rights. - -Reference herein to any specific commercial products, process, or -services by trade name, trademark, manufacturer or otherwise does -not necessarily constitute or imply its endorsement, recommendation, -or favoring by the United States Government or Lawrence Livermore -National Security, LLC. The views and opinions of authors expressed -herein do not necessarily state or reflect those of the Untied States -Government or Lawrence Livermore National Security, LLC, and shall -not be used for advertising or product endorsement purposes. - -The precise terms and conditions for copying, distribution, and -modification are specified in the file "COPYING". diff --git a/COPYING b/LICENSE similarity index 100% rename from COPYING rename to LICENSE diff --git a/META b/META deleted file mode 100644 index 740b294a5..000000000 --- a/META +++ /dev/null @@ -1,8 +0,0 @@ -Meta: 1 -Name: spl -Branch: 1.0 -Version: 0.7.0 -Release: 1 -Release-Tags: relext -License: GPL -Author: OpenZFS on Linux diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 05107cb19..000000000 --- a/Makefile.am +++ /dev/null @@ -1,55 +0,0 @@ - -ACLOCAL_AMFLAGS = -I config - -include config/rpm.am -include config/deb.am -include config/tgz.am - -SUBDIRS = include rpm -if CONFIG_USER -SUBDIRS += lib cmd man scripts -endif -if CONFIG_KERNEL -SUBDIRS += module - -extradir = @prefix@/src/spl-$(VERSION) -extra_HEADERS = spl.release.in spl_config.h.in - -kerneldir = @prefix@/src/spl-$(VERSION)/$(LINUX_VERSION) -nodist_kernel_HEADERS = spl.release spl_config.h module/$(LINUX_SYMBOLS) -endif - -AUTOMAKE_OPTIONS = foreign -EXTRA_DIST = autogen.sh META DISCLAIMER copy-builtin -EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am - -distclean-local:: - -$(RM) -R autom4te*.cache - -find . \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \ - -o -name .pc -o -name .hg -o -name .git \) -prune -o \ - \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ - -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ - -o -name '.*.rej' -o -name 'aclocal.m4' -o -size 0 \ - -o -name '*%' -o -name '.*.cmd' -o -name 'core' \ - -o -name 'Makefile' -o -name '$(LINUX_SYMBOLS)' \ - -o -name '*.order' -o -name '*.markers' \) \ - -type f -print | xargs $(RM) - -dist-hook: - sed -i 's/Release:[[:print:]]*/Release: $(RELEASE)/' \ - $(distdir)/META - -ctags: - $(RM) tags - find $(top_srcdir) -name .git -prune -o -name '*.[hc]' | xargs ctags - -etags: - $(RM) TAGS - find $(top_srcdir) -name .pc -prune -o -name '*.[hc]' | xargs etags -a - -tags: ctags etags - -pkg: @DEFAULT_PACKAGE@ -pkg-dkms: @DEFAULT_PACKAGE@-dkms -pkg-kmod: @DEFAULT_PACKAGE@-kmod -pkg-utils: @DEFAULT_PACKAGE@-utils diff --git a/NOTICE b/NOTICE new file mode 100644 index 000000000..321892039 --- /dev/null +++ b/NOTICE @@ -0,0 +1,16 @@ +This work was produced under the auspices of the U.S. Department of Energy by +Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344. + +This work was prepared as an account of work sponsored by an agency of the +United States Government. Neither the United States Government nor Lawrence +Livermore National Security, LLC, nor any of their employees makes any warranty, +expressed or implied, or assumes any legal liability or responsibility for the +accuracy, completeness, or usefulness of any information, apparatus, product, or +process disclosed, or represents that its use would not infringe privately owned +rights. Reference herein to any specific commercial product, process, or service +by trade name, trademark, manufacturer, or otherwise does not necessarily +constitute or imply its endorsement, recommendation, or favoring by the United +States Government or Lawrence Livermore National Security, LLC. The views and +opinions of authors expressed herein do not necessarily state or reflect those +of the United States Government or Lawrence Livermore National Security, LLC, +and shall not be used for advertising or product endorsement purposes. diff --git a/README.markdown b/README.markdown deleted file mode 100644 index bdf63ac2e..000000000 --- a/README.markdown +++ /dev/null @@ -1,36 +0,0 @@ -The Solaris Porting Layer (SPL) is a Linux kernel module which provides -many of the Solaris kernel APIs. This shim layer makes it possible to -run Solaris kernel code in the Linux kernel with relatively minimal -modification. This can be particularly useful when you want to track -upstream Solaris development closely and do not want the overhead of -maintaining a large patch which converts Solaris primitives to Linux -primitives. - -To build packages for your distribution: - - $ sh autogen.sh - $ ./configure - $ make pkg - -If you are building directly from the git tree and not an officially -released tarball you will need to generate the configure script. -This can be done by executing the autogen.sh script after installing -the GNU autotools for your distribution. - -To copy the kernel code inside your kernel source tree for builtin -compilation: - - $ sh autogen.sh - $ ./configure --enable-linux-builtin --with-linux=/usr/src/linux-... - $ ./copy-builtin /usr/src/linux-... - -The SPL comes with an automated test suite called SPLAT. The test suite -is implemented in two parts. There is a kernel module which contains -the tests and a user space utility which controls which tests are run. -To run the full test suite: - - $ sudo insmod ./module/splat/splat.ko - $ sudo ./cmd/splat --all - -Full documentation for building, configuring, testing, and using the -SPL can be found at: diff --git a/README.md b/README.md new file mode 100644 index 000000000..64283ec54 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +![img](http://zfsonlinux.org/images/zfs-linux.png) + +The Solaris Porting Layer, SPL, is a Linux kernel module which provides a +compatibility layer used by the [ZFS on Linux](http://zfsonlinux.org) project. + +# Installation + +The latest version of the SPL is maintained as part of the ZFS on Linux +Github repository: + + * Latest Version: https://github.com/zfsonlinux/zfs + +Cloning this repository is only needed when building version 0.7.x or earlier. + + * Version 0.7.x: https://github.com/zfsonlinux/spl/tree/spl-0.7-release + * Version 0.6.5.x: https://github.com/zfsonlinux/spl/tree/spl-0.6.5-release + +# Release + +The SPL is released under a GPLv2 license. For more details see the NOTICE +and LICENSE files; `UCRL-CODE-235197` diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 427394af4..000000000 --- a/autogen.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -autoreconf -fiv -rm -Rf autom4te.cache diff --git a/cmd/Makefile.am b/cmd/Makefile.am deleted file mode 100644 index 63a3c76f9..000000000 --- a/cmd/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = splat splslab diff --git a/cmd/splat/.gitignore b/cmd/splat/.gitignore deleted file mode 100644 index 97325b30d..000000000 --- a/cmd/splat/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/splat diff --git a/cmd/splat/Makefile.am b/cmd/splat/Makefile.am deleted file mode 100644 index 01afdcf25..000000000 --- a/cmd/splat/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -DEFAULT_INCLUDES += \ - -I$(top_srcdir)/lib - -sbin_PROGRAMS = splat - -splat_SOURCES = splat.c -splat_LDFLAGS = $(top_builddir)/lib/libcommon.la - -EXTRA_DIST = splat.h diff --git a/cmd/splat/splat.c b/cmd/splat/splat.c deleted file mode 100644 index d11a64ce8..000000000 --- a/cmd/splat/splat.c +++ /dev/null @@ -1,836 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) User Space Interface. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "splat.h" - -#undef ioctl - -static const char shortOpts[] = "hvlat:xc"; -static const struct option longOpts[] = { - { "help", no_argument, 0, 'h' }, - { "verbose", no_argument, 0, 'v' }, - { "list", no_argument, 0, 'l' }, - { "all", no_argument, 0, 'a' }, - { "test", required_argument, 0, 't' }, - { "exit", no_argument, 0, 'x' }, - { "nocolor", no_argument, 0, 'c' }, - { 0, 0, 0, 0 } -}; - -#define VERSION_SIZE 64 - -static List subsystems; /* Subsystem/tests */ -static int splatctl_fd; /* Control file descriptor */ -static char splat_version[VERSION_SIZE]; /* Kernel version string */ -static char *splat_buffer = NULL; /* Scratch space area */ -static int splat_buffer_size = 0; /* Scratch space size */ - - -static void test_list(List, int); -static int dev_clear(void); -static void subsystem_fini(subsystem_t *); -static void test_fini(test_t *); - - -static int usage(void) { - fprintf(stderr, "usage: splat [hvla] [-t >]\n"); - fprintf(stderr, - " --help -h This help\n" - " --verbose -v Increase verbosity\n" - " --list -l List all tests in all subsystems\n" - " --all -a Run all tests in all subsystems\n" - " --test -t Run 'test' in subsystem 'sub'\n" - " --exit -x Exit on first test error\n" - " --nocolor -c Do not colorize output\n"); - fprintf(stderr, "\n" - "Examples:\n" - " splat -t kmem:all # Runs all kmem tests\n" - " splat -t taskq:0x201 # Run taskq test 0x201\n"); - - return 0; -} - -static subsystem_t *subsystem_init(splat_user_t *desc) -{ - subsystem_t *sub; - - sub = (subsystem_t *)malloc(sizeof(*sub)); - if (sub == NULL) - return NULL; - - memcpy(&sub->sub_desc, desc, sizeof(*desc)); - - sub->sub_tests = list_create((ListDelF)test_fini); - if (sub->sub_tests == NULL) { - free(sub); - return NULL; - } - - return sub; -} - -static void subsystem_fini(subsystem_t *sub) -{ - assert(sub != NULL); - free(sub); -} - -static int subsystem_setup(void) -{ - splat_cfg_t *cfg; - int i, rc, size, cfg_size; - subsystem_t *sub; - splat_user_t *desc; - - /* Aquire the number of registered subsystems */ - cfg_size = sizeof(*cfg); - cfg = (splat_cfg_t *)malloc(cfg_size); - if (cfg == NULL) - return -ENOMEM; - - memset(cfg, 0, cfg_size); - cfg->cfg_magic = SPLAT_CFG_MAGIC; - cfg->cfg_cmd = SPLAT_CFG_SUBSYSTEM_COUNT; - - rc = ioctl(splatctl_fd, SPLAT_CFG, cfg); - if (rc) { - fprintf(stderr, "Ioctl() error 0x%lx / %d: %d\n", - (unsigned long)SPLAT_CFG, cfg->cfg_cmd, errno); - free(cfg); - return rc; - } - - size = cfg->cfg_rc1; - free(cfg); - - /* Based on the newly acquired number of subsystems allocate - * memory to get the descriptive information for them all. */ - cfg_size = sizeof(*cfg) + size * sizeof(splat_user_t); - cfg = (splat_cfg_t *)malloc(cfg_size); - if (cfg == NULL) - return -ENOMEM; - - memset(cfg, 0, cfg_size); - cfg->cfg_magic = SPLAT_CFG_MAGIC; - cfg->cfg_cmd = SPLAT_CFG_SUBSYSTEM_LIST; - cfg->cfg_data.splat_subsystems.size = size; - - rc = ioctl(splatctl_fd, SPLAT_CFG, cfg); - if (rc) { - fprintf(stderr, "Ioctl() error %lu / %d: %d\n", - (unsigned long) SPLAT_CFG, cfg->cfg_cmd, errno); - free(cfg); - return rc; - } - - /* Add the new subsystems in to the global list */ - size = cfg->cfg_rc1; - for (i = 0; i < size; i++) { - desc = &(cfg->cfg_data.splat_subsystems.descs[i]); - - sub = subsystem_init(desc); - if (sub == NULL) { - fprintf(stderr, "Error initializing subsystem: %s\n", - desc->name); - free(cfg); - return -ENOMEM; - } - - list_append(subsystems, sub); - } - - free(cfg); - return 0; -} - -static void subsystem_list(List l, int indent) -{ - ListIterator i; - subsystem_t *sub; - - fprintf(stdout, - "------------------------------ " - "Available SPLAT Tests " - "------------------------------\n"); - - i = list_iterator_create(l); - - while ((sub = list_next(i))) { - fprintf(stdout, "%*s0x%0*x %-*s ---- %s ----\n", - indent, "", - 4, sub->sub_desc.id, - SPLAT_NAME_SIZE + 7, sub->sub_desc.name, - sub->sub_desc.desc); - test_list(sub->sub_tests, indent + 7); - } - - list_iterator_destroy(i); -} - -static test_t *test_init(subsystem_t *sub, splat_user_t *desc) -{ - test_t *test; - - test = (test_t *)malloc(sizeof(*test)); - if (test == NULL) - return NULL; - - test->test_sub = sub; - memcpy(&test->test_desc, desc, sizeof(*desc)); - - return test; -} - -static void test_fini(test_t *test) -{ - assert(test != NULL); - free(test); -} - -static int test_setup(subsystem_t *sub) -{ - splat_cfg_t *cfg; - int i, rc, size; - test_t *test; - splat_user_t *desc; - - /* Aquire the number of registered tests for the give subsystem */ - cfg = (splat_cfg_t *)malloc(sizeof(*cfg)); - if (cfg == NULL) - return -ENOMEM; - - memset(cfg, 0, sizeof(*cfg)); - cfg->cfg_magic = SPLAT_CFG_MAGIC; - cfg->cfg_cmd = SPLAT_CFG_TEST_COUNT; - cfg->cfg_arg1 = sub->sub_desc.id; /* Subsystem of interest */ - - rc = ioctl(splatctl_fd, SPLAT_CFG, cfg); - if (rc) { - fprintf(stderr, "Ioctl() error %lu / %d: %d\n", - (unsigned long) SPLAT_CFG, cfg->cfg_cmd, errno); - free(cfg); - return rc; - } - - size = cfg->cfg_rc1; - free(cfg); - - /* Based on the newly aquired number of tests allocate enough - * memory to get the descriptive information for them all. */ - cfg = (splat_cfg_t *)malloc(sizeof(*cfg) + size*sizeof(splat_user_t)); - if (cfg == NULL) - return -ENOMEM; - - memset(cfg, 0, sizeof(*cfg) + size * sizeof(splat_user_t)); - cfg->cfg_magic = SPLAT_CFG_MAGIC; - cfg->cfg_cmd = SPLAT_CFG_TEST_LIST; - cfg->cfg_arg1 = sub->sub_desc.id; /* Subsystem of interest */ - cfg->cfg_data.splat_tests.size = size; - - rc = ioctl(splatctl_fd, SPLAT_CFG, cfg); - if (rc) { - fprintf(stderr, "Ioctl() error %lu / %d: %d\n", - (unsigned long) SPLAT_CFG, cfg->cfg_cmd, errno); - free(cfg); - return rc; - } - - /* Add the new tests in to the relevant subsystems */ - size = cfg->cfg_rc1; - for (i = 0; i < size; i++) { - desc = &(cfg->cfg_data.splat_tests.descs[i]); - - test = test_init(sub, desc); - if (test == NULL) { - fprintf(stderr, "Error initializing test: %s\n", - desc->name); - free(cfg); - return -ENOMEM; - } - - list_append(sub->sub_tests, test); - } - - free(cfg); - return 0; -} - -static test_t *test_copy(test_t *test) -{ - return test_init(test->test_sub, &test->test_desc); -} - -static void test_list(List l, int indent) -{ - ListIterator i; - test_t *test; - - i = list_iterator_create(l); - - while ((test = list_next(i))) - fprintf(stdout, "%*s0x%0*x %-*s %s\n", - indent, "", 04, test->test_desc.id, - SPLAT_NAME_SIZE, test->test_desc.name, - test->test_desc.desc); - - list_iterator_destroy(i); -} - -static test_t *test_find(char *sub_str, char *test_str) -{ - ListIterator si, ti; - subsystem_t *sub; - test_t *test; - __u32 sub_num, test_num; - - /* - * No error checking here because it may not be a number, it's - * perfectly OK for it to be a string. Since we're just using - * it for comparison purposes this is all very safe. - */ - sub_num = strtoul(sub_str, NULL, 0); - test_num = strtoul(test_str, NULL, 0); - - si = list_iterator_create(subsystems); - - while ((sub = list_next(si))) { - - if (strncmp(sub->sub_desc.name, sub_str, SPLAT_NAME_SIZE) && - sub->sub_desc.id != sub_num) - continue; - - ti = list_iterator_create(sub->sub_tests); - - while ((test = list_next(ti))) { - - if (!strncmp(test->test_desc.name, test_str, - SPLAT_NAME_SIZE) || test->test_desc.id==test_num) { - list_iterator_destroy(ti); - list_iterator_destroy(si); - return test; - } - } - - list_iterator_destroy(ti); - } - - list_iterator_destroy(si); - - return NULL; -} - -static int test_add(cmd_args_t *args, test_t *test) -{ - test_t *tmp; - - tmp = test_copy(test); - if (tmp == NULL) - return -ENOMEM; - - list_append(args->args_tests, tmp); - return 0; -} - -static int test_add_all(cmd_args_t *args) -{ - ListIterator si, ti; - subsystem_t *sub; - test_t *test; - int rc; - - si = list_iterator_create(subsystems); - - while ((sub = list_next(si))) { - ti = list_iterator_create(sub->sub_tests); - - while ((test = list_next(ti))) { - if ((rc = test_add(args, test))) { - list_iterator_destroy(ti); - list_iterator_destroy(si); - return rc; - } - } - - list_iterator_destroy(ti); - } - - list_iterator_destroy(si); - - return 0; -} - -static int test_run(cmd_args_t *args, test_t *test) -{ - subsystem_t *sub = test->test_sub; - splat_cmd_t *cmd; - int rc, cmd_size; - - dev_clear(); - - cmd_size = sizeof(*cmd); - cmd = (splat_cmd_t *)malloc(cmd_size); - if (cmd == NULL) - return -ENOMEM; - - memset(cmd, 0, cmd_size); - cmd->cmd_magic = SPLAT_CMD_MAGIC; - cmd->cmd_subsystem = sub->sub_desc.id; - cmd->cmd_test = test->test_desc.id; - cmd->cmd_data_size = 0; /* Unused feature */ - - fprintf(stdout, "%*s:%-*s ", - SPLAT_NAME_SIZE, sub->sub_desc.name, - SPLAT_NAME_SIZE, test->test_desc.name); - fflush(stdout); - rc = ioctl(splatctl_fd, SPLAT_CMD, cmd); - if (args->args_do_color) { - fprintf(stdout, "%s %s\n", rc ? - COLOR_RED "Fail" COLOR_RESET : - COLOR_GREEN "Pass" COLOR_RESET, - rc ? strerror(errno) : ""); - } else { - fprintf(stdout, "%s %s\n", rc ? - "Fail" : "Pass", - rc ? strerror(errno) : ""); - } - fflush(stdout); - free(cmd); - - if ((args->args_verbose == 1 && rc) || - (args->args_verbose >= 2)) { - if ((rc = read(splatctl_fd, splat_buffer, - splat_buffer_size - 1)) < 0) { - fprintf(stdout, "Error reading results: %d\n", rc); - } else { - fprintf(stdout, "\n%s\n", splat_buffer); - fflush(stdout); - } - } - - return rc; -} - -static int tests_run(cmd_args_t *args) -{ - ListIterator i; - test_t *test; - int rc; - - fprintf(stdout, - "------------------------------ " - "Running SPLAT Tests " - "------------------------------\n"); - - i = list_iterator_create(args->args_tests); - - while ((test = list_next(i))) { - rc = test_run(args, test); - if (rc && args->args_exit_on_error) { - list_iterator_destroy(i); - return rc; - } - } - - list_iterator_destroy(i); - return 0; -} - -static int args_parse_test(cmd_args_t *args, char *str) -{ - ListIterator si, ti; - subsystem_t *s; - test_t *t; - char *sub_str, *test_str; - int sub_num, test_num; - int sub_all = 0, test_all = 0; - int rc, flag = 0; - - test_str = strchr(str, ':'); - if (test_str == NULL) { - fprintf(stderr, "Test must be of the " - "form \n"); - return -EINVAL; - } - - sub_str = str; - test_str[0] = '\0'; - test_str = test_str + 1; - - sub_num = strtol(sub_str, NULL, 0); - test_num = strtol(test_str, NULL, 0); - - if (!strncasecmp(sub_str, "all", strlen(sub_str)) || (sub_num == -1)) - sub_all = 1; - - if (!strncasecmp(test_str,"all",strlen(test_str)) || (test_num == -1)) - test_all = 1; - - si = list_iterator_create(subsystems); - - if (sub_all) { - if (test_all) { - /* Add all tests from all subsystems */ - while ((s = list_next(si))) { - ti = list_iterator_create(s->sub_tests); - while ((t = list_next(ti))) { - if ((rc = test_add(args, t))) { - list_iterator_destroy(ti); - goto error_run; - } - } - list_iterator_destroy(ti); - } - } else { - /* Add a specific test from all subsystems */ - while ((s = list_next(si))) { - if ((t=test_find(s->sub_desc.name,test_str))) { - if ((rc = test_add(args, t))) - goto error_run; - - flag = 1; - } - } - - if (!flag) - fprintf(stderr, "No tests '%s:%s' could be " - "found\n", sub_str, test_str); - } - } else { - if (test_all) { - /* Add all tests from a specific subsystem */ - while ((s = list_next(si))) { - if (strncasecmp(sub_str, s->sub_desc.name, - strlen(sub_str))) - continue; - - ti = list_iterator_create(s->sub_tests); - while ((t = list_next(ti))) { - if ((rc = test_add(args, t))) { - list_iterator_destroy(ti); - goto error_run; - } - } - list_iterator_destroy(ti); - } - } else { - /* Add a specific test from a specific subsystem */ - if ((t = test_find(sub_str, test_str))) { - if ((rc = test_add(args, t))) - goto error_run; - } else { - fprintf(stderr, "Test '%s:%s' could not be " - "found\n", sub_str, test_str); - return -EINVAL; - } - } - } - - list_iterator_destroy(si); - - return 0; - -error_run: - list_iterator_destroy(si); - - fprintf(stderr, "Test '%s:%s' not added to run list: %d\n", - sub_str, test_str, rc); - - return rc; -} - -static void args_fini(cmd_args_t *args) -{ - assert(args != NULL); - - if (args->args_tests != NULL) - list_destroy(args->args_tests); - - free(args); -} - -static cmd_args_t * -args_init(int argc, char **argv) -{ - cmd_args_t *args; - int c, rc; - - if (argc == 1) { - usage(); - return (cmd_args_t *) NULL; - } - - /* Configure and populate the args structures */ - args = malloc(sizeof(*args)); - if (args == NULL) - return NULL; - - memset(args, 0, sizeof(*args)); - args->args_verbose = 0; - args->args_do_list = 0; - args->args_do_all = 0; - args->args_do_color = 1; - args->args_exit_on_error = 0; - args->args_tests = list_create((ListDelF)test_fini); - if (args->args_tests == NULL) { - args_fini(args); - return NULL; - } - - while ((c = getopt_long(argc, argv, shortOpts, longOpts, NULL)) != -1){ - switch (c) { - case 'v': args->args_verbose++; break; - case 'l': args->args_do_list = 1; break; - case 'a': args->args_do_all = 1; break; - case 'c': args->args_do_color = 0; break; - case 'x': args->args_exit_on_error = 1; break; - case 't': - if (args->args_do_all) { - fprintf(stderr, "Option -t is " - "useless when used with -a\n"); - args_fini(args); - return NULL; - } - - rc = args_parse_test(args, argv[optind - 1]); - if (rc) { - args_fini(args); - return NULL; - } - break; - case 'h': - case '?': - usage(); - args_fini(args); - return NULL; - default: - fprintf(stderr, "Unknown option '%s'\n", - argv[optind - 1]); - break; - } - } - - return args; -} - -static int -dev_clear(void) -{ - splat_cfg_t cfg; - int rc; - - memset(&cfg, 0, sizeof(cfg)); - cfg.cfg_magic = SPLAT_CFG_MAGIC; - cfg.cfg_cmd = SPLAT_CFG_BUFFER_CLEAR; - cfg.cfg_arg1 = 0; - - rc = ioctl(splatctl_fd, SPLAT_CFG, &cfg); - if (rc) - fprintf(stderr, "Ioctl() error %lu / %d: %d\n", - (unsigned long) SPLAT_CFG, cfg.cfg_cmd, errno); - - lseek(splatctl_fd, 0, SEEK_SET); - - return rc; -} - -static int -dev_size(int size) -{ - splat_cfg_t cfg; - int rc; - - memset(&cfg, 0, sizeof(cfg)); - cfg.cfg_magic = SPLAT_CFG_MAGIC; - cfg.cfg_cmd = SPLAT_CFG_BUFFER_SIZE; - cfg.cfg_arg1 = size; - - rc = ioctl(splatctl_fd, SPLAT_CFG, &cfg); - if (rc) { - fprintf(stderr, "Ioctl() error %lu / %d: %d\n", - (unsigned long) SPLAT_CFG, cfg.cfg_cmd, errno); - return rc; - } - - return cfg.cfg_rc1; -} - -static void -dev_fini(void) -{ - if (splat_buffer) - free(splat_buffer); - - if (splatctl_fd != -1) { - if (close(splatctl_fd) == -1) { - fprintf(stderr, "Unable to close %s: %d\n", - SPLAT_DEV, errno); - } - } -} - -static int -dev_init(void) -{ - ListIterator i; - subsystem_t *sub; - int rc; - - splatctl_fd = open(SPLAT_DEV, O_RDONLY); - if (splatctl_fd == -1) { - fprintf(stderr, "Unable to open %s: %d\n" - "Is the splat module loaded?\n", SPLAT_DEV, errno); - rc = errno; - goto error; - } - - /* Determine kernel module version string */ - memset(splat_version, 0, VERSION_SIZE); - if ((rc = read(splatctl_fd, splat_version, VERSION_SIZE - 1)) == -1) - goto error; - - if ((rc = dev_clear())) - goto error; - - if ((rc = dev_size(0)) < 0) - goto error; - - splat_buffer_size = rc; - splat_buffer = (char *)malloc(splat_buffer_size); - if (splat_buffer == NULL) { - rc = -ENOMEM; - goto error; - } - - memset(splat_buffer, 0, splat_buffer_size); - - /* Determine available subsystems */ - if ((rc = subsystem_setup()) != 0) - goto error; - - /* Determine available tests for all subsystems */ - i = list_iterator_create(subsystems); - - while ((sub = list_next(i))) { - if ((rc = test_setup(sub)) != 0) { - list_iterator_destroy(i); - goto error; - } - } - - list_iterator_destroy(i); - return 0; - -error: - if (splatctl_fd != -1) { - if (close(splatctl_fd) == -1) { - fprintf(stderr, "Unable to close %s: %d\n", - SPLAT_DEV, errno); - } - } - - return rc; -} - -int -init(void) -{ - int rc = 0; - - /* Allocate the subsystem list */ - subsystems = list_create((ListDelF)subsystem_fini); - if (subsystems == NULL) - rc = ENOMEM; - - return rc; -} - -void -fini(void) -{ - list_destroy(subsystems); -} - - -int -main(int argc, char **argv) -{ - cmd_args_t *args = NULL; - int rc = 0; - - /* General init */ - if ((rc = init())) - return rc; - - /* Device specific init */ - if ((rc = dev_init())) - goto out; - - /* Argument init and parsing */ - if ((args = args_init(argc, argv)) == NULL) { - rc = -1; - goto out; - } - - /* Generic kernel version string */ - if (args->args_verbose) - fprintf(stdout, "%s", splat_version); - - /* Print the available test list and exit */ - if (args->args_do_list) { - subsystem_list(subsystems, 0); - goto out; - } - - /* Add all available test to the list of tests to run */ - if (args->args_do_all) { - if ((rc = test_add_all(args))) - goto out; - } - - /* Run all the requested tests */ - if ((rc = tests_run(args))) - goto out; - -out: - if (args != NULL) - args_fini(args); - - dev_fini(); - fini(); - return rc; -} diff --git a/cmd/splat/splat.h b/cmd/splat/splat.h deleted file mode 100644 index 8fbc97cb6..000000000 --- a/cmd/splat/splat.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPLAT_H -#define _SPLAT_H - -#include "list.h" -#include "../include/splat-ctl.h" - -#define DEV_NAME "/dev/splatctl" -#define COLOR_BLACK "\033[0;30m" -#define COLOR_DK_GRAY "\033[1;30m" -#define COLOR_BLUE "\033[0;34m" -#define COLOR_LT_BLUE "\033[1;34m" -#define COLOR_GREEN "\033[0;32m" -#define COLOR_LT_GREEN "\033[1;32m" -#define COLOR_CYAN "\033[0;36m" -#define COLOR_LT_CYAN "\033[1;36m" -#define COLOR_RED "\033[0;31m" -#define COLOR_LT_RED "\033[1;31m" -#define COLOR_PURPLE "\033[0;35m" -#define COLOR_LT_PURPLE "\033[1;35m" -#define COLOR_BROWN "\033[0;33m" -#define COLOR_YELLOW "\033[1;33m" -#define COLOR_LT_GRAY "\033[0;37m" -#define COLOR_WHITE "\033[1;37m" -#define COLOR_RESET "\033[0m" - -typedef struct subsystem { - splat_user_t sub_desc; /* Subsystem description */ - List sub_tests; /* Assocated subsystem tests list */ -} subsystem_t; - -typedef struct test { - splat_user_t test_desc; /* Test description */ - subsystem_t *test_sub; /* Parent subsystem */ -} test_t; - -typedef struct cmd_args { - int args_verbose; /* Verbose flag */ - int args_do_list; /* Display all tests flag */ - int args_do_all; /* Run all tests flag */ - int args_do_color; /* Colorize output */ - int args_exit_on_error; /* Exit on first error flag */ - List args_tests; /* Requested subsystems/tests */ -} cmd_args_t; - -#endif /* _SPLAT_H */ - diff --git a/cmd/splslab/Makefile.am b/cmd/splslab/Makefile.am deleted file mode 100644 index b18d52d7e..000000000 --- a/cmd/splslab/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -bin_SCRIPTS = splslab.py -EXTRA_DIST = $(bin_SCRIPTS) diff --git a/cmd/splslab/splslab.py b/cmd/splslab/splslab.py deleted file mode 100755 index 160fb2776..000000000 --- a/cmd/splslab/splslab.py +++ /dev/null @@ -1,202 +0,0 @@ -#!/usr/bin/python - -import sys -import time -import getopt -import re -import signal -from collections import defaultdict - -class Stat: - # flag definitions based on the kmem.h - NOTOUCH = 1 - NODEBUG = 2 - KMEM = 32 - VMEM = 64 - SLAB = 128 - OFFSLAB = 256 - NOEMERGENCY = 512 - DEADLOCKED = 16384 - GROWING = 32768 - REAPING = 65536 - DESTROY = 131072 - - fdefs = { - NOTOUCH : "NTCH", - NODEBUG : "NDBG", - KMEM : "KMEM", - VMEM : "VMEM", - SLAB : "SLAB", - OFFSLAB : "OFSL", - NOEMERGENCY : "NEMG", - DEADLOCKED : "DDLK", - GROWING : "GROW", - REAPING : "REAP", - DESTROY : "DSTR" - } - - def __init__(self, name, flags, size, alloc, slabsize, objsize): - self._name = name - self._flags = self.f2str(flags) - self._size = size - self._alloc = alloc - self._slabsize = slabsize - self._objsize = objsize - - def f2str(self, flags): - fstring = '' - for k in Stat.fdefs.keys(): - if flags & k: - fstring = fstring + Stat.fdefs[k] + '|' - - fstring = fstring[:-1] - return fstring - -class CumulativeStat: - def __init__(self, skey="a"): - self._size = 0 - self._alloc = 0 - self._pct = 0 - self._skey = skey - self._regexp = \ - re.compile('(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+'); - self._stats = defaultdict(list) - - # Add another stat to the dictionary and re-calculate the totals - def add(self, s): - key = 0 - if self._skey == "a": - key = s._alloc - else: - key = s._size - self._stats[key].append(s) - self._size = self._size + s._size - self._alloc = self._alloc + s._alloc - if self._size: - self._pct = self._alloc * 100 / self._size - else: - self._pct = 0 - - # Parse the slab info in the procfs - # Calculate cumulative stats - def slab_update(self): - k = [line.strip() for line in open('/proc/spl/kmem/slab')] - - if not k: - sys.stderr.write("No SPL slab stats found\n") - sys.exit(1) - - del k[0:2] - - for s in k: - if not s: - continue - m = self._regexp.match(s) - if m: - self.add(Stat(m.group(1), int(m.group(2),16), int(m.group(3)), - int(m.group(4)), int(m.group(5)), int(m.group(6)))) - else: - sys.stderr.write("Error: unexpected input format\n" % s) - exit(-1) - - def show_header(self): - sys.stdout.write("\n%25s %20s %15s %15s %15s %15s\n\n" % \ - ("cache name", "flags", "size", "alloc", "slabsize", "objsize")) - - # Show up to the number of 'rows' of output sorted in descending order - # by the key specified earlier; if rows == 0, all rows are shown - def show(self, rows): - self.show_header() - i = 1 - done = False - for k in reversed(sorted(self._stats.keys())): - for s in self._stats[k]: - sys.stdout.write("%25s %20s %15d %15d %15d %15d\n" % \ - (s._name, s._flags, s._size, s._alloc, \ - s._slabsize, s._objsize)) - i = i + 1 - if rows != 0 and i > rows: - done = True - break - if done: - break - sys.stdout.write("%25s %36d %15d (%d%%)\n\n" % \ - ("Totals:", self._size, self._alloc, self._pct)) - -def usage(): - cmd = "Usage: splslab.py [-n|--num-rows] number [-s|--sort-by] " + \ - "[interval] [count]"; - sys.stderr.write("%s\n" % cmd) - sys.stderr.write("\t-h : print help\n") - sys.stderr.write("\t-n : --num-rows N : limit output to N top " + - "largest slabs (default: all)\n") - sys.stderr.write("\t-s : --sort-by key : sort output in descending " + - "order by total size (s)\n\t\tor allocated size (a) " + - "(default: a)\n") - sys.stderr.write("\tinterval : repeat every interval seconds\n") - sys.stderr.write("\tcount : output statistics count times and exit\n") - - -def main(): - - rows = 0 - count = 0 - skey = "a" - interval = 1 - - signal.signal(signal.SIGINT, signal.SIG_DFL) - - try: - opts, args = getopt.getopt( - sys.argv[1:], - "n:s:h", - [ - "num-rows", - "sort-by", - "help" - ] - ) - except getopt.error as e: - sys.stderr.write("Error: %s\n" % e.msg) - usage() - exit(-1) - - i = 1 - for opt, arg in opts: - if opt in ('-n', '--num-rows'): - rows = int(arg) - i = i + 2 - elif opt in ('-s', '--sort-by'): - if arg != "s" and arg != "a": - sys.stderr.write("Error: invalid sorting key \"%s\"\n" % arg) - usage() - exit(-1) - skey = arg - i = i + 2 - elif opt in ('-h', '--help'): - usage() - exit(0) - else: - break - - args = sys.argv[i:] - - interval = int(args[0]) if len(args) else interval - count = int(args[1]) if len(args) > 1 else count - - i = 0 - while True: - cs = CumulativeStat(skey) - cs.slab_update() - cs.show(rows) - - i = i + 1 - if count and i >= count: - break - - time.sleep(interval) - - return 0 - -if __name__ == '__main__': - main() diff --git a/config/.gitignore b/config/.gitignore deleted file mode 100644 index cd811a0a9..000000000 --- a/config/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -/compile -/config.guess -/config.sub -/depcomp -/install-sh -/ltmain.sh -/missing -/libtool.m4 -/lt*.m4 diff --git a/config/Rules.am b/config/Rules.am deleted file mode 100644 index 7c5d3283f..000000000 --- a/config/Rules.am +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. -# Copyright (C) 2007 The Regents of the University of California. -# Written by Brian Behlendorf . -############################################################################### -# Common rules for user space components. -############################################################################### - -DEFAULT_INCLUDES = -include ${top_builddir}/spl_config.h - -AM_LIBTOOLFLAGS = --silent -AM_CPPFLAGS = -D__USE_LARGEFILE64 -AM_CFLAGS = -Wall -Wshadow -Wstrict-prototypes -fno-strict-aliasing -AM_CFLAGS += ${DEBUG_CFLAGS} diff --git a/config/config.awk b/config/config.awk deleted file mode 100644 index cc4b7cc26..000000000 --- a/config/config.awk +++ /dev/null @@ -1,15 +0,0 @@ -# Remove default preprocessor define's from config.h -# PACKAGE -# PACKAGE_BUGREPORT -# PACKAGE_NAME -# PACKAGE_STRING -# PACKAGE_TARNAME -# PACKAGE_VERSION -# STDC_HEADERS -# VERSION - -BEGIN { RS = "" ; FS = "\n" } \ - !/.#define PACKAGE./ && \ - !/.#define VERSION./ && \ - !/.#define STDC_HEADERS./ \ - { print $0"\n" } diff --git a/config/deb.am b/config/deb.am deleted file mode 100644 index f745c9181..000000000 --- a/config/deb.am +++ /dev/null @@ -1,58 +0,0 @@ -############################################################################### -# Copyright (C) 2010 Lawrence Livermore National Security, LLC. -# Written by Brian Behlendorf . -############################################################################### -# Build targets for DEB packages. -# -# Long term native distro specific Debian style packaging should be added. -# In the short term RPM packages are built and converted to DEB packages -# using alien. If someone familiar with Debian style packaging were to -# update the build system to correctly build Debian style packages I would -# happily take it. Until then we will have to make due with alien. -# -############################################################################### - -deb-local: - @(if test "${HAVE_DPKGBUILD}" = "no"; then \ - echo -e "\n" \ - "*** Required util ${DPKGBUILD} missing. Please install the\n" \ - "*** package for your distribution which provides ${DPKGBUILD},\n" \ - "*** re-run configure, and try again.\n"; \ - exit 1; \ - fi; \ - if test "${HAVE_ALIEN}" = "no"; then \ - echo -e "\n" \ - "*** Required util ${ALIEN} missing. Please install the\n" \ - "*** package for your distribution which provides ${ALIEN},\n" \ - "*** re-run configure, and try again.\n"; \ - exit 1; \ - fi) - -deb-kmod: deb-local rpm-kmod - name=${PACKAGE}; \ - version=${VERSION}-${RELEASE}; \ - arch=`$(RPM) -qp $${name}-kmod-$${version}.src.rpm --qf %{arch} | tail -1`; \ - debarch=`$(DPKG) --print-architecture`; \ - pkg1=kmod-$${name}*$${version}.$${arch}.rpm; \ - fakeroot $(ALIEN) --bump=0 --scripts --to-deb --target=$$debarch $$pkg1; \ - $(RM) $$pkg1 - -deb-dkms: deb-local rpm-dkms - name=${PACKAGE}; \ - version=${VERSION}-${RELEASE}; \ - arch=`$(RPM) -qp $${name}-dkms-$${version}.src.rpm --qf %{arch} | tail -1`; \ - debarch=`$(DPKG) --print-architecture`; \ - pkg1=$${name}-dkms-$${version}.$${arch}.rpm; \ - fakeroot $(ALIEN) --bump=0 --scripts --to-deb --target=$$debarch $$pkg1; \ - $(RM) $$pkg1 - -deb-utils: deb-local rpm-utils - name=${PACKAGE}; \ - version=${VERSION}-${RELEASE}; \ - arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \ - debarch=`$(DPKG) --print-architecture`; \ - pkg1=$${name}-$${version}.$${arch}.rpm; \ - fakeroot $(ALIEN) --bump=0 --scripts --to-deb --target=$$debarch $$pkg1; \ - $(RM) $$pkg1 - -deb: deb-kmod deb-dkms deb-utils diff --git a/config/kernel-fallocate-pax.m4 b/config/kernel-fallocate-pax.m4 new file mode 100644 index 000000000..ac75a4c8e --- /dev/null +++ b/config/kernel-fallocate-pax.m4 @@ -0,0 +1,19 @@ +dnl # +dnl # PaX Linux 2.6.38 - 3.x API +dnl # +AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [ + AC_MSG_CHECKING([whether fops->fallocate() exists]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL; + struct file_operations_no_const fops __attribute__ ((unused)) = { + .fallocate = fallocate, + }; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel-fallocate.m4 b/config/kernel-fallocate.m4 deleted file mode 100644 index b8c82f464..000000000 --- a/config/kernel-fallocate.m4 +++ /dev/null @@ -1,68 +0,0 @@ -dnl # -dnl # Linux 2.6.38 - 3.x API -dnl # -AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [ - AC_MSG_CHECKING([whether fops->fallocate() exists]) - SPL_LINUX_TRY_COMPILE([ - #include - ],[ - long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL; - struct file_operations fops __attribute__ ((unused)) = { - .fallocate = fallocate, - }; - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) -dnl # -dnl # Linux 2.6.x - 2.6.37 API -dnl # -AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [ - AC_MSG_CHECKING([whether iops->fallocate() exists]) - SPL_LINUX_TRY_COMPILE([ - #include - ],[ - long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL; - struct inode_operations fops __attribute__ ((unused)) = { - .fallocate = fallocate, - }; - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -dnl # -dnl # PaX Linux 2.6.38 - 3.x API -dnl # -AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [ - AC_MSG_CHECKING([whether fops->fallocate() exists]) - SPL_LINUX_TRY_COMPILE([ - #include - ],[ - long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL; - struct file_operations_no_const fops __attribute__ ((unused)) = { - .fallocate = fallocate, - }; - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -dnl # -dnl # The fallocate callback was moved from the inode_operations -dnl # structure to the file_operations structure. -dnl # -AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [ - SPL_AC_KERNEL_FILE_FALLOCATE - SPL_AC_KERNEL_INODE_FALLOCATE - SPL_AC_PAX_KERNEL_FILE_FALLOCATE -]) diff --git a/config/kernel-kmem.m4 b/config/kernel-kmem.m4 new file mode 100644 index 000000000..cc055e530 --- /dev/null +++ b/config/kernel-kmem.m4 @@ -0,0 +1,58 @@ +dnl # +dnl # Enabled by default it provides a minimal level of memory tracking. +dnl # A total count of bytes allocated is kept for each alloc and free. +dnl # Then at module unload time a report to the console will be printed +dnl # if memory was leaked. +dnl # +AC_DEFUN([SPL_AC_DEBUG_KMEM], [ + AC_ARG_ENABLE([debug-kmem], + [AS_HELP_STRING([--enable-debug-kmem], + [Enable basic kmem accounting @<:@default=no@:>@])], + [], + [enable_debug_kmem=no]) + + AS_IF([test "x$enable_debug_kmem" = xyes], + [ + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM" + DEBUG_KMEM="_with_debug_kmem" + AC_DEFINE([DEBUG_KMEM], [1], + [Define to 1 to enable basic kmem accounting]) + ], [ + DEBUG_KMEM="_without_debug_kmem" + ]) + + AC_SUBST(DEBUG_KMEM) + AC_MSG_CHECKING([whether basic kmem accounting is enabled]) + AC_MSG_RESULT([$enable_debug_kmem]) +]) + +dnl # +dnl # Disabled by default it provides detailed memory tracking. This +dnl # feature also requires --enable-debug-kmem to be set. When enabled +dnl # not only will total bytes be tracked but also the location of every +dnl # alloc and free. When the SPL module is unloaded a list of all leaked +dnl # addresses and where they were allocated will be dumped to the console. +dnl # Enabling this feature has a significant impact on performance but it +dnl # makes finding memory leaks pretty straight forward. +dnl # +AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [ + AC_ARG_ENABLE([debug-kmem-tracking], + [AS_HELP_STRING([--enable-debug-kmem-tracking], + [Enable detailed kmem tracking @<:@default=no@:>@])], + [], + [enable_debug_kmem_tracking=no]) + + AS_IF([test "x$enable_debug_kmem_tracking" = xyes], + [ + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING" + DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking" + AC_DEFINE([DEBUG_KMEM_TRACKING], [1], + [Define to 1 to enable detailed kmem tracking]) + ], [ + DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking" + ]) + + AC_SUBST(DEBUG_KMEM_TRACKING) + AC_MSG_CHECKING([whether detailed kmem tracking is enabled]) + AC_MSG_RESULT([$enable_debug_kmem_tracking]) +]) diff --git a/config/kernel-truncate-range.m4 b/config/kernel-truncate-range.m4 deleted file mode 100644 index 4b1600b61..000000000 --- a/config/kernel-truncate-range.m4 +++ /dev/null @@ -1,19 +0,0 @@ -dnl # -dnl # 3.5 API change, -dnl # inode_operations.truncate_range removed -dnl # -AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [ - AC_MSG_CHECKING([whether truncate_range() inode operation is available]) - SPL_LINUX_TRY_COMPILE([ - #include - ],[ - struct inode_operations ops; - ops.truncate_range = NULL; - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1, - [truncate_range() inode operation is available]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/rpm.am b/config/rpm.am deleted file mode 100644 index 51a20b3e6..000000000 --- a/config/rpm.am +++ /dev/null @@ -1,87 +0,0 @@ -############################################################################### -# Copyright (C) 2007-2013 Lawrence Livermore National Security, LLC. -# Copyright (C) 2007 The Regents of the University of California. -# Written by Brian Behlendorf . -############################################################################### -# Build targets for RPM packages. -############################################################################### - -srpm-kmod: - $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-kmod" \ - def='${SRPM_DEFINE_COMMON} ${SRPM_DEFINE_KMOD}' srpm-common - -srpm-dkms: - $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-dkms" \ - def='${SRPM_DEFINE_COMMON} ${SRPM_DEFINE_DKMS}' srpm-common - -srpm-utils: - $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" \ - def='${SRPM_DEFINE_COMMON} ${SRPM_DEFINE_UTIL}' srpm-common - -srpm: srpm-kmod srpm-dkms srpm-utils -srpms: srpm-kmod srpm-dkms srpm-utils - -rpm-kmod: srpm-kmod - $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-kmod" \ - def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_KMOD}' rpm-common - -rpm-dkms: srpm-dkms - $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-dkms" \ - def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_DKMS}' rpm-common - -rpm-utils: srpm-utils - $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" \ - def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_UTIL}' rpm-common - -rpm: rpm-kmod rpm-dkms rpm-utils -rpms: rpm-kmod rpm-dkms rpm-utils - -rpm-local: - @(if test "${HAVE_RPMBUILD}" = "no"; then \ - echo -e "\n" \ - "*** Required util ${RPMBUILD} missing. Please install the\n" \ - "*** package for your distribution which provides ${RPMBUILD},\n" \ - "*** re-run configure, and try again.\n"; \ - exit 1; \ - fi; \ - mkdir -p $(rpmbuild)/TMP && \ - mkdir -p $(rpmbuild)/BUILD && \ - mkdir -p $(rpmbuild)/RPMS && \ - mkdir -p $(rpmbuild)/SRPMS && \ - mkdir -p $(rpmbuild)/SPECS && \ - cp ${RPM_SPEC_DIR}/$(rpmspec) $(rpmbuild)/SPECS && \ - mkdir -p $(rpmbuild)/SOURCES && \ - cp $(top_srcdir)/scripts/kmodtool $(rpmbuild)/SOURCES && \ - cp $(distdir).tar.gz $(rpmbuild)/SOURCES) - -srpm-common: dist - @(dist=`$(RPM) --eval %{?dist}`; \ - rpmpkg=$(pkg)-$(VERSION)-$(RELEASE)$$dist*src.rpm; \ - rpmspec=$(pkg).spec; \ - rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \ - $(MAKE) $(AM_MAKEFLAGS) \ - rpmbuild="$$rpmbuild" \ - rpmspec="$$rpmspec" \ - rpm-local || exit 1; \ - LANG=C $(RPMBUILD) \ - --define "_tmppath $$rpmbuild/TMP" \ - --define "_topdir $$rpmbuild" \ - $(def) -bs $$rpmbuild/SPECS/$$rpmspec || exit 1; \ - cp $$rpmbuild/SRPMS/$$rpmpkg . || exit 1; \ - rm -R $$rpmbuild) - -rpm-common: - @(dist=`$(RPM) --eval %{?dist}`; \ - rpmpkg=$(pkg)-$(VERSION)-$(RELEASE)$$dist*src.rpm; \ - rpmspec=$(pkg).spec; \ - rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \ - $(MAKE) $(AM_MAKEFLAGS) \ - rpmbuild="$$rpmbuild" \ - rpmspec="$$rpmspec" \ - rpm-local || exit 1; \ - LANG=C ${RPMBUILD} \ - --define "_tmppath $$rpmbuild/TMP" \ - --define "_topdir $$rpmbuild" \ - $(def) --rebuild $$rpmpkg || exit 1; \ - cp $$rpmbuild/RPMS/*/* . || exit 1; \ - rm -R $$rpmbuild) diff --git a/config/spl-build.m4 b/config/spl-build.m4 deleted file mode 100644 index 5c6c02af2..000000000 --- a/config/spl-build.m4 +++ /dev/null @@ -1,755 +0,0 @@ -############################################################################### -# Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. -# Copyright (C) 2007 The Regents of the University of California. -# Written by Brian Behlendorf . -############################################################################### -# SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration. -############################################################################### - -AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ - SPL_AC_KERNEL - - if test "${LINUX_OBJ}" != "${LINUX}"; then - KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" - fi - AC_SUBST(KERNELMAKE_PARAMS) - - KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes" - AC_SUBST(KERNELCPPFLAGS) - - SPL_AC_TEST_MODULE - SPL_AC_ATOMIC_SPINLOCK - SPL_AC_SHRINKER_CALLBACK - SPL_AC_CTL_NAME - SPL_AC_CONFIG_TRIM_UNUSED_KSYMS - SPL_AC_PDE_DATA - SPL_AC_SET_FS_PWD_WITH_CONST - SPL_AC_2ARGS_VFS_FSYNC - SPL_AC_INODE_TRUNCATE_RANGE - SPL_AC_FS_STRUCT_SPINLOCK - SPL_AC_KUIDGID_T - SPL_AC_KERNEL_FALLOCATE - SPL_AC_CONFIG_ZLIB_INFLATE - SPL_AC_CONFIG_ZLIB_DEFLATE - SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE - SPL_AC_SHRINK_CONTROL_STRUCT - SPL_AC_RWSEM_SPINLOCK_IS_RAW - SPL_AC_RWSEM_ACTIVITY - SPL_AC_RWSEM_ATOMIC_LONG_COUNT - SPL_AC_SCHED_RT_HEADER - SPL_AC_SCHED_SIGNAL_HEADER - SPL_AC_4ARGS_VFS_GETATTR - SPL_AC_3ARGS_VFS_GETATTR - SPL_AC_2ARGS_VFS_GETATTR - SPL_AC_USLEEP_RANGE - SPL_AC_KMEM_CACHE_ALLOCFLAGS - SPL_AC_WAIT_ON_BIT - SPL_AC_INODE_LOCK - SPL_AC_GROUP_INFO_GID - SPL_AC_KMEM_CACHE_CREATE_USERCOPY - SPL_AC_WAIT_QUEUE_ENTRY_T - SPL_AC_WAIT_QUEUE_HEAD_ENTRY - SPL_AC_IO_SCHEDULE_TIMEOUT - SPL_AC_KERNEL_WRITE - SPL_AC_KERNEL_READ - SPL_AC_KERNEL_TIMER_FUNCTION_TIMER_LIST -]) - -AC_DEFUN([SPL_AC_MODULE_SYMVERS], [ - modpost=$LINUX/scripts/Makefile.modpost - AC_MSG_CHECKING([kernel file name for module symbols]) - if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then - if grep -q Modules.symvers $modpost; then - LINUX_SYMBOLS=Modules.symvers - else - LINUX_SYMBOLS=Module.symvers - fi - - if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then - AC_MSG_ERROR([ - *** Please make sure the kernel devel package for your distribution - *** is installed. If you are building with a custom kernel, make sure the - *** kernel is configured, built, and the '--with-linux=PATH' configure - *** option refers to the location of the kernel source.]) - fi - else - LINUX_SYMBOLS=NONE - fi - AC_MSG_RESULT($LINUX_SYMBOLS) - AC_SUBST(LINUX_SYMBOLS) -]) - -AC_DEFUN([SPL_AC_KERNEL], [ - AC_ARG_WITH([linux], - AS_HELP_STRING([--with-linux=PATH], - [Path to kernel source]), - [kernelsrc="$withval"]) - - AC_ARG_WITH([linux-obj], - AS_HELP_STRING([--with-linux-obj=PATH], - [Path to kernel build objects]), - [kernelbuild="$withval"]) - - AC_MSG_CHECKING([kernel source directory]) - if test -z "$kernelsrc"; then - if test -e "/lib/modules/$(uname -r)/source"; then - headersdir="/lib/modules/$(uname -r)/source" - sourcelink=$(readlink -f "$headersdir") - elif test -e "/lib/modules/$(uname -r)/build"; then - headersdir="/lib/modules/$(uname -r)/build" - sourcelink=$(readlink -f "$headersdir") - else - sourcelink=$(ls -1d /usr/src/kernels/* \ - /usr/src/linux-* \ - 2>/dev/null | grep -v obj | tail -1) - fi - - if test -n "$sourcelink" && test -e ${sourcelink}; then - kernelsrc=`readlink -f ${sourcelink}` - else - kernelsrc="[Not found]" - fi - else - if test "$kernelsrc" = "NONE"; then - kernsrcver=NONE - fi - withlinux=yes - fi - - AC_MSG_RESULT([$kernelsrc]) - if test ! -d "$kernelsrc"; then - AC_MSG_ERROR([ - *** Please make sure the kernel devel package for your distribution - *** is installed and then try again. If that fails, you can specify the - *** location of the kernel source with the '--with-linux=PATH' option.]) - fi - - AC_MSG_CHECKING([kernel build directory]) - if test -z "$kernelbuild"; then - if test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"; then - kernelbuild=`readlink -f /lib/modules/$(uname -r)/build` - elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then - kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu} - elif test -d ${kernelsrc}-obj/${target_cpu}/default; then - kernelbuild=${kernelsrc}-obj/${target_cpu}/default - elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then - kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu} - else - kernelbuild=${kernelsrc} - fi - fi - AC_MSG_RESULT([$kernelbuild]) - - AC_MSG_CHECKING([kernel source version]) - utsrelease1=$kernelbuild/include/linux/version.h - utsrelease2=$kernelbuild/include/linux/utsrelease.h - utsrelease3=$kernelbuild/include/generated/utsrelease.h - if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then - utsrelease=linux/version.h - elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then - utsrelease=linux/utsrelease.h - elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then - utsrelease=generated/utsrelease.h - fi - - if test "$utsrelease"; then - kernsrcver=`(echo "#include <$utsrelease>"; - echo "kernsrcver=UTS_RELEASE") | - cpp -I $kernelbuild/include | - grep "^kernsrcver=" | cut -d \" -f 2` - - if test -z "$kernsrcver"; then - AC_MSG_RESULT([Not found]) - AC_MSG_ERROR([*** Cannot determine kernel version.]) - fi - else - AC_MSG_RESULT([Not found]) - if test "x$enable_linux_builtin" != xyes; then - AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.]) - else - AC_MSG_ERROR([ - *** Cannot find UTS_RELEASE definition. - *** Please run 'make prepare' inside the kernel source tree.]) - fi - fi - - AC_MSG_RESULT([$kernsrcver]) - - LINUX=${kernelsrc} - LINUX_OBJ=${kernelbuild} - LINUX_VERSION=${kernsrcver} - - AC_SUBST(LINUX) - AC_SUBST(LINUX_OBJ) - AC_SUBST(LINUX_VERSION) - - SPL_AC_MODULE_SYMVERS -]) - -dnl # -dnl # Default SPL user configuration -dnl # -AC_DEFUN([SPL_AC_CONFIG_USER], []) - -dnl # -dnl # Check for rpm+rpmbuild to build RPM packages. If these tools -dnl # are missing, it is non-fatal, but you will not be able to build -dnl # RPM packages and will be warned if you try too. -dnl # -dnl # By default, the generic spec file will be used because it requires -dnl # minimal dependencies. Distribution specific spec files can be -dnl # placed under the 'rpm/' directory and enabled using -dnl # the --with-spec= configure option. -dnl # -AC_DEFUN([SPL_AC_RPM], [ - RPM=rpm - RPMBUILD=rpmbuild - - AC_MSG_CHECKING([whether $RPM is available]) - AS_IF([tmp=$($RPM --version 2>/dev/null)], [ - RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') - HAVE_RPM=yes - AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)]) - ],[ - HAVE_RPM=no - AC_MSG_RESULT([$HAVE_RPM]) - ]) - - AC_MSG_CHECKING([whether $RPMBUILD is available]) - AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [ - RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') - HAVE_RPMBUILD=yes - AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)]) - ],[ - HAVE_RPMBUILD=no - AC_MSG_RESULT([$HAVE_RPMBUILD]) - ]) - - RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1"' - RPM_DEFINE_COMMON+=' --define "$(DEBUG_KMEM) 1"' - RPM_DEFINE_COMMON+=' --define "$(DEBUG_KMEM_TRACKING) 1"' - RPM_DEFINE_UTIL= - RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"' - RPM_DEFINE_KMOD+=' --define "_wrong_version_format_terminate_build 0"' - RPM_DEFINE_DKMS= - - SRPM_DEFINE_COMMON='--define "build_src_rpm 1"' - SRPM_DEFINE_UTIL= - SRPM_DEFINE_KMOD= - SRPM_DEFINE_DKMS= - - RPM_SPEC_DIR="rpm/generic" - AC_ARG_WITH([spec], - AS_HELP_STRING([--with-spec=SPEC], - [Spec files 'generic|redhat']), - [RPM_SPEC_DIR="rpm/$withval"]) - - AC_MSG_CHECKING([whether spec files are available]) - AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)]) - - AC_SUBST(HAVE_RPM) - AC_SUBST(RPM) - AC_SUBST(RPM_VERSION) - - AC_SUBST(HAVE_RPMBUILD) - AC_SUBST(RPMBUILD) - AC_SUBST(RPMBUILD_VERSION) - - AC_SUBST(RPM_SPEC_DIR) - AC_SUBST(RPM_DEFINE_UTIL) - AC_SUBST(RPM_DEFINE_KMOD) - AC_SUBST(RPM_DEFINE_DKMS) - AC_SUBST(RPM_DEFINE_COMMON) - AC_SUBST(SRPM_DEFINE_UTIL) - AC_SUBST(SRPM_DEFINE_KMOD) - AC_SUBST(SRPM_DEFINE_DKMS) - AC_SUBST(SRPM_DEFINE_COMMON) -]) - -dnl # -dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these -dnl # tools are missing it is non-fatal but you will not be able to build -dnl # DEB packages and will be warned if you try too. -dnl # -AC_DEFUN([SPL_AC_DPKG], [ - DPKG=dpkg - DPKGBUILD=dpkg-buildpackage - - AC_MSG_CHECKING([whether $DPKG is available]) - AS_IF([tmp=$($DPKG --version 2>/dev/null)], [ - DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }') - HAVE_DPKG=yes - AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)]) - ],[ - HAVE_DPKG=no - AC_MSG_RESULT([$HAVE_DPKG]) - ]) - - AC_MSG_CHECKING([whether $DPKGBUILD is available]) - AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [ - DPKGBUILD_VERSION=$(echo $tmp | \ - $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.') - HAVE_DPKGBUILD=yes - AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)]) - ],[ - HAVE_DPKGBUILD=no - AC_MSG_RESULT([$HAVE_DPKGBUILD]) - ]) - - AC_SUBST(HAVE_DPKG) - AC_SUBST(DPKG) - AC_SUBST(DPKG_VERSION) - - AC_SUBST(HAVE_DPKGBUILD) - AC_SUBST(DPKGBUILD) - AC_SUBST(DPKGBUILD_VERSION) -]) - -dnl # -dnl # Until native packaging for various different packing systems -dnl # can be added the least we can do is attempt to use alien to -dnl # convert the RPM packages to the needed package type. This is -dnl # a hack but so far it has worked reasonable well. -dnl # -AC_DEFUN([SPL_AC_ALIEN], [ - ALIEN=alien - - AC_MSG_CHECKING([whether $ALIEN is available]) - AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [ - ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }') - HAVE_ALIEN=yes - AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)]) - ],[ - HAVE_ALIEN=no - AC_MSG_RESULT([$HAVE_ALIEN]) - ]) - - AC_SUBST(HAVE_ALIEN) - AC_SUBST(ALIEN) - AC_SUBST(ALIEN_VERSION) -]) - -dnl # -dnl # Using the VENDOR tag from config.guess set the default -dnl # package type for 'make pkg': (rpm | deb | tgz) -dnl # -AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [ - AC_MSG_CHECKING([linux distribution]) - if test -f /etc/toss-release ; then - VENDOR=toss ; - elif test -f /etc/fedora-release ; then - VENDOR=fedora ; - elif test -f /etc/redhat-release ; then - VENDOR=redhat ; - elif test -f /etc/gentoo-release ; then - VENDOR=gentoo ; - elif test -f /etc/arch-release ; then - VENDOR=arch ; - elif test -f /etc/SuSE-release ; then - VENDOR=sles ; - elif test -f /etc/slackware-version ; then - VENDOR=slackware ; - elif test -f /etc/lunar.release ; then - VENDOR=lunar ; - elif test -f /etc/lsb-release ; then - VENDOR=ubuntu ; - elif test -f /etc/debian_version ; then - VENDOR=debian ; - else - VENDOR= ; - fi - AC_MSG_RESULT([$VENDOR]) - AC_SUBST(VENDOR) - - AC_MSG_CHECKING([default package type]) - case "$VENDOR" in - toss) DEFAULT_PACKAGE=rpm ;; - redhat) DEFAULT_PACKAGE=rpm ;; - fedora) DEFAULT_PACKAGE=rpm ;; - gentoo) DEFAULT_PACKAGE=tgz ;; - arch) DEFAULT_PACKAGE=tgz ;; - sles) DEFAULT_PACKAGE=rpm ;; - slackware) DEFAULT_PACKAGE=tgz ;; - lunar) DEFAULT_PACKAGE=tgz ;; - ubuntu) DEFAULT_PACKAGE=deb ;; - debian) DEFAULT_PACKAGE=deb ;; - *) DEFAULT_PACKAGE=rpm ;; - esac - - AC_MSG_RESULT([$DEFAULT_PACKAGE]) - AC_SUBST(DEFAULT_PACKAGE) -]) - -dnl # -dnl # Default SPL user configuration -dnl # -AC_DEFUN([SPL_AC_PACKAGE], [ - SPL_AC_DEFAULT_PACKAGE - SPL_AC_RPM - SPL_AC_DPKG - SPL_AC_ALIEN -]) - -AC_DEFUN([SPL_AC_LICENSE], [ - AC_MSG_CHECKING([spl author]) - AC_MSG_RESULT([$SPL_META_AUTHOR]) - - AC_MSG_CHECKING([spl license]) - AC_MSG_RESULT([$SPL_META_LICENSE]) -]) - -AC_DEFUN([SPL_AC_CONFIG], [ - SPL_CONFIG=all - AC_ARG_WITH([config], - AS_HELP_STRING([--with-config=CONFIG], - [Config file 'kernel|user|all|srpm']), - [SPL_CONFIG="$withval"]) - AC_ARG_ENABLE([linux-builtin], - [AC_HELP_STRING([--enable-linux-builtin], - [Configure for builtin in-tree kernel modules @<:@default=no@:>@])], - [], - [enable_linux_builtin=no]) - - AC_MSG_CHECKING([spl config]) - AC_MSG_RESULT([$SPL_CONFIG]); - AC_SUBST(SPL_CONFIG) - - case "$SPL_CONFIG" in - kernel) SPL_AC_CONFIG_KERNEL ;; - user) SPL_AC_CONFIG_USER ;; - all) SPL_AC_CONFIG_KERNEL - SPL_AC_CONFIG_USER ;; - srpm) ;; - *) - AC_MSG_RESULT([Error!]) - AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config, - user kernel|user|all|srpm]) ;; - esac - - AM_CONDITIONAL([CONFIG_USER], - [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all]) - AM_CONDITIONAL([CONFIG_KERNEL], - [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] && - [test "x$enable_linux_builtin" != xyes ]) -]) - -dnl # -dnl # Enable if the SPL should be compiled with internal debugging enabled. -dnl # By default this support is disabled. -dnl # -AC_DEFUN([SPL_AC_DEBUG], [ - AC_MSG_CHECKING([whether debugging is enabled]) - AC_ARG_ENABLE([debug], - [AS_HELP_STRING([--enable-debug], - [Enable generic debug support @<:@default=no@:>@])], - [], - [enable_debug=no]) - - AS_IF([test "x$enable_debug" = xyes], - [ - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror" - DEBUG_CFLAGS="-DDEBUG -Werror" - DEBUG_SPL="_with_debug" - ], [ - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG" - DEBUG_CFLAGS="-DNDEBUG" - DEBUG_SPL="_without_debug" - ]) - - AC_SUBST(DEBUG_CFLAGS) - AC_SUBST(DEBUG_SPL) - AC_MSG_RESULT([$enable_debug]) -]) - -dnl # -dnl # Enabled by default it provides a minimal level of memory tracking. -dnl # A total count of bytes allocated is kept for each alloc and free. -dnl # Then at module unload time a report to the console will be printed -dnl # if memory was leaked. -dnl # -AC_DEFUN([SPL_AC_DEBUG_KMEM], [ - AC_ARG_ENABLE([debug-kmem], - [AS_HELP_STRING([--enable-debug-kmem], - [Enable basic kmem accounting @<:@default=no@:>@])], - [], - [enable_debug_kmem=no]) - - AS_IF([test "x$enable_debug_kmem" = xyes], - [ - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM" - DEBUG_KMEM="_with_debug_kmem" - AC_DEFINE([DEBUG_KMEM], [1], - [Define to 1 to enable basic kmem accounting]) - ], [ - DEBUG_KMEM="_without_debug_kmem" - ]) - - AC_SUBST(DEBUG_KMEM) - AC_MSG_CHECKING([whether basic kmem accounting is enabled]) - AC_MSG_RESULT([$enable_debug_kmem]) -]) - -dnl # -dnl # Disabled by default it provides detailed memory tracking. This -dnl # feature also requires --enable-debug-kmem to be set. When enabled -dnl # not only will total bytes be tracked but also the location of every -dnl # alloc and free. When the SPL module is unloaded a list of all leaked -dnl # addresses and where they were allocated will be dumped to the console. -dnl # Enabling this feature has a significant impact on performance but it -dnl # makes finding memory leaks pretty straight forward. -dnl # -AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [ - AC_ARG_ENABLE([debug-kmem-tracking], - [AS_HELP_STRING([--enable-debug-kmem-tracking], - [Enable detailed kmem tracking @<:@default=no@:>@])], - [], - [enable_debug_kmem_tracking=no]) - - AS_IF([test "x$enable_debug_kmem_tracking" = xyes], - [ - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING" - DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking" - AC_DEFINE([DEBUG_KMEM_TRACKING], [1], - [Define to 1 to enable detailed kmem tracking]) - ], [ - DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking" - ]) - - AC_SUBST(DEBUG_KMEM_TRACKING) - AC_MSG_CHECKING([whether detailed kmem tracking is enabled]) - AC_MSG_RESULT([$enable_debug_kmem_tracking]) -]) - -dnl # -dnl # SPL_LINUX_CONFTEST -dnl # -AC_DEFUN([SPL_LINUX_CONFTEST], [ -cat confdefs.h - <<_ACEOF >conftest.c -$1 -_ACEOF -]) - -dnl # -dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY]) -dnl # -m4_define([SPL_LANG_PROGRAM], [ -$1 -int -main (void) -{ -dnl Do *not* indent the following line: there may be CPP directives. -dnl Don't move the `;' right after for the same reason. -$2 - ; - return 0; -} -]) - -dnl # -dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE -dnl # -AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [ - m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])]) - rm -Rf build && mkdir -p build && touch build/conftest.mod.c - echo "obj-m := conftest.o" >build/Makefile - modpost_flag='' - test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage - AS_IF( - [AC_TRY_COMMAND(cp conftest.c build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag) >/dev/null && AC_TRY_COMMAND([$3])], - [$4], - [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])] - ) - rm -Rf build -]) - -dnl # -dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE -dnl # -AC_DEFUN([SPL_LINUX_TRY_COMPILE], - [SPL_LINUX_COMPILE_IFELSE( - [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])], - [modules], - [test -s build/conftest.o], - [$3], [$4]) -]) - -dnl # -dnl # SPL_CHECK_SYMBOL_EXPORT -dnl # check symbol exported or not -dnl # -AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [ - grep -q -E '[[[:space:]]]$1[[[:space:]]]' \ - $LINUX_OBJ/Module*.symvers 2>/dev/null - rc=$? - if test $rc -ne 0; then - export=0 - for file in $2; do - grep -q -E "EXPORT_SYMBOL.*($1)" \ - "$LINUX_OBJ/$file" 2>/dev/null - rc=$? - if test $rc -eq 0; then - export=1 - break; - fi - done - if test $export -eq 0; then : - $4 - else : - $3 - fi - else : - $3 - fi -]) - -dnl # -dnl # SPL_LINUX_TRY_COMPILE_SYMBOL -dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT -dnl # is called if not compiling for builtin -dnl # -AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [ - SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1]) - if test $rc -ne 0; then : - $6 - else - if test "x$enable_linux_builtin" != xyes; then - SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1]) - fi - if test $rc -ne 0; then : - $6 - else : - $5 - fi - fi -]) - -dnl # -dnl # SPL_CHECK_SYMBOL_HEADER -dnl # check if a symbol prototype is defined in listed headers. -dnl # -AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [ - AC_MSG_CHECKING([whether symbol $1 exists in header]) - header=0 - for file in $3; do - grep -q "$2" "$LINUX/$file" 2>/dev/null - rc=$? - if test $rc -eq 0; then - header=1 - break; - fi - done - if test $header -eq 0; then - AC_MSG_RESULT([no]) - $5 - else - AC_MSG_RESULT([yes]) - $4 - fi -]) - -dnl # -dnl # SPL_CHECK_HEADER -dnl # check whether header exists and define HAVE_$2_HEADER -dnl # -AC_DEFUN([SPL_CHECK_HEADER], - [AC_MSG_CHECKING([whether header $1 exists]) - SPL_LINUX_TRY_COMPILE([ - #include <$1> - ],[ - return 0; - ],[ - AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists]) - AC_MSG_RESULT(yes) - $3 - ],[ - AC_MSG_RESULT(no) - $4 - ]) -]) - -dnl # -dnl # Basic toolchain sanity check. Verify that kernel modules can -dnl # be built and which symbols can be used. -dnl # -AC_DEFUN([SPL_AC_TEST_MODULE], - [AC_MSG_CHECKING([whether modules can be built]) - SPL_LINUX_TRY_COMPILE([],[],[ - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no]) - if test "x$enable_linux_builtin" != xyes; then - AC_MSG_ERROR([*** Unable to build an empty module.]) - else - AC_MSG_ERROR([ - *** Unable to build an empty module. - *** Please run 'make scripts' inside the kernel source tree.]) - fi - ]) - - AS_IF([test "x$cross_compiling" != xyes], [ - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([ - #include "$LINUX/include/linux/license.h" - ], [ - return !license_is_gpl_compatible( - "$SPL_META_LICENSE"); - ]) - ], [ - AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1], - [Define to 1 if GPL-only symbols can be used]) - ], [ - ]) - ]) -]) - -dnl # -dnl # Use the atomic implemenation based on global spinlocks. This -dnl # should only be needed by 32-bit kernels which do not provide -dnl # the atomic64_* API. It may be optionally enabled as a fallback -dnl # if problems are observed with the direct mapping to the native -dnl # Linux atomic operations. You may not disable atomic spinlocks -dnl # if you kernel does not an atomic64_* API. -dnl # -AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [ - AC_ARG_ENABLE([atomic-spinlocks], - [AS_HELP_STRING([--enable-atomic-spinlocks], - [Atomic types use spinlocks @<:@default=check@:>@])], - [], - [enable_atomic_spinlocks=check]) - - SPL_LINUX_TRY_COMPILE([ - #include - ],[ - atomic64_t *ptr __attribute__ ((unused)); - ],[ - have_atomic64_t=yes - AC_DEFINE(HAVE_ATOMIC64_T, 1, - [kernel defines atomic64_t]) - ],[ - have_atomic64_t=no - ]) - - AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [ - AS_IF([test "x$have_atomic64_t" = xyes], [ - enable_atomic_spinlocks=no - ],[ - enable_atomic_spinlocks=yes - ]) - ]) - - AS_IF([test "x$enable_atomic_spinlocks" = xyes], [ - AC_DEFINE([ATOMIC_SPINLOCK], [1], - [Atomic types use spinlocks]) - ],[ - AS_IF([test "x$have_atomic64_t" = xno], [ - AC_MSG_FAILURE( - [--disable-atomic-spinlocks given but required atomic64 support is unavailable]) - ]) - ]) - - AC_MSG_CHECKING([whether atomic types use spinlocks]) - AC_MSG_RESULT([$enable_atomic_spinlocks]) - - AC_MSG_CHECKING([whether kernel defines atomic64_t]) - AC_MSG_RESULT([$have_atomic64_t]) -]) diff --git a/config/spl-meta.m4 b/config/spl-meta.m4 deleted file mode 100644 index fbfaec4ab..000000000 --- a/config/spl-meta.m4 +++ /dev/null @@ -1,170 +0,0 @@ -dnl # -dnl # DESCRIPTION: -dnl # Read meta data from the META file. When building from a git repository -dnl # the SPL_META_RELEASE field will be overwritten if there is an annotated -dnl # tag matching the form SPL_META_NAME-SPL_META_VERSION-*. This allows -dnl # for working builds to be uniquely identified using the git commit hash. -dnl # -dnl # The META file format is as follows: -dnl # ^[ ]*KEY:[ \t]+VALUE$ -dnl # -dnl # In other words: -dnl # - KEY is separated from VALUE by a colon and one or more spaces/tabs. -dnl # - KEY and VALUE are case sensitive. -dnl # - Leading spaces are ignored. -dnl # - First match wins for duplicate keys. -dnl # -dnl # A line can be commented out by preceding it with a '#' (or technically -dnl # any non-space character since that will prevent the regex from -dnl # matching). -dnl # -dnl # WARNING: -dnl # Placing a colon followed by a space or tab (ie, ":[ \t]+") within the -dnl # VALUE will prematurely terminate the string since that sequence is -dnl # used as the awk field separator. -dnl # -dnl # KEYS: -dnl # The following META keys are recognized: -dnl # Name, Version, Release, Date, Author, LT_Current, LT_Revision, LT_Age -dnl # -dnl # Written by Chris Dunlap . -dnl # Modified by Brian Behlendorf . -dnl # -AC_DEFUN([SPL_AC_META], [ - AC_PROG_AWK - AC_MSG_CHECKING([metadata]) - - META="$srcdir/META" - _spl_ac_meta_type="none" - if test -f "$META"; then - _spl_ac_meta_type="META file" - - SPL_META_NAME=_SPL_AC_META_GETVAL([(Name|Project|Package)]); - if test -n "$SPL_META_NAME"; then - AC_DEFINE_UNQUOTED([SPL_META_NAME], ["$SPL_META_NAME"], - [Define the project name.] - ) - AC_SUBST([SPL_META_NAME]) - fi - - SPL_META_VERSION=_SPL_AC_META_GETVAL([Version]); - if test -n "$SPL_META_VERSION"; then - AC_DEFINE_UNQUOTED([SPL_META_VERSION], ["$SPL_META_VERSION"], - [Define the project version.] - ) - AC_SUBST([SPL_META_VERSION]) - fi - - SPL_META_RELEASE=_SPL_AC_META_GETVAL([Release]); - if test ! -f ".nogitrelease" && git rev-parse --git-dir > /dev/null 2>&1; then - _match="${SPL_META_NAME}-${SPL_META_VERSION}" - _alias=$(git describe --match=${_match} 2>/dev/null) - _release=$(echo ${_alias}|cut -f3- -d'-'|sed 's/-/_/g') - if test -n "${_release}"; then - SPL_META_RELEASE=${_release} - _spl_ac_meta_type="git describe" - else - _match="${SPL_META_NAME}-${SPL_META_VERSION}-${SPL_META_RELEASE}" - _alias=$(git describe --match=${_match} 2>/dev/null) - _release=$(echo ${_alias}|cut -f3- -d'-'|sed 's/-/_/g') - if test -n "${_release}"; then - SPL_META_RELEASE=${_release} - _spl_ac_meta_type="git describe" - fi - fi - fi - - if test -n "$SPL_META_RELEASE"; then - AC_DEFINE_UNQUOTED([SPL_META_RELEASE], ["$SPL_META_RELEASE"], - [Define the project release.] - ) - AC_SUBST([SPL_META_RELEASE]) - - RELEASE="$SPL_META_RELEASE" - AC_SUBST([RELEASE]) - fi - - SPL_META_LICENSE=_SPL_AC_META_GETVAL([License]); - if test -n "$SPL_META_LICENSE"; then - AC_DEFINE_UNQUOTED([SPL_META_LICENSE], ["$SPL_META_LICENSE"], - [Define the project license.] - ) - AC_SUBST([SPL_META_LICENSE]) - fi - - if test -n "$SPL_META_NAME" -a -n "$SPL_META_VERSION"; then - SPL_META_ALIAS="$SPL_META_NAME-$SPL_META_VERSION" - test -n "$SPL_META_RELEASE" && - SPL_META_ALIAS="$SPL_META_ALIAS-$SPL_META_RELEASE" - AC_DEFINE_UNQUOTED([SPL_META_ALIAS], - ["$SPL_META_ALIAS"], - [Define the project alias string.] - ) - AC_SUBST([SPL_META_ALIAS]) - fi - - SPL_META_DATA=_SPL_AC_META_GETVAL([Date]); - if test -n "$SPL_META_DATA"; then - AC_DEFINE_UNQUOTED([SPL_META_DATA], ["$SPL_META_DATA"], - [Define the project release date.] - ) - AC_SUBST([SPL_META_DATA]) - fi - - SPL_META_AUTHOR=_SPL_AC_META_GETVAL([Author]); - if test -n "$SPL_META_AUTHOR"; then - AC_DEFINE_UNQUOTED([SPL_META_AUTHOR], ["$SPL_META_AUTHOR"], - [Define the project author.] - ) - AC_SUBST([SPL_META_AUTHOR]) - fi - - m4_pattern_allow([^LT_(CURRENT|REVISION|AGE)$]) - SPL_META_LT_CURRENT=_SPL_AC_META_GETVAL([LT_Current]); - SPL_META_LT_REVISION=_SPL_AC_META_GETVAL([LT_Revision]); - SPL_META_LT_AGE=_SPL_AC_META_GETVAL([LT_Age]); - if test -n "$SPL_META_LT_CURRENT" \ - -o -n "$SPL_META_LT_REVISION" \ - -o -n "$SPL_META_LT_AGE"; then - test -n "$SPL_META_LT_CURRENT" || SPL_META_LT_CURRENT="0" - test -n "$SPL_META_LT_REVISION" || SPL_META_LT_REVISION="0" - test -n "$SPL_META_LT_AGE" || SPL_META_LT_AGE="0" - AC_DEFINE_UNQUOTED([SPL_META_LT_CURRENT], - ["$SPL_META_LT_CURRENT"], - [Define the libtool library 'current' - version information.] - ) - AC_DEFINE_UNQUOTED([SPL_META_LT_REVISION], - ["$SPL_META_LT_REVISION"], - [Define the libtool library 'revision' - version information.] - ) - AC_DEFINE_UNQUOTED([SPL_META_LT_AGE], ["$SPL_META_LT_AGE"], - [Define the libtool library 'age' - version information.] - ) - AC_SUBST([SPL_META_LT_CURRENT]) - AC_SUBST([SPL_META_LT_REVISION]) - AC_SUBST([SPL_META_LT_AGE]) - fi - fi - - AC_MSG_RESULT([$_spl_ac_meta_type]) - ] -) - -dnl # _SPL_AC_META_GETVAL (KEY_NAME_OR_REGEX) -dnl # -dnl # Returns the META VALUE associated with the given KEY_NAME_OR_REGEX expr. -dnl # -dnl # Despite their resemblance to line noise, -dnl # the "@<:@" and "@:>@" constructs are quadrigraphs for "[" and "]". -dnl # -dnl # -dnl # The "$[]1" and "$[]2" constructs prevent M4 parameter expansion -dnl # so a literal $1 and $2 will be passed to the resulting awk script, -dnl # whereas the "$1" will undergo M4 parameter expansion for the META key. -dnl # -AC_DEFUN([_SPL_AC_META_GETVAL], - [`$AWK -F ':@<:@ \t@:>@+' '$[]1 ~ /^ *$1$/ { print $[]2; exit }' $META`]dnl -) diff --git a/config/tgz.am b/config/tgz.am deleted file mode 100644 index 765be43b9..000000000 --- a/config/tgz.am +++ /dev/null @@ -1,44 +0,0 @@ -############################################################################### -# Copyright (C) 2010 Lawrence Livermore National Security, LLC. -# Written by Brian Behlendorf . -############################################################################### -# Build targets for TGZ packages. -# -# Long term native distro specific Slackware style packaging should be added. -# In the short term RPM packages are built and converted to TGZ packages -# using alien. If someone familiar with Slackware style packaging were to -# update the build system to correctly build Slackware style packages I would -# happily take it. Until then we will have to make due with alien. -# -############################################################################### - -tgz-local: - @(if test "${HAVE_ALIEN}" = "no"; then \ - echo -e "\n" \ - "*** Required util ${ALIEN} missing. Please install the\n" \ - "*** package for your distribution which provides ${ALIEN},\n" \ - "*** re-run configure, and try again.\n"; \ - exit 1; \ - fi) - -tgz-kmod: tgz-local rpm-kmod -if CONFIG_KERNEL - name=${PACKAGE}; \ - version=${VERSION}-${RELEASE}; \ - arch=`$(RPM) -qp $${name}-kmod-$${version}.src.rpm --qf %{arch} | tail -1`; \ - pkg1=kmod-$${name}*$${version}.$${arch}.rpm; \ - fakeroot $(ALIEN) --scripts --to-tgz $$pkg1; \ - $(RM) $$pkg1 -endif - -tgz-utils: tgz-local rpm-utils -if CONFIG_USER - name=${PACKAGE}; \ - version=${VERSION}-${RELEASE}; \ - arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \ - pkg1=$${name}-$${version}.$${arch}.rpm; \ - fakeroot $(ALIEN) --scripts --to-tgz $$pkg1; \ - $(RM) $$pkg1 -endif - -tgz: tgz-kmod tgz-utils diff --git a/configure.ac b/configure.ac deleted file mode 100644 index ab53879e7..000000000 --- a/configure.ac +++ /dev/null @@ -1,88 +0,0 @@ -############################################################################### -# SPL AutoConf Configuration -############################################################################### -# Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. -# Copyright (C) 2007 The Regents of the University of California. -# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). -# Written by Brian Behlendorf . -# UCRL-CODE-235197 -# -# This file is part of the SPL, Solaris Porting Layer. -# For details, see . -# -# The SPL is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# The SPL is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License along -# with the SPL. If not, see . -############################################################################### - -AC_INIT(m4_esyscmd(grep Name META | cut -d ':' -f 2 | tr -d ' \n'), - m4_esyscmd(grep Version META | cut -d ':' -f 2 | tr -d ' \n')) -AC_LANG(C) -SPL_AC_META -AC_CONFIG_AUX_DIR([config]) -AC_CONFIG_MACRO_DIR([config]) -AC_CANONICAL_SYSTEM -AM_MAINTAINER_MODE -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -AM_INIT_AUTOMAKE -AC_CONFIG_HEADERS([spl_config.h], [ - (mv spl_config.h spl_config.h.tmp && - awk -f ${ac_srcdir}/config/config.awk spl_config.h.tmp >spl_config.h && - rm spl_config.h.tmp) || exit 1]) - -AC_PROG_INSTALL -AC_PROG_CC -AC_PROG_LIBTOOL - -SPL_AC_LICENSE -SPL_AC_PACKAGE -SPL_AC_CONFIG -SPL_AC_DEBUG -SPL_AC_DEBUG_KMEM -SPL_AC_DEBUG_KMEM_TRACKING - -AC_CONFIG_FILES([ - Makefile - man/Makefile - man/man1/Makefile - man/man5/Makefile - lib/Makefile - cmd/Makefile - cmd/splat/Makefile - cmd/splslab/Makefile - module/Makefile - module/spl/Makefile - module/splat/Makefile - include/Makefile - include/fs/Makefile - include/linux/Makefile - include/rpc/Makefile - include/sharefs/Makefile - include/sys/Makefile - include/sys/fm/Makefile - include/sys/fs/Makefile - include/util/Makefile - include/vm/Makefile - scripts/Makefile - rpm/Makefile - rpm/redhat/Makefile - rpm/redhat/spl.spec - rpm/redhat/spl-kmod.spec - rpm/redhat/spl-dkms.spec - rpm/generic/Makefile - rpm/generic/spl.spec - rpm/generic/spl-kmod.spec - rpm/generic/spl-dkms.spec - spl.release -]) - -AC_OUTPUT diff --git a/copy-builtin b/copy-builtin deleted file mode 100755 index 34c482bab..000000000 --- a/copy-builtin +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash - -set -e - -usage() -{ - echo "usage: $0 " >&2 - exit 1 -} - -[ "$#" -eq 1 ] || usage -KERNEL_DIR="$(readlink --canonicalize-existing "$1")" - -MODULES=() -for MODULE_DIR in module/* -do - [ -d "$MODULE_DIR" ] || continue - MODULES+=("${MODULE_DIR##*/}") -done - -if ! [ -e 'spl_config.h' ] -then - echo >&2 - echo " $0: you did not run configure, or you're not in the SPL source directory." >&2 - echo " $0: run configure with --with-linux=$KERNEL_DIR and --enable-linux-builtin." >&2 - echo >&2 - exit 1 -fi - -make clean || true - -rm -rf "$KERNEL_DIR/include/spl" "$KERNEL_DIR/spl" -cp --recursive include "$KERNEL_DIR/include/spl" -cp --recursive module "$KERNEL_DIR/spl" -cp spl_config.h "$KERNEL_DIR/" -cp spl.release.in "$KERNEL_DIR/" - -adjust_obj_paths() -{ - local FILE="$1" - local LINE OBJPATH - - while IFS='' read -r LINE - do - OBJPATH="${LINE#\$(MODULE)-objs += }" - if [ "$OBJPATH" = "$LINE" ] - then - echo "$LINE" - else - echo "\$(MODULE)-objs += ${OBJPATH##*/}" - fi - done < "$FILE" > "$FILE.new" - mv "$FILE.new" "$FILE" -} - -for MODULE in "${MODULES[@]}" -do - adjust_obj_paths "$KERNEL_DIR/spl/$MODULE/Makefile" - sed -i.bak '/obj =/d' "$KERNEL_DIR/spl/$MODULE/Makefile" - sed -i.bak '/src =/d' "$KERNEL_DIR/spl/$MODULE/Makefile" -done - -cat > "$KERNEL_DIR/spl/Kconfig" <<"EOF" -config SPL - tristate "Solaris Porting Layer (SPL)" - help - This is the SPL library from the ZFS On Linux project. - - See http://zfsonlinux.org/ - - To compile this library as a module, choose M here. - - If unsure, say N. -EOF - -{ - cat <<-"EOF" - SPL_MODULE_CFLAGS = -I$(srctree)/include/spl - SPL_MODULE_CFLAGS += -include $(srctree)/spl_config.h - export SPL_MODULE_CFLAGS - - obj-$(CONFIG_SPL) := - EOF - - for MODULE in "${MODULES[@]}" - do - echo 'obj-$(CONFIG_SPL) += ' "$MODULE/" - done -} > "$KERNEL_DIR/spl/Kbuild" - -add_after() -{ - local FILE="$1" - local MARKER="$2" - local NEW="$3" - local LINE - - while IFS='' read -r LINE - do - echo "$LINE" - - if [ -n "$MARKER" -a "$LINE" = "$MARKER" ] - then - echo "$NEW" - MARKER='' - if IFS='' read -r LINE - then - [ "$LINE" != "$NEW" ] && echo "$LINE" - fi - fi - done < "$FILE" > "$FILE.new" - - mv "$FILE.new" "$FILE" -} - -add_after "$KERNEL_DIR/Kconfig" 'source "arch/$SRCARCH/Kconfig"' 'source "spl/Kconfig"' -# We must take care to build SPL before ZFS, otherwise the symbols required -# to link ZFS will not be available. -sed -i 's~mm/ fs/~mm/ spl/ fs/~' "$KERNEL_DIR/Makefile" - -echo >&2 -echo " $0: done." >&2 -echo " $0: now you can build the kernel with SPL support." >&2 -echo " $0: make sure you enable SPL support (CONFIG_SPL) before building." >&2 -echo >&2 - diff --git a/include/Makefile.am b/include/Makefile.am deleted file mode 100644 index 3200222db..000000000 --- a/include/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -SUBDIRS = fs linux rpc sharefs sys util vm - -COMMON_H = - -KERNEL_H = \ - $(top_srcdir)/include/splat-ctl.h \ - $(top_srcdir)/include/spl-ctl.h \ - $(top_srcdir)/include/strings.h \ - $(top_srcdir)/include/unistd.h - -USER_H = - -EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H) - -if CONFIG_KERNEL -kerneldir = @prefix@/src/spl-$(VERSION)/include -kernel_HEADERS = $(KERNEL_H) -endif diff --git a/include/fs/Makefile.am b/include/fs/Makefile.am deleted file mode 100644 index e0da4b32a..000000000 --- a/include/fs/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -COMMON_H = - -KERNEL_H = \ - $(top_srcdir)/include/fs/fs_subr.h - -USER_H = - -EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H) - -if CONFIG_KERNEL -kerneldir = @prefix@/src/spl-$(VERSION)/include/fs -kernel_HEADERS = $(KERNEL_H) -endif diff --git a/include/fs/fs_subr.h b/include/fs/fs_subr.h deleted file mode 100644 index 71f074205..000000000 --- a/include/fs/fs_subr.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_FS_FS_SUBR_H -#define _SPL_FS_FS_SUBR_H - -#endif /* SPL_FS_FS_SUBR_H */ diff --git a/include/linux/Makefile.am b/include/linux/Makefile.am deleted file mode 100644 index 712e94ebe..000000000 --- a/include/linux/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -COMMON_H = - -KERNEL_H = \ - $(top_srcdir)/include/linux/bitops_compat.h \ - $(top_srcdir)/include/linux/compiler_compat.h \ - $(top_srcdir)/include/linux/delay_compat.h \ - $(top_srcdir)/include/linux/file_compat.h \ - $(top_srcdir)/include/linux/list_compat.h \ - $(top_srcdir)/include/linux/math64_compat.h \ - $(top_srcdir)/include/linux/mm_compat.h \ - $(top_srcdir)/include/linux/proc_compat.h \ - $(top_srcdir)/include/linux/rwsem_compat.h \ - $(top_srcdir)/include/linux/wait_compat.h \ - $(top_srcdir)/include/linux/zlib_compat.h - -USER_H = - -EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H) - -if CONFIG_KERNEL -kerneldir = @prefix@/src/spl-$(VERSION)/include/linux -kernel_HEADERS = $(KERNEL_H) -endif diff --git a/include/linux/bitops_compat.h b/include/linux/bitops_compat.h deleted file mode 100644 index a62b628e8..000000000 --- a/include/linux/bitops_compat.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_BITOPS_COMPAT_H -#define _SPL_BITOPS_COMPAT_H - -#include - -#endif /* _SPL_BITOPS_COMPAT_H */ diff --git a/include/linux/compiler_compat.h b/include/linux/compiler_compat.h deleted file mode 100644 index 696d79572..000000000 --- a/include/linux/compiler_compat.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_COMPILER_COMPAT_H -#define _SPL_COMPILER_COMPAT_H - -#include - -#ifndef ACCESS_ONCE -/* - * Prevent the compiler from merging or refetching accesses. The compiler - * is also forbidden from reordering successive instances of ACCESS_ONCE(), - * but only when the compiler is aware of some particular ordering. One way - * to make the compiler aware of ordering is to put the two invocations of - * ACCESS_ONCE() in different C statements. - * - * This macro does absolutely -nothing- to prevent the CPU from reordering, - * merging, or refetching absolutely anything at any time. Its main intended - * use is to mediate communication between process-level code and irq/NMI - * handlers, all running on the same CPU. - */ -/* Taken from 2.6.33.2 */ -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) -#endif - -#endif /* _SPL_COMPILER_COMPAT_H */ diff --git a/include/linux/delay_compat.h b/include/linux/delay_compat.h deleted file mode 100644 index c7a381100..000000000 --- a/include/linux/delay_compat.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2007-2013 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_DELAY_COMPAT_H -#define _SPL_DELAY_COMPAT_H - -#include -#include - -/* usleep_range() introduced in 2.6.36 */ -#ifndef HAVE_USLEEP_RANGE - -static inline void -usleep_range(unsigned long min, unsigned long max) -{ - unsigned int min_ms = min / USEC_PER_MSEC; - - if (min >= MAX_UDELAY_MS) - msleep(min_ms); - else - udelay(min); -} - -#endif /* HAVE_USLEEP_RANGE */ - -#endif /* _SPL_DELAY_COMPAT_H */ diff --git a/include/linux/file_compat.h b/include/linux/file_compat.h deleted file mode 100644 index 55ba2cc76..000000000 --- a/include/linux/file_compat.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_FILE_COMPAT_H -#define _SPL_FILE_COMPAT_H - -#include -#include -#ifdef HAVE_FDTABLE_HEADER -#include -#endif - -static inline struct file * -spl_filp_open(const char *name, int flags, int mode, int *err) -{ - struct file *filp = NULL; - int rc; - - filp = filp_open(name, flags, mode); - if (IS_ERR(filp)) { - rc = PTR_ERR(filp); - if (err) - *err = rc; - filp = NULL; - } - return (filp); -} - -#define spl_filp_close(f) filp_close(f, NULL) -#define spl_filp_poff(f) (&(f)->f_pos) -#define spl_filp_write(fp, b, s, p) (fp)->f_op->write((fp), (b), (s), p) - -static inline int -spl_filp_fallocate(struct file *fp, int mode, loff_t offset, loff_t len) -{ - int error = -EOPNOTSUPP; - -#ifdef HAVE_FILE_FALLOCATE - if (fp->f_op->fallocate) - error = fp->f_op->fallocate(fp, mode, offset, len); -#else -#ifdef HAVE_INODE_FALLOCATE - if (fp->f_dentry && fp->f_dentry->d_inode && - fp->f_dentry->d_inode->i_op->fallocate) - error = fp->f_dentry->d_inode->i_op->fallocate( - fp->f_dentry->d_inode, mode, offset, len); -#endif /* HAVE_INODE_FALLOCATE */ -#endif /* HAVE_FILE_FALLOCATE */ - - return (error); -} - -static inline ssize_t -spl_kernel_write(struct file *file, const void *buf, size_t count, loff_t *pos) -{ -#if defined(HAVE_KERNEL_WRITE_PPOS) - return (kernel_write(file, buf, count, pos)); -#else - mm_segment_t saved_fs; - ssize_t ret; - - saved_fs = get_fs(); - set_fs(get_ds()); - - ret = vfs_write(file, (__force const char __user *)buf, count, pos); - - set_fs(saved_fs); - - return (ret); -#endif -} - -static inline ssize_t -spl_kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) -{ -#if defined(HAVE_KERNEL_READ_PPOS) - return (kernel_read(file, buf, count, pos)); -#else - mm_segment_t saved_fs; - ssize_t ret; - - saved_fs = get_fs(); - set_fs(get_ds()); - - ret = vfs_read(file, (void __user *)buf, count, pos); - - set_fs(saved_fs); - - return (ret); -#endif -} - -#ifdef HAVE_2ARGS_VFS_FSYNC -#define spl_filp_fsync(fp, sync) vfs_fsync(fp, sync) -#else -#define spl_filp_fsync(fp, sync) vfs_fsync(fp, (fp)->f_dentry, sync) -#endif /* HAVE_2ARGS_VFS_FSYNC */ - -#ifdef HAVE_INODE_LOCK_SHARED -#define spl_inode_lock(ip) inode_lock(ip) -#define spl_inode_unlock(ip) inode_unlock(ip) -#define spl_inode_lock_shared(ip) inode_lock_shared(ip) -#define spl_inode_unlock_shared(ip) inode_unlock_shared(ip) -#define spl_inode_trylock(ip) inode_trylock(ip) -#define spl_inode_trylock_shared(ip) inode_trylock_shared(ip) -#define spl_inode_is_locked(ip) inode_is_locked(ip) -#define spl_inode_lock_nested(ip, s) inode_lock_nested(ip, s) -#else -#define spl_inode_lock(ip) mutex_lock(&(ip)->i_mutex) -#define spl_inode_unlock(ip) mutex_unlock(&(ip)->i_mutex) -#define spl_inode_lock_shared(ip) mutex_lock(&(ip)->i_mutex) -#define spl_inode_unlock_shared(ip) mutex_unlock(&(ip)->i_mutex) -#define spl_inode_trylock(ip) mutex_trylock(&(ip)->i_mutex) -#define spl_inode_trylock_shared(ip) mutex_trylock(&(ip)->i_mutex) -#define spl_inode_is_locked(ip) mutex_is_locked(&(ip)->i_mutex) -#define spl_inode_lock_nested(ip, s) mutex_lock_nested(&(ip)->i_mutex, s) -#endif - -#endif /* SPL_FILE_COMPAT_H */ diff --git a/include/linux/list_compat.h b/include/linux/list_compat.h deleted file mode 100644 index fece8ad34..000000000 --- a/include/linux/list_compat.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_LIST_COMPAT_H -#define _SPL_LIST_COMPAT_H - -#include - -#ifndef list_for_each_entry_safe_reverse - -/* - * list_for_each_entry_safe_reverse - * @pos: the type * to use as a loop cursor. - * @n: another type * to use as temporary storage - * @head: the head for your list. - * @member: the name of the list_struct within the struct. - * - * Iterate backwards over list of given type, safe against removal - * of list entry. - */ -#define list_for_each_entry_safe_reverse(pos, n, head, member) \ - for (pos = list_entry((head)->prev, typeof(*pos), member), \ - n = list_entry(pos->member.prev, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.prev, typeof(*n), member)) - -#endif /* list_for_each_entry_safe_reverse */ - -#endif /* SPL_LIST_COMPAT_H */ diff --git a/include/linux/math64_compat.h b/include/linux/math64_compat.h deleted file mode 100644 index c02f58479..000000000 --- a/include/linux/math64_compat.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_MATH64_COMPAT_H -#define _SPL_MATH64_COMPAT_H - -#ifndef abs64 -/* CSTYLED */ -#define abs64(x) ({ uint64_t t = (x) >> 63; ((x) ^ t) - t; }) -#endif - -#endif /* _SPL_MATH64_COMPAT_H */ diff --git a/include/linux/proc_compat.h b/include/linux/proc_compat.h deleted file mode 100644 index 91d914e10..000000000 --- a/include/linux/proc_compat.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_PROC_COMPAT_H -#define _SPL_PROC_COMPAT_H - -#include - -extern struct proc_dir_entry *proc_spl_kstat; - -int spl_proc_init(void); -void spl_proc_fini(void); - -#endif /* SPL_PROC_COMPAT_H */ diff --git a/include/linux/rwsem_compat.h b/include/linux/rwsem_compat.h deleted file mode 100644 index 7a0dcf8dc..000000000 --- a/include/linux/rwsem_compat.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_RWSEM_COMPAT_H -#define _SPL_RWSEM_COMPAT_H - -#include - -#if defined(CONFIG_PREEMPT_RT_FULL) -#define SPL_RWSEM_SINGLE_READER_VALUE (1) -#define SPL_RWSEM_SINGLE_WRITER_VALUE (0) -#elif defined(CONFIG_RWSEM_GENERIC_SPINLOCK) -#define SPL_RWSEM_SINGLE_READER_VALUE (1) -#define SPL_RWSEM_SINGLE_WRITER_VALUE (-1) -#else -#define SPL_RWSEM_SINGLE_READER_VALUE (RWSEM_ACTIVE_READ_BIAS) -#define SPL_RWSEM_SINGLE_WRITER_VALUE (RWSEM_ACTIVE_WRITE_BIAS) -#endif - -/* Linux 3.16 changed activity to count for rwsem-spinlock */ -#if defined(CONFIG_PREEMPT_RT_FULL) -#define RWSEM_COUNT(sem) sem->read_depth -#elif defined(HAVE_RWSEM_ACTIVITY) -#define RWSEM_COUNT(sem) sem->activity -/* Linux 4.8 changed count to an atomic_long_t for !rwsem-spinlock */ -#elif defined(HAVE_RWSEM_ATOMIC_LONG_COUNT) -#define RWSEM_COUNT(sem) atomic_long_read(&(sem)->count) -#else -#define RWSEM_COUNT(sem) sem->count -#endif - -int rwsem_tryupgrade(struct rw_semaphore *rwsem); - -#if defined(RWSEM_SPINLOCK_IS_RAW) -#define spl_rwsem_lock_irqsave(lk, fl) raw_spin_lock_irqsave(lk, fl) -#define spl_rwsem_unlock_irqrestore(lk, fl) \ - raw_spin_unlock_irqrestore(lk, fl) -#define spl_rwsem_trylock_irqsave(lk, fl) raw_spin_trylock_irqsave(lk, fl) -#else -#define spl_rwsem_lock_irqsave(lk, fl) spin_lock_irqsave(lk, fl) -#define spl_rwsem_unlock_irqrestore(lk, fl) spin_unlock_irqrestore(lk, fl) -#define spl_rwsem_trylock_irqsave(lk, fl) spin_trylock_irqsave(lk, fl) -#endif /* RWSEM_SPINLOCK_IS_RAW */ - -#define spl_rwsem_is_locked(rwsem) rwsem_is_locked(rwsem) - -#endif /* _SPL_RWSEM_COMPAT_H */ diff --git a/include/linux/zlib_compat.h b/include/linux/zlib_compat.h deleted file mode 100644 index 3c14285d2..000000000 --- a/include/linux/zlib_compat.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2011 Lawrence Livermore National Security, LLC. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_ZLIB_COMPAT_H -#define _SPL_ZLIB_COMPAT_H - -#include - -#ifdef HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE -#define spl_zlib_deflate_workspacesize(wb, ml) \ - zlib_deflate_workspacesize(wb, ml) -#else -#define spl_zlib_deflate_workspacesize(wb, ml) \ - zlib_deflate_workspacesize() -#endif /* HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE */ - -#endif /* SPL_ZLIB_COMPAT_H */ diff --git a/include/rpc/Makefile.am b/include/rpc/Makefile.am deleted file mode 100644 index cfc824685..000000000 --- a/include/rpc/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -COMMON_H = - -KERNEL_H = \ - $(top_srcdir)/include/rpc/types.h \ - $(top_srcdir)/include/rpc/xdr.h - -USER_H = - -EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H) - -if CONFIG_KERNEL -kerneldir = @prefix@/src/spl-$(VERSION)/include/rpc -kernel_HEADERS = $(KERNEL_H) -endif diff --git a/include/rpc/types.h b/include/rpc/types.h deleted file mode 100644 index 4fb5415ab..000000000 --- a/include/rpc/types.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_RPC_TYPES_H -#define _SPL_RPC_TYPES_H - -typedef int bool_t; - -#endif /* SPL_RPC_TYPES_H */ diff --git a/include/sharefs/Makefile.am b/include/sharefs/Makefile.am deleted file mode 100644 index 10e709325..000000000 --- a/include/sharefs/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -COMMON_H = - -KERNEL_H = \ - $(top_srcdir)/include/sharefs/share.h - -USER_H = - -EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H) - -if CONFIG_KERNEL -kerneldir = @prefix@/src/spl-$(VERSION)/include/sharefs -kernel_HEADERS = $(KERNEL_H) -endif diff --git a/include/sharefs/share.h b/include/sharefs/share.h deleted file mode 100644 index a5bf0e2e1..000000000 --- a/include/sharefs/share.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_SHARE_H -#define _SPL_SHARE_H - -#endif /* SPL_SHARE_H */ diff --git a/include/spl-ctl.h b/include/spl-ctl.h deleted file mode 100644 index 571887d1d..000000000 --- a/include/spl-ctl.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _DEBUG_CTL_H -#define _DEBUG_CTL_H - -/* - * Contains shared definitions which both the user space - * and kernel space portions of splat must agree on. - */ -typedef struct spl_debug_header { - int ph_len; - int ph_flags; - int ph_subsys; - int ph_mask; - int ph_cpu_id; - int ph_sec; - long ph_usec; - int ph_stack; - int ph_pid; - int ph_line_num; -} spl_debug_header_t; - -#endif /* _DEBUG_CTL_H */ diff --git a/include/rpc/xdr.h b/include/spl/rpc/xdr.h similarity index 99% rename from include/rpc/xdr.h rename to include/spl/rpc/xdr.h index e349757d5..0b39b46cf 100644 --- a/include/rpc/xdr.h +++ b/include/spl/rpc/xdr.h @@ -23,7 +23,8 @@ #define _SPL_RPC_XDR_H #include -#include + +typedef int bool_t; /* * XDR enums and types. diff --git a/include/sys/acl.h b/include/spl/sys/acl.h similarity index 100% rename from include/sys/acl.h rename to include/spl/sys/acl.h diff --git a/include/spl/sys/atomic.h b/include/spl/sys/atomic.h new file mode 100644 index 000000000..51b547923 --- /dev/null +++ b/include/spl/sys/atomic.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. + * Copyright (C) 2007 The Regents of the University of California. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by Brian Behlendorf . + * UCRL-CODE-235197 + * + * This file is part of the SPL, Solaris Porting Layer. + * For details, see . + * + * The SPL is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * The SPL is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with the SPL. If not, see . + */ + +#ifndef _SPL_ATOMIC_H +#define _SPL_ATOMIC_H + +#include +#include +#include + +/* + * Map the atomic_* functions to the Linux counterparts. This relies on the + * fact that the atomic types are internally really a uint32 or uint64. If + * this were to change an alternate approach would be needed. + * + * N.B. Due to the limitations of the original API atomicity is not strictly + * preserved when using the 64-bit functions on a 32-bit system. In order + * to support this all consumers would need to be updated to use the Linux + * provided atomic_t and atomic64_t types. + */ +#define atomic_inc_32(v) atomic_inc((atomic_t *)(v)) +#define atomic_dec_32(v) atomic_dec((atomic_t *)(v)) +#define atomic_add_32(v, i) atomic_add((i), (atomic_t *)(v)) +#define atomic_sub_32(v, i) atomic_sub((i), (atomic_t *)(v)) +#define atomic_inc_32_nv(v) atomic_inc_return((atomic_t *)(v)) +#define atomic_dec_32_nv(v) atomic_dec_return((atomic_t *)(v)) +#define atomic_add_32_nv(v, i) atomic_add_return((i), (atomic_t *)(v)) +#define atomic_sub_32_nv(v, i) atomic_sub_return((i), (atomic_t *)(v)) +#define atomic_cas_32(v, x, y) atomic_cmpxchg((atomic_t *)(v), x, y) +#define atomic_swap_32(v, x) atomic_xchg((atomic_t *)(v), x) +#define atomic_inc_64(v) atomic64_inc((atomic64_t *)(v)) +#define atomic_dec_64(v) atomic64_dec((atomic64_t *)(v)) +#define atomic_add_64(v, i) atomic64_add((i), (atomic64_t *)(v)) +#define atomic_sub_64(v, i) atomic64_sub((i), (atomic64_t *)(v)) +#define atomic_inc_64_nv(v) atomic64_inc_return((atomic64_t *)(v)) +#define atomic_dec_64_nv(v) atomic64_dec_return((atomic64_t *)(v)) +#define atomic_add_64_nv(v, i) atomic64_add_return((i), (atomic64_t *)(v)) +#define atomic_sub_64_nv(v, i) atomic64_sub_return((i), (atomic64_t *)(v)) +#define atomic_cas_64(v, x, y) atomic64_cmpxchg((atomic64_t *)(v), x, y) +#define atomic_swap_64(v, x) atomic64_xchg((atomic64_t *)(v), x) + +#ifdef _LP64 +static __inline__ void * +atomic_cas_ptr(volatile void *target, void *cmp, void *newval) +{ + return ((void *)atomic_cas_64((volatile uint64_t *)target, + (uint64_t)cmp, (uint64_t)newval)); +} +#else /* _LP64 */ +static __inline__ void * +atomic_cas_ptr(volatile void *target, void *cmp, void *newval) +{ + return ((void *)atomic_cas_32((volatile uint32_t *)target, + (uint32_t)cmp, (uint32_t)newval)); +} +#endif /* _LP64 */ + +#endif /* _SPL_ATOMIC_H */ diff --git a/include/sys/byteorder.h b/include/spl/sys/byteorder.h similarity index 89% rename from include/sys/byteorder.h rename to include/spl/sys/byteorder.h index a0ff424f8..477707996 100644 --- a/include/sys/byteorder.h +++ b/include/spl/sys/byteorder.h @@ -28,6 +28,11 @@ #include #include +#define BSWAP_8(x) ((x) & 0xff) +#define BSWAP_16(x) ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8)) +#define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16)) +#define BSWAP_64(x) ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32)) + #define LE_16(x) cpu_to_le16(x) #define LE_32(x) cpu_to_le32(x) #define LE_64(x) cpu_to_le64(x) diff --git a/include/sys/callb.h b/include/spl/sys/callb.h similarity index 100% rename from include/sys/callb.h rename to include/spl/sys/callb.h diff --git a/include/sys/callo.h b/include/spl/sys/callo.h similarity index 100% rename from include/sys/callo.h rename to include/spl/sys/callo.h diff --git a/include/sys/cmn_err.h b/include/spl/sys/cmn_err.h similarity index 91% rename from include/sys/cmn_err.h rename to include/spl/sys/cmn_err.h index 594a76333..be57358b0 100644 --- a/include/sys/cmn_err.h +++ b/include/spl/sys/cmn_err.h @@ -25,7 +25,7 @@ #ifndef _SPL_CMN_ERR_H #define _SPL_CMN_ERR_H -#include +#include #define CE_CONT 0 /* continuation */ #define CE_NOTE 1 /* notice */ @@ -34,8 +34,8 @@ #define CE_IGNORE 4 /* print nothing */ extern void cmn_err(int, const char *, ...); -extern void vcmn_err(int, const char *, __va_list); -extern void vpanic(const char *, __va_list); +extern void vcmn_err(int, const char *, va_list); +extern void vpanic(const char *, va_list); #define fm_panic panic diff --git a/include/sys/condvar.h b/include/spl/sys/condvar.h similarity index 98% rename from include/sys/condvar.h rename to include/spl/sys/condvar.h index 5fcc9068a..1d47cdd96 100644 --- a/include/sys/condvar.h +++ b/include/spl/sys/condvar.h @@ -26,11 +26,10 @@ #define _SPL_CONDVAR_H #include -#include -#include #include #include #include +#include /* * The kcondvar_t struct is protected by mutex taken externally before diff --git a/include/sys/console.h b/include/spl/sys/console.h similarity index 100% rename from include/sys/console.h rename to include/spl/sys/console.h diff --git a/include/sys/cred.h b/include/spl/sys/cred.h similarity index 99% rename from include/sys/cred.h rename to include/spl/sys/cred.h index e4b18b665..fd063399b 100644 --- a/include/sys/cred.h +++ b/include/spl/sys/cred.h @@ -26,6 +26,7 @@ #define _SPL_CRED_H #include +#include #include #include diff --git a/include/sys/ctype.h b/include/spl/sys/ctype.h similarity index 100% rename from include/sys/ctype.h rename to include/spl/sys/ctype.h diff --git a/include/sys/debug.h b/include/spl/sys/debug.h similarity index 100% rename from include/sys/debug.h rename to include/spl/sys/debug.h diff --git a/include/sys/disp.h b/include/spl/sys/disp.h similarity index 100% rename from include/sys/disp.h rename to include/spl/sys/disp.h diff --git a/include/sys/dkio.h b/include/spl/sys/dkio.h similarity index 100% rename from include/sys/dkio.h rename to include/spl/sys/dkio.h diff --git a/include/sys/dkioc_free_util.h b/include/spl/sys/dkioc_free_util.h similarity index 100% rename from include/sys/dkioc_free_util.h rename to include/spl/sys/dkioc_free_util.h diff --git a/include/sys/fcntl.h b/include/spl/sys/fcntl.h similarity index 100% rename from include/sys/fcntl.h rename to include/spl/sys/fcntl.h diff --git a/include/sys/file.h b/include/spl/sys/file.h similarity index 50% rename from include/sys/file.h rename to include/spl/sys/file.h index b6c40aff2..05dbc0814 100644 --- a/include/sys/file.h +++ b/include/spl/sys/file.h @@ -25,7 +25,28 @@ #ifndef _SPL_FILE_H #define _SPL_FILE_H -#define FIGNORECASE 0x00080000 -#define FKIOCTL 0x80000000 +#define FIGNORECASE 0x00080000 +#define FKIOCTL 0x80000000 +#define ED_CASE_CONFLICT 0x10 + +#ifdef HAVE_INODE_LOCK_SHARED +#define spl_inode_lock(ip) inode_lock(ip) +#define spl_inode_unlock(ip) inode_unlock(ip) +#define spl_inode_lock_shared(ip) inode_lock_shared(ip) +#define spl_inode_unlock_shared(ip) inode_unlock_shared(ip) +#define spl_inode_trylock(ip) inode_trylock(ip) +#define spl_inode_trylock_shared(ip) inode_trylock_shared(ip) +#define spl_inode_is_locked(ip) inode_is_locked(ip) +#define spl_inode_lock_nested(ip, s) inode_lock_nested(ip, s) +#else +#define spl_inode_lock(ip) mutex_lock(&(ip)->i_mutex) +#define spl_inode_unlock(ip) mutex_unlock(&(ip)->i_mutex) +#define spl_inode_lock_shared(ip) mutex_lock(&(ip)->i_mutex) +#define spl_inode_unlock_shared(ip) mutex_unlock(&(ip)->i_mutex) +#define spl_inode_trylock(ip) mutex_trylock(&(ip)->i_mutex) +#define spl_inode_trylock_shared(ip) mutex_trylock(&(ip)->i_mutex) +#define spl_inode_is_locked(ip) mutex_is_locked(&(ip)->i_mutex) +#define spl_inode_lock_nested(ip, s) mutex_lock_nested(&(ip)->i_mutex, s) +#endif #endif /* SPL_FILE_H */ diff --git a/include/sys/inttypes.h b/include/spl/sys/inttypes.h similarity index 100% rename from include/sys/inttypes.h rename to include/spl/sys/inttypes.h diff --git a/include/sys/isa_defs.h b/include/spl/sys/isa_defs.h similarity index 100% rename from include/sys/isa_defs.h rename to include/spl/sys/isa_defs.h diff --git a/include/sys/kmem.h b/include/spl/sys/kmem.h similarity index 100% rename from include/sys/kmem.h rename to include/spl/sys/kmem.h diff --git a/include/sys/kmem_cache.h b/include/spl/sys/kmem_cache.h similarity index 100% rename from include/sys/kmem_cache.h rename to include/spl/sys/kmem_cache.h diff --git a/include/sys/kobj.h b/include/spl/sys/kobj.h similarity index 100% rename from include/sys/kobj.h rename to include/spl/sys/kobj.h diff --git a/include/sys/kstat.h b/include/spl/sys/kstat.h similarity index 99% rename from include/sys/kstat.h rename to include/spl/sys/kstat.h index e9aff7386..9170fe24e 100644 --- a/include/sys/kstat.h +++ b/include/spl/sys/kstat.h @@ -26,11 +26,11 @@ #define _SPL_KSTAT_H #include -#include #include #include #include #include +#include #define KSTAT_STRLEN 255 #define KSTAT_RAW_MAX (128*1024) diff --git a/include/sys/list.h b/include/spl/sys/list.h similarity index 95% rename from include/sys/list.h rename to include/spl/sys/list.h index d80c8474e..74b784e93 100644 --- a/include/sys/list.h +++ b/include/spl/sys/list.h @@ -72,10 +72,6 @@ list_link_init(list_node_t *node) static inline void list_create(list_t *list, size_t size, size_t offset) { - ASSERT(list); - ASSERT(size > 0); - ASSERT(size >= offset + sizeof (list_node_t)); - list->list_size = size; list->list_offset = offset; INIT_LIST_HEAD(&list->list_head); @@ -84,9 +80,6 @@ list_create(list_t *list, size_t size, size_t offset) static inline void list_destroy(list_t *list) { - ASSERT(list); - ASSERT(list_is_empty(list)); - list_del(&list->list_head); } @@ -123,7 +116,6 @@ list_insert_before(list_t *list, void *object, void *nobject) static inline void list_remove(list_t *list, void *object) { - ASSERT(!list_is_empty(list)); list_del(list_d2l(list, object)); } @@ -206,9 +198,6 @@ spl_list_move_tail(list_t *dst, list_t *src) static inline void list_link_replace(list_node_t *old_node, list_node_t *new_node) { - ASSERT(list_link_active(old_node)); - ASSERT(!list_link_active(new_node)); - new_node->next = old_node->next; new_node->prev = old_node->prev; old_node->prev->next = new_node; diff --git a/include/sys/mode.h b/include/spl/sys/mode.h similarity index 100% rename from include/sys/mode.h rename to include/spl/sys/mode.h diff --git a/include/sys/mutex.h b/include/spl/sys/mutex.h similarity index 99% rename from include/sys/mutex.h rename to include/spl/sys/mutex.h index c7084b3c3..f906d49d4 100644 --- a/include/sys/mutex.h +++ b/include/spl/sys/mutex.h @@ -27,7 +27,6 @@ #include #include -#include #include typedef enum { diff --git a/include/sys/param.h b/include/spl/sys/param.h similarity index 100% rename from include/sys/param.h rename to include/spl/sys/param.h diff --git a/include/sys/proc.h b/include/spl/sys/proc.h similarity index 89% rename from include/sys/proc.h rename to include/spl/sys/proc.h index 95fc8cc5f..287683920 100644 --- a/include/sys/proc.h +++ b/include/spl/sys/proc.h @@ -25,4 +25,11 @@ #ifndef _SPL_PROC_H #define _SPL_PROC_H +#include + +extern struct proc_dir_entry *proc_spl_kstat; + +int spl_proc_init(void); +void spl_proc_fini(void); + #endif /* SPL_PROC_H */ diff --git a/include/sys/processor.h b/include/spl/sys/processor.h similarity index 100% rename from include/sys/processor.h rename to include/spl/sys/processor.h diff --git a/include/sys/random.h b/include/spl/sys/random.h similarity index 100% rename from include/sys/random.h rename to include/spl/sys/random.h diff --git a/include/sys/rwlock.h b/include/spl/sys/rwlock.h similarity index 78% rename from include/sys/rwlock.h rename to include/spl/sys/rwlock.h index bb8b785e8..b44ceab66 100644 --- a/include/sys/rwlock.h +++ b/include/spl/sys/rwlock.h @@ -27,7 +27,43 @@ #include #include -#include + +/* Linux kernel compatibility */ +#if defined(CONFIG_PREEMPT_RT_FULL) +#define SPL_RWSEM_SINGLE_READER_VALUE (1) +#define SPL_RWSEM_SINGLE_WRITER_VALUE (0) +#elif defined(CONFIG_RWSEM_GENERIC_SPINLOCK) +#define SPL_RWSEM_SINGLE_READER_VALUE (1) +#define SPL_RWSEM_SINGLE_WRITER_VALUE (-1) +#else +#define SPL_RWSEM_SINGLE_READER_VALUE (RWSEM_ACTIVE_READ_BIAS) +#define SPL_RWSEM_SINGLE_WRITER_VALUE (RWSEM_ACTIVE_WRITE_BIAS) +#endif + +/* Linux 3.16 changed activity to count for rwsem-spinlock */ +#if defined(CONFIG_PREEMPT_RT_FULL) +#define RWSEM_COUNT(sem) sem->read_depth +#elif defined(HAVE_RWSEM_ACTIVITY) +#define RWSEM_COUNT(sem) sem->activity +/* Linux 4.8 changed count to an atomic_long_t for !rwsem-spinlock */ +#elif defined(HAVE_RWSEM_ATOMIC_LONG_COUNT) +#define RWSEM_COUNT(sem) atomic_long_read(&(sem)->count) +#else +#define RWSEM_COUNT(sem) sem->count +#endif + +#if defined(RWSEM_SPINLOCK_IS_RAW) +#define spl_rwsem_lock_irqsave(lk, fl) raw_spin_lock_irqsave(lk, fl) +#define spl_rwsem_unlock_irqrestore(lk, fl) \ + raw_spin_unlock_irqrestore(lk, fl) +#define spl_rwsem_trylock_irqsave(lk, fl) raw_spin_trylock_irqsave(lk, fl) +#else +#define spl_rwsem_lock_irqsave(lk, fl) spin_lock_irqsave(lk, fl) +#define spl_rwsem_unlock_irqrestore(lk, fl) spin_unlock_irqrestore(lk, fl) +#define spl_rwsem_trylock_irqsave(lk, fl) spin_trylock_irqsave(lk, fl) +#endif /* RWSEM_SPINLOCK_IS_RAW */ + +#define spl_rwsem_is_locked(rwsem) rwsem_is_locked(rwsem) typedef enum { RW_DRIVER = 2, @@ -232,5 +268,6 @@ RW_LOCK_HELD(krwlock_t *rwp) int spl_rw_init(void); void spl_rw_fini(void); +int rwsem_tryupgrade(struct rw_semaphore *rwsem); #endif /* _SPL_RWLOCK_H */ diff --git a/include/linux/mm_compat.h b/include/spl/sys/shrinker.h similarity index 98% rename from include/linux/mm_compat.h rename to include/spl/sys/shrinker.h index c10652efd..28c1fa78c 100644 --- a/include/linux/mm_compat.h +++ b/include/spl/sys/shrinker.h @@ -22,8 +22,8 @@ * with the SPL. If not, see . */ -#ifndef _SPL_MM_COMPAT_H -#define _SPL_MM_COMPAT_H +#ifndef _SPL_SHRINKER_H +#define _SPL_SHRINKER_H #include #include @@ -206,4 +206,4 @@ typedef int spl_shrinker_t; #define SHRINK_STOP (-1) #endif -#endif /* SPL_MM_COMPAT_H */ +#endif /* SPL_SHRINKER_H */ diff --git a/include/sys/sid.h b/include/spl/sys/sid.h similarity index 100% rename from include/sys/sid.h rename to include/spl/sys/sid.h diff --git a/include/sys/signal.h b/include/spl/sys/signal.h similarity index 100% rename from include/sys/signal.h rename to include/spl/sys/signal.h diff --git a/include/sys/stat.h b/include/spl/sys/stat.h similarity index 100% rename from include/sys/stat.h rename to include/spl/sys/stat.h diff --git a/include/sys/idmap.h b/include/spl/sys/strings.h similarity index 71% rename from include/sys/idmap.h rename to include/spl/sys/strings.h index abbfcbed1..4fb803206 100644 --- a/include/sys/idmap.h +++ b/include/spl/sys/strings.h @@ -1,7 +1,6 @@ /* - * Copyright (C) 2010 Lawrence Livermore National Security, LLC. + * Copyright (C) 2018 Lawrence Livermore National Security, LLC. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . * UCRL-CODE-235197 * * This file is part of the SPL, Solaris Porting Layer. @@ -20,10 +19,13 @@ * You should have received a copy of the GNU General Public License along * with the SPL. If not, see . */ +#ifndef _SPL_SYS_STRINGS_H +#define _SPL_SYS_STRINGS_H -#ifndef _SPL_IDMAP_H -#define _SPL_IDMAP_H +#include -#define IDMAP_WK_CREATOR_OWNER_UID 2147483648U +#define bzero(ptr, size) memset(ptr, 0, size) +#define bcopy(src, dest, size) memmove(dest, src, size) +#define bcmp(src, dest, size) memcmp((src), (dest), (size_t)(size)) -#endif /* SPL_IDMAP_H */ +#endif /* _SPL_SYS_STRINGS_H */ diff --git a/include/sys/sunddi.h b/include/spl/sys/sunddi.h similarity index 98% rename from include/sys/sunddi.h rename to include/spl/sys/sunddi.h index 1bae594c8..29a6fe00d 100644 --- a/include/sys/sunddi.h +++ b/include/spl/sys/sunddi.h @@ -27,7 +27,6 @@ #include #include -#include #include #include #include diff --git a/include/sys/sysmacros.h b/include/spl/sys/sysmacros.h similarity index 91% rename from include/sys/sysmacros.h rename to include/spl/sys/sysmacros.h index d083cebda..839e7fd8c 100644 --- a/include/sys/sysmacros.h +++ b/include/spl/sys/sysmacros.h @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -66,11 +65,10 @@ #define UINT64_MIN ULLONG_MIN #define NBBY 8 -#define ENOTSUP EOPNOTSUPP #define MAXMSGLEN 256 #define MAXNAMELEN 256 -#define MAXPATHLEN PATH_MAX +#define MAXPATHLEN 4096 #define MAXOFFSET_T LLONG_MAX #define MAXBSIZE 8192 #define DEV_BSIZE 512 @@ -117,19 +115,6 @@ #define PAGESHIFT PAGE_SHIFT #endif -/* from Solaris sys/byteorder.h */ -#define BSWAP_8(x) ((x) & 0xff) -#define BSWAP_16(x) ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8)) -#define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16)) -#define BSWAP_64(x) ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32)) - -/* - * Map some simple functions. - */ -#define bzero(ptr, size) memset(ptr, 0, size) -#define bcopy(src, dest, size) memmove(dest, src, size) -#define bcmp(src, dest, size) memcmp((src), (dest), (size_t)(size)) - /* Dtrace probes do not exist in the linux kernel */ #ifdef DTRACE_PROBE #undef DTRACE_PROBE diff --git a/include/sys/systeminfo.h b/include/spl/sys/systeminfo.h similarity index 100% rename from include/sys/systeminfo.h rename to include/spl/sys/systeminfo.h diff --git a/include/sys/taskq.h b/include/spl/sys/taskq.h similarity index 99% rename from include/sys/taskq.h rename to include/spl/sys/taskq.h index 4d90a3563..7353367a2 100644 --- a/include/sys/taskq.h +++ b/include/spl/sys/taskq.h @@ -30,10 +30,10 @@ #include #include #include -#include #include #include #include +#include #define TASKQ_NAMELEN 31 diff --git a/include/sys/thread.h b/include/spl/sys/thread.h similarity index 97% rename from include/sys/thread.h rename to include/spl/sys/thread.h index 80cf49914..3762717da 100644 --- a/include/sys/thread.h +++ b/include/spl/sys/thread.h @@ -62,6 +62,8 @@ extern kthread_t *__thread_create(caddr_t stk, size_t stksize, int state, pri_t pri); extern void __thread_exit(void); extern struct task_struct *spl_kthread_create(int (*func)(void *), - void *data, const char namefmt[], ...); + void *data, const char namefmt[], ...); + +extern proc_t p0; #endif /* _SPL_THREAD_H */ diff --git a/include/sys/time.h b/include/spl/sys/time.h similarity index 100% rename from include/sys/time.h rename to include/spl/sys/time.h diff --git a/include/sys/timer.h b/include/spl/sys/timer.h similarity index 86% rename from include/sys/timer.h rename to include/spl/sys/timer.h index 821590e3a..a6b134570 100644 --- a/include/sys/timer.h +++ b/include/spl/sys/timer.h @@ -26,7 +26,9 @@ #define _SPL_TIMER_H #include +#include #include +#include #include #define lbolt ((clock_t)jiffies) @@ -51,6 +53,20 @@ #define delay(ticks) schedule_timeout_uninterruptible(ticks) +/* usleep_range() introduced in 2.6.36 */ +#ifndef HAVE_USLEEP_RANGE +static inline void +usleep_range(unsigned long min, unsigned long max) +{ + unsigned int min_ms = min / USEC_PER_MSEC; + + if (min >= MAX_UDELAY_MS) + msleep(min_ms); + else + udelay(min); +} +#endif /* HAVE_USLEEP_RANGE */ + #define SEC_TO_TICK(sec) ((sec) * HZ) #define MSEC_TO_TICK(ms) msecs_to_jiffies(ms) #define USEC_TO_TICK(us) usecs_to_jiffies(us) diff --git a/include/sys/tsd.h b/include/spl/sys/tsd.h similarity index 100% rename from include/sys/tsd.h rename to include/spl/sys/tsd.h diff --git a/include/sys/types.h b/include/spl/sys/types.h similarity index 57% rename from include/sys/types.h rename to include/spl/sys/types.h index e159dda21..a5b478127 100644 --- a/include/sys/types.h +++ b/include/spl/sys/types.h @@ -26,7 +26,6 @@ #define _SPL_TYPES_H #include -#include #ifndef ULLONG_MAX #define ULLONG_MAX (~0ULL) @@ -36,33 +35,36 @@ #define LLONG_MAX ((long long)(~0ULL>>1)) #endif -typedef enum { B_FALSE = 0, B_TRUE = 1 } boolean_t; -typedef unsigned long intptr_t; -typedef unsigned long ulong_t; -typedef unsigned int uint_t; -typedef unsigned char uchar_t; -typedef unsigned long long u_longlong_t; -typedef unsigned long long u_offset_t; -typedef unsigned long long rlim64_t; -typedef long long longlong_t; -typedef long long offset_t; -typedef struct task_struct kthread_t; -typedef struct task_struct proc_t; -typedef short pri_t; -typedef struct timespec timestruc_t; /* definition per SVr4 */ -typedef struct timespec timespec_t; -typedef longlong_t hrtime_t; -typedef unsigned short ushort_t; -typedef u_longlong_t len_t; -typedef longlong_t diskaddr_t; -typedef ushort_t o_mode_t; -typedef uint_t major_t; -typedef uint_t minor_t; -typedef ulong_t pgcnt_t; -typedef long spgcnt_t; -typedef short index_t; -typedef int id_t; +typedef enum { + B_FALSE = 0, + B_TRUE = 1 +} boolean_t; -extern proc_t p0; +typedef unsigned char uchar_t; +typedef unsigned short ushort_t; +typedef unsigned int uint_t; +typedef unsigned long ulong_t; +typedef unsigned long long u_longlong_t; +typedef long long longlong_t; + +typedef unsigned long intptr_t; +typedef unsigned long long rlim64_t; + +typedef struct task_struct kthread_t; +typedef struct task_struct proc_t; + +typedef struct timespec timestruc_t; +typedef struct timespec timespec_t; +typedef longlong_t hrtime_t; + +typedef int id_t; +typedef short pri_t; +typedef short index_t; +typedef longlong_t offset_t; +typedef u_longlong_t u_offset_t; +typedef ulong_t pgcnt_t; + +typedef int major_t; +typedef int minor_t; #endif /* _SPL_TYPES_H */ diff --git a/include/sys/types32.h b/include/spl/sys/types32.h similarity index 97% rename from include/sys/types32.h rename to include/spl/sys/types32.h index 1b05b2a47..c60ba8c97 100644 --- a/include/sys/types32.h +++ b/include/spl/sys/types32.h @@ -25,7 +25,6 @@ #ifndef _SPL_TYPES32_H #define _SPL_TYPES32_H -#include #include typedef uint32_t caddr32_t; diff --git a/include/sys/uio.h b/include/spl/sys/uio.h similarity index 100% rename from include/sys/uio.h rename to include/spl/sys/uio.h diff --git a/include/sys/user.h b/include/spl/sys/user.h similarity index 100% rename from include/sys/user.h rename to include/spl/sys/user.h diff --git a/include/sys/vfs.h b/include/spl/sys/vfs.h similarity index 100% rename from include/sys/vfs.h rename to include/spl/sys/vfs.h diff --git a/include/sys/vmem.h b/include/spl/sys/vmem.h similarity index 100% rename from include/sys/vmem.h rename to include/spl/sys/vmem.h diff --git a/include/sys/vmsystm.h b/include/spl/sys/vmsystm.h similarity index 100% rename from include/sys/vmsystm.h rename to include/spl/sys/vmsystm.h diff --git a/include/sys/vnode.h b/include/spl/sys/vnode.h similarity index 99% rename from include/sys/vnode.h rename to include/spl/sys/vnode.h index 946654b7b..a3f7828e7 100644 --- a/include/sys/vnode.h +++ b/include/spl/sys/vnode.h @@ -41,7 +41,6 @@ #include #include #include -#include /* * Prior to linux-2.6.33 only O_DSYNC semantics were implemented and diff --git a/include/linux/wait_compat.h b/include/spl/sys/wait.h similarity index 95% rename from include/linux/wait_compat.h rename to include/spl/sys/wait.h index 10fe2d896..5311ff8b9 100644 --- a/include/linux/wait_compat.h +++ b/include/spl/sys/wait.h @@ -22,8 +22,8 @@ * with the SPL. If not, see . */ -#ifndef _SPL_WAIT_COMPAT_H -#define _SPL_WAIT_COMPAT_H +#ifndef _SPL_WAIT_H +#define _SPL_WAIT_H #include #include @@ -52,4 +52,4 @@ typedef wait_queue_head_t spl_wait_queue_head_t; typedef wait_queue_t spl_wait_queue_entry_t; #endif -#endif /* SPL_WAIT_COMPAT_H */ +#endif /* SPL_WAIT_H */ diff --git a/include/sys/zmod.h b/include/spl/sys/zmod.h similarity index 91% rename from include/sys/zmod.h rename to include/spl/sys/zmod.h index 5380bd6fd..95c1a3ed7 100644 --- a/include/sys/zmod.h +++ b/include/spl/sys/zmod.h @@ -59,6 +59,14 @@ #include #include +#ifdef HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE +#define spl_zlib_deflate_workspacesize(wb, ml) \ + zlib_deflate_workspacesize(wb, ml) +#else +#define spl_zlib_deflate_workspacesize(wb, ml) \ + zlib_deflate_workspacesize() +#endif /* HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE */ + extern int z_compress_level(void *dest, size_t *destLen, const void *source, size_t sourceLen, int level); extern int z_uncompress(void *dest, size_t *destLen, const void *source, diff --git a/include/sys/zone.h b/include/spl/sys/zone.h similarity index 100% rename from include/sys/zone.h rename to include/spl/sys/zone.h diff --git a/include/splat-ctl.h b/include/splat-ctl.h deleted file mode 100644 index 0f020dc24..000000000 --- a/include/splat-ctl.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPLAT_CTL_H -#define _SPLAT_CTL_H - -#include - -/* - * Contains shared definitions for both user space and kernel space. To - * ensure 32-bit/64-bit interoperability over ioctl()'s only types with - * fixed sizes can be used. - */ -#define SPLAT_NAME "splatctl" -#define SPLAT_DEV "/dev/splatctl" - -#define SPLAT_NAME_SIZE 20 -#define SPLAT_DESC_SIZE 60 - -typedef struct splat_user { - char name[SPLAT_NAME_SIZE]; /* Short name */ - char desc[SPLAT_DESC_SIZE]; /* Short description */ - __u32 id; /* Unique numeric id */ -} splat_user_t; - -#define SPLAT_CFG_MAGIC 0x15263748U -typedef struct splat_cfg { - __u32 cfg_magic; /* Unique magic */ - __u32 cfg_cmd; /* Configure command */ - __s32 cfg_arg1; /* Configure command arg 1 */ - __s32 cfg_rc1; /* Configure response 1 */ - union { - struct { - __u32 size; - splat_user_t descs[0]; - } splat_subsystems; - struct { - __u32 size; - splat_user_t descs[0]; - } splat_tests; - } cfg_data; -} splat_cfg_t; - -#define SPLAT_CMD_MAGIC 0x9daebfc0U -typedef struct splat_cmd { - __u32 cmd_magic; /* Unique magic */ - __u32 cmd_subsystem; /* Target subsystem */ - __u32 cmd_test; /* Subsystem test */ - __u32 cmd_data_size; /* Opaque data size */ - char cmd_data_str[0]; /* Opaque data region */ -} splat_cmd_t; - -/* Valid ioctls */ -#define SPLAT_CFG _IOWR('f', 101, splat_cfg_t) -#define SPLAT_CMD _IOWR('f', 102, splat_cmd_t) - -/* Valid configuration commands */ -#define SPLAT_CFG_BUFFER_CLEAR 0x001 /* Clear text buffer */ -#define SPLAT_CFG_BUFFER_SIZE 0x002 /* Resize text buffer */ -#define SPLAT_CFG_SUBSYSTEM_COUNT 0x101 /* Number of subsystem */ -#define SPLAT_CFG_SUBSYSTEM_LIST 0x102 /* List of N subsystems */ -#define SPLAT_CFG_TEST_COUNT 0x201 /* Number of tests */ -#define SPLAT_CFG_TEST_LIST 0x202 /* List of N tests */ - -/* - * Valid subsystem and test commands are defined in each subsystem as - * SPLAT_SUBSYSTEM_*. We do need to be careful to avoid collisions, the - * currently defined subsystems are as follows: - */ -#define SPLAT_SUBSYSTEM_KMEM 0x0100 -#define SPLAT_SUBSYSTEM_TASKQ 0x0200 -#define SPLAT_SUBSYSTEM_KRNG 0x0300 -#define SPLAT_SUBSYSTEM_MUTEX 0x0400 -#define SPLAT_SUBSYSTEM_CONDVAR 0x0500 -#define SPLAT_SUBSYSTEM_THREAD 0x0600 -#define SPLAT_SUBSYSTEM_RWLOCK 0x0700 -#define SPLAT_SUBSYSTEM_TIME 0x0800 -#define SPLAT_SUBSYSTEM_VNODE 0x0900 -#define SPLAT_SUBSYSTEM_KOBJ 0x0a00 -#define SPLAT_SUBSYSTEM_ATOMIC 0x0b00 -#define SPLAT_SUBSYSTEM_LIST 0x0c00 -#define SPLAT_SUBSYSTEM_GENERIC 0x0d00 -#define SPLAT_SUBSYSTEM_CRED 0x0e00 -#define SPLAT_SUBSYSTEM_ZLIB 0x0f00 -#define SPLAT_SUBSYSTEM_LINUX 0x1000 -#define SPLAT_SUBSYSTEM_UNKNOWN 0xff00 - -#endif /* _SPLAT_CTL_H */ diff --git a/include/strings.h b/include/strings.h deleted file mode 100644 index 18179c79e..000000000 --- a/include/strings.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_STRINGS_H -#define _SPL_STRINGS_H - -#endif /* SPL_STRINGS_H */ diff --git a/include/sys/Makefile.am b/include/sys/Makefile.am deleted file mode 100644 index 45b658976..000000000 --- a/include/sys/Makefile.am +++ /dev/null @@ -1,113 +0,0 @@ -SUBDIRS = fm fs - -COMMON_H = - -KERNEL_H = \ - $(top_srcdir)/include/sys/acl.h \ - $(top_srcdir)/include/sys/acl_impl.h \ - $(top_srcdir)/include/sys/atomic.h \ - $(top_srcdir)/include/sys/attr.h \ - $(top_srcdir)/include/sys/bitmap.h \ - $(top_srcdir)/include/sys/bootconf.h \ - $(top_srcdir)/include/sys/bootprops.h \ - $(top_srcdir)/include/sys/buf.h \ - $(top_srcdir)/include/sys/byteorder.h \ - $(top_srcdir)/include/sys/callb.h \ - $(top_srcdir)/include/sys/callo.h \ - $(top_srcdir)/include/sys/cmn_err.h \ - $(top_srcdir)/include/sys/compress.h \ - $(top_srcdir)/include/sys/condvar.h \ - $(top_srcdir)/include/sys/conf.h \ - $(top_srcdir)/include/sys/console.h \ - $(top_srcdir)/include/sys/cpupart.h \ - $(top_srcdir)/include/sys/cpuvar.h \ - $(top_srcdir)/include/sys/crc32.h \ - $(top_srcdir)/include/sys/cred.h \ - $(top_srcdir)/include/sys/ctype.h \ - $(top_srcdir)/include/sys/ddi.h \ - $(top_srcdir)/include/sys/debug.h \ - $(top_srcdir)/include/sys/dirent.h \ - $(top_srcdir)/include/sys/disp.h \ - $(top_srcdir)/include/sys/dkio.h \ - $(top_srcdir)/include/sys/dkioc_free_util.h \ - $(top_srcdir)/include/sys/dklabel.h \ - $(top_srcdir)/include/sys/dnlc.h \ - $(top_srcdir)/include/sys/dumphdr.h \ - $(top_srcdir)/include/sys/efi_partition.h \ - $(top_srcdir)/include/sys/errno.h \ - $(top_srcdir)/include/sys/extdirent.h \ - $(top_srcdir)/include/sys/fcntl.h \ - $(top_srcdir)/include/sys/file.h \ - $(top_srcdir)/include/sys/idmap.h \ - $(top_srcdir)/include/sys/int_limits.h \ - $(top_srcdir)/include/sys/int_types.h \ - $(top_srcdir)/include/sys/inttypes.h \ - $(top_srcdir)/include/sys/isa_defs.h \ - $(top_srcdir)/include/sys/kidmap.h \ - $(top_srcdir)/include/sys/kmem.h \ - $(top_srcdir)/include/sys/kmem_cache.h \ - $(top_srcdir)/include/sys/kobj.h \ - $(top_srcdir)/include/sys/kstat.h \ - $(top_srcdir)/include/sys/list.h \ - $(top_srcdir)/include/sys/mkdev.h \ - $(top_srcdir)/include/sys/mntent.h \ - $(top_srcdir)/include/sys/modctl.h \ - $(top_srcdir)/include/sys/mode.h \ - $(top_srcdir)/include/sys/mount.h \ - $(top_srcdir)/include/sys/mutex.h \ - $(top_srcdir)/include/sys/note.h \ - $(top_srcdir)/include/sys/open.h \ - $(top_srcdir)/include/sys/param.h \ - $(top_srcdir)/include/sys/pathname.h \ - $(top_srcdir)/include/sys/policy.h \ - $(top_srcdir)/include/sys/pool.h \ - $(top_srcdir)/include/sys/priv_impl.h \ - $(top_srcdir)/include/sys/processor.h \ - $(top_srcdir)/include/sys/proc.h \ - $(top_srcdir)/include/sys/pset.h \ - $(top_srcdir)/include/sys/random.h \ - $(top_srcdir)/include/sys/refstr.h \ - $(top_srcdir)/include/sys/resource.h \ - $(top_srcdir)/include/sys/rwlock.h \ - $(top_srcdir)/include/sys/sdt.h \ - $(top_srcdir)/include/sys/sid.h \ - $(top_srcdir)/include/sys/signal.h \ - $(top_srcdir)/include/sys/stat.h \ - $(top_srcdir)/include/sys/stropts.h \ - $(top_srcdir)/include/sys/sunddi.h \ - $(top_srcdir)/include/sys/sunldi.h \ - $(top_srcdir)/include/sys/sysdc.h \ - $(top_srcdir)/include/sys/sysmacros.h \ - $(top_srcdir)/include/sys/systeminfo.h \ - $(top_srcdir)/include/sys/systm.h \ - $(top_srcdir)/include/sys/taskq.h \ - $(top_srcdir)/include/sys/thread.h \ - $(top_srcdir)/include/sys/time.h \ - $(top_srcdir)/include/sys/timer.h \ - $(top_srcdir)/include/sys/t_lock.h \ - $(top_srcdir)/include/sys/tsd.h \ - $(top_srcdir)/include/sys/types32.h \ - $(top_srcdir)/include/sys/types.h \ - $(top_srcdir)/include/sys/u8_textprep.h \ - $(top_srcdir)/include/sys/uio.h \ - $(top_srcdir)/include/sys/unistd.h \ - $(top_srcdir)/include/sys/user.h \ - $(top_srcdir)/include/sys/va_list.h \ - $(top_srcdir)/include/sys/varargs.h \ - $(top_srcdir)/include/sys/vfs.h \ - $(top_srcdir)/include/sys/vfs_opreg.h \ - $(top_srcdir)/include/sys/vmem.h \ - $(top_srcdir)/include/sys/vmsystm.h \ - $(top_srcdir)/include/sys/vnode.h \ - $(top_srcdir)/include/sys/zmod.h \ - $(top_srcdir)/include/sys/zone.h - -USER_H = - -EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H) - -if CONFIG_KERNEL -kerneldir = @prefix@/src/spl-$(VERSION)/include/sys -kernel_HEADERS = $(KERNEL_H) -endif - diff --git a/include/sys/acl_impl.h b/include/sys/acl_impl.h deleted file mode 100644 index 9cb21124b..000000000 --- a/include/sys/acl_impl.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_ACL_IMPL_H -#define _SPL_ACL_IMPL_H - -#endif /* _SPL_ACL_IMPL_H */ diff --git a/include/sys/atomic.h b/include/sys/atomic.h deleted file mode 100644 index e992fdce3..000000000 --- a/include/sys/atomic.h +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_ATOMIC_H -#define _SPL_ATOMIC_H - -#include -#include -#include - -/* - * Two approaches to atomic operations are implemented each with its - * own benefits are drawbacks imposed by the Solaris API. Neither - * approach handles the issue of word breaking when using a 64-bit - * atomic variable on a 32-bit arch. The Solaris API would need to - * add an atomic read call to correctly support this. - * - * When ATOMIC_SPINLOCK is defined all atomic operations will be - * serialized through global spin locks. This is bad for performance - * but it does allow a simple generic implementation. - * - * When ATOMIC_SPINLOCK is not defined the Linux atomic operations - * are used. This is safe as long as the core Linux implementation - * doesn't change because we are relying on the fact that an atomic - * type is really just a uint32 or uint64. If this changes at some - * point in the future we need to fall-back to the spin approach. - */ -#ifdef ATOMIC_SPINLOCK -extern spinlock_t atomic32_lock; -extern spinlock_t atomic64_lock; - -static __inline__ void -atomic_inc_32(volatile uint32_t *target) -{ - spin_lock(&atomic32_lock); - (*target)++; - spin_unlock(&atomic32_lock); -} - -static __inline__ void -atomic_dec_32(volatile uint32_t *target) -{ - spin_lock(&atomic32_lock); - (*target)--; - spin_unlock(&atomic32_lock); -} - -static __inline__ void -atomic_add_32(volatile uint32_t *target, int32_t delta) -{ - spin_lock(&atomic32_lock); - *target += delta; - spin_unlock(&atomic32_lock); -} - -static __inline__ void -atomic_sub_32(volatile uint32_t *target, int32_t delta) -{ - spin_lock(&atomic32_lock); - *target -= delta; - spin_unlock(&atomic32_lock); -} - -static __inline__ uint32_t -atomic_inc_32_nv(volatile uint32_t *target) -{ - uint32_t nv; - - spin_lock(&atomic32_lock); - nv = ++(*target); - spin_unlock(&atomic32_lock); - - return (nv); -} - -static __inline__ uint32_t -atomic_dec_32_nv(volatile uint32_t *target) -{ - uint32_t nv; - - spin_lock(&atomic32_lock); - nv = --(*target); - spin_unlock(&atomic32_lock); - - return (nv); -} - -static __inline__ uint32_t -atomic_add_32_nv(volatile uint32_t *target, uint32_t delta) -{ - uint32_t nv; - - spin_lock(&atomic32_lock); - *target += delta; - nv = *target; - spin_unlock(&atomic32_lock); - - return (nv); -} - -static __inline__ uint32_t -atomic_sub_32_nv(volatile uint32_t *target, uint32_t delta) -{ - uint32_t nv; - - spin_lock(&atomic32_lock); - *target -= delta; - nv = *target; - spin_unlock(&atomic32_lock); - - return (nv); -} - -static __inline__ uint32_t -atomic_cas_32(volatile uint32_t *target, uint32_t cmp, uint32_t newval) -{ - uint32_t rc; - - spin_lock(&atomic32_lock); - rc = *target; - if (*target == cmp) - *target = newval; - - spin_unlock(&atomic32_lock); - - return (rc); -} - -static __inline__ uint32_t -atomic_swap_32(volatile uint32_t *target, uint32_t newval) -{ - uint32_t rc; - - spin_lock(&atomic32_lock); - rc = *target; - *target = newval; - spin_unlock(&atomic32_lock); - - return (rc); -} - -static __inline__ void -atomic_inc_64(volatile uint64_t *target) -{ - spin_lock(&atomic64_lock); - (*target)++; - spin_unlock(&atomic64_lock); -} - -static __inline__ void -atomic_dec_64(volatile uint64_t *target) -{ - spin_lock(&atomic64_lock); - (*target)--; - spin_unlock(&atomic64_lock); -} - -static __inline__ void -atomic_add_64(volatile uint64_t *target, uint64_t delta) -{ - spin_lock(&atomic64_lock); - *target += delta; - spin_unlock(&atomic64_lock); -} - -static __inline__ void -atomic_sub_64(volatile uint64_t *target, uint64_t delta) -{ - spin_lock(&atomic64_lock); - *target -= delta; - spin_unlock(&atomic64_lock); -} - -static __inline__ uint64_t -atomic_inc_64_nv(volatile uint64_t *target) -{ - uint64_t nv; - - spin_lock(&atomic64_lock); - nv = ++(*target); - spin_unlock(&atomic64_lock); - - return (nv); -} - -static __inline__ uint64_t -atomic_dec_64_nv(volatile uint64_t *target) -{ - uint64_t nv; - - spin_lock(&atomic64_lock); - nv = --(*target); - spin_unlock(&atomic64_lock); - - return (nv); -} - -static __inline__ uint64_t -atomic_add_64_nv(volatile uint64_t *target, uint64_t delta) -{ - uint64_t nv; - - spin_lock(&atomic64_lock); - *target += delta; - nv = *target; - spin_unlock(&atomic64_lock); - - return (nv); -} - -static __inline__ uint64_t -atomic_sub_64_nv(volatile uint64_t *target, uint64_t delta) -{ - uint64_t nv; - - spin_lock(&atomic64_lock); - *target -= delta; - nv = *target; - spin_unlock(&atomic64_lock); - - return (nv); -} - -static __inline__ uint64_t -atomic_cas_64(volatile uint64_t *target, uint64_t cmp, uint64_t newval) -{ - uint64_t rc; - - spin_lock(&atomic64_lock); - rc = *target; - if (*target == cmp) - *target = newval; - spin_unlock(&atomic64_lock); - - return (rc); -} - -static __inline__ uint64_t -atomic_swap_64(volatile uint64_t *target, uint64_t newval) -{ - uint64_t rc; - - spin_lock(&atomic64_lock); - rc = *target; - *target = newval; - spin_unlock(&atomic64_lock); - - return (rc); -} - -#else /* ATOMIC_SPINLOCK */ - -#define atomic_inc_32(v) atomic_inc((atomic_t *)(v)) -#define atomic_dec_32(v) atomic_dec((atomic_t *)(v)) -#define atomic_add_32(v, i) atomic_add((i), (atomic_t *)(v)) -#define atomic_sub_32(v, i) atomic_sub((i), (atomic_t *)(v)) -#define atomic_inc_32_nv(v) atomic_inc_return((atomic_t *)(v)) -#define atomic_dec_32_nv(v) atomic_dec_return((atomic_t *)(v)) -#define atomic_add_32_nv(v, i) atomic_add_return((i), (atomic_t *)(v)) -#define atomic_sub_32_nv(v, i) atomic_sub_return((i), (atomic_t *)(v)) -#define atomic_cas_32(v, x, y) atomic_cmpxchg((atomic_t *)(v), x, y) -#define atomic_swap_32(v, x) atomic_xchg((atomic_t *)(v), x) -#define atomic_inc_64(v) atomic64_inc((atomic64_t *)(v)) -#define atomic_dec_64(v) atomic64_dec((atomic64_t *)(v)) -#define atomic_add_64(v, i) atomic64_add((i), (atomic64_t *)(v)) -#define atomic_sub_64(v, i) atomic64_sub((i), (atomic64_t *)(v)) -#define atomic_inc_64_nv(v) atomic64_inc_return((atomic64_t *)(v)) -#define atomic_dec_64_nv(v) atomic64_dec_return((atomic64_t *)(v)) -#define atomic_add_64_nv(v, i) atomic64_add_return((i), (atomic64_t *)(v)) -#define atomic_sub_64_nv(v, i) atomic64_sub_return((i), (atomic64_t *)(v)) -#define atomic_cas_64(v, x, y) atomic64_cmpxchg((atomic64_t *)(v), x, y) -#define atomic_swap_64(v, x) atomic64_xchg((atomic64_t *)(v), x) - -#endif /* ATOMIC_SPINLOCK */ - -#ifdef _LP64 -static __inline__ void * -atomic_cas_ptr(volatile void *target, void *cmp, void *newval) -{ - return ((void *)atomic_cas_64((volatile uint64_t *)target, - (uint64_t)cmp, (uint64_t)newval)); -} -#else /* _LP64 */ -static __inline__ void * -atomic_cas_ptr(volatile void *target, void *cmp, void *newval) -{ - return ((void *)atomic_cas_32((volatile uint32_t *)target, - (uint32_t)cmp, (uint32_t)newval)); -} -#endif /* _LP64 */ - -#endif /* _SPL_ATOMIC_H */ diff --git a/include/sys/attr.h b/include/sys/attr.h deleted file mode 100644 index 7941acbec..000000000 --- a/include/sys/attr.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_ATTR_H -#define _SPL_ATTR_H - -#endif /* SPL_ATTR_H */ diff --git a/include/sys/bitmap.h b/include/sys/bitmap.h deleted file mode 100644 index 3e7d910c0..000000000 --- a/include/sys/bitmap.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_BITMAP_H -#define _SPL_BITMAP_H - -#endif /* SPL_BITMAP_H */ diff --git a/include/sys/bootconf.h b/include/sys/bootconf.h deleted file mode 100644 index 62730ba5d..000000000 --- a/include/sys/bootconf.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_BOOTCONF_H -#define _SPL_BOOTCONF_H - -#endif /* SPL_BOOTCONF_H */ diff --git a/include/sys/bootprops.h b/include/sys/bootprops.h deleted file mode 100644 index 50150eda9..000000000 --- a/include/sys/bootprops.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_BOOTPROPS_H -#define _SPL_BOOTPROPS_H - -#endif /* SPL_BOOTPROPS_H */ diff --git a/include/sys/buf.h b/include/sys/buf.h deleted file mode 100644 index fa453e478..000000000 --- a/include/sys/buf.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_BUF_H -#define _SPL_BUF_H - -#endif /* SPL_BUF_H */ diff --git a/include/sys/compress.h b/include/sys/compress.h deleted file mode 100644 index e46ab0df2..000000000 --- a/include/sys/compress.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_COMPRESS_H -#define _SPL_COMPRESS_H - -#endif /* SPL_COMPRESS_H */ diff --git a/include/sys/conf.h b/include/sys/conf.h deleted file mode 100644 index 68f4095dd..000000000 --- a/include/sys/conf.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_CONF_H -#define _SPL_CONF_H - -#endif /* SPL_CONF_H */ diff --git a/include/sys/cpupart.h b/include/sys/cpupart.h deleted file mode 100644 index ba57c19e8..000000000 --- a/include/sys/cpupart.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_CPUPART_H -#define _SPL_CPUPART_H - -#endif /* SPL_CPUPART_H */ diff --git a/include/sys/cpuvar.h b/include/sys/cpuvar.h deleted file mode 100644 index 075c06047..000000000 --- a/include/sys/cpuvar.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_CPUVAR_H -#define _SPL_CPUVAR_H - -#endif /* SPL_CPUVAR_H */ diff --git a/include/sys/crc32.h b/include/sys/crc32.h deleted file mode 100644 index eb021b1ff..000000000 --- a/include/sys/crc32.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_CRC32_H -#define _SPL_CRC32_H - -#endif /* SPL_CRC32_H */ diff --git a/include/sys/ddi.h b/include/sys/ddi.h deleted file mode 100644 index af2806ee7..000000000 --- a/include/sys/ddi.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_DDI_H -#define _SPL_DDI_H - -#endif /* SPL_DDI_H */ diff --git a/include/sys/dirent.h b/include/sys/dirent.h deleted file mode 100644 index 8237d0dd9..000000000 --- a/include/sys/dirent.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_DIRENT_H -#define _SPL_DIRENT_H - -#endif /* SPL_DIRENT_H */ diff --git a/include/sys/dklabel.h b/include/sys/dklabel.h deleted file mode 100644 index ff58059c6..000000000 --- a/include/sys/dklabel.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_DKLABEL_H -#define _SPL_DKLABEL_H - -#endif /* _SPL_DKLABEL_H */ diff --git a/include/sys/dnlc.h b/include/sys/dnlc.h deleted file mode 100644 index cda112c18..000000000 --- a/include/sys/dnlc.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_DNLC_H -#define _SPL_DNLC_H - -#endif /* SPL_DNLC_H */ diff --git a/include/sys/dumphdr.h b/include/sys/dumphdr.h deleted file mode 100644 index a452fe35d..000000000 --- a/include/sys/dumphdr.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_DUMPHDR_H -#define _SPL_DUMPHDR_H - -#endif /* SPL_DUMPHDR_H */ diff --git a/include/sys/efi_partition.h b/include/sys/efi_partition.h deleted file mode 100644 index d0c9c2005..000000000 --- a/include/sys/efi_partition.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_EFI_PARTITION_H -#define _SPL_EFI_PARTITION_H - -#endif /* SPL_EFI_PARTITION_H */ diff --git a/include/sys/errno.h b/include/sys/errno.h deleted file mode 100644 index 2dd378bc8..000000000 --- a/include/sys/errno.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_ERRNO_H -#define _SPL_ERRNO_H - -#endif /* SPL_ERRNO_H */ diff --git a/include/sys/extdirent.h b/include/sys/extdirent.h deleted file mode 100644 index e0567fa6e..000000000 --- a/include/sys/extdirent.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2010 Lawrence Livermore National Security, LLC. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_EXTDIRENT_H -#define _SPL_EXTDIRENT_H - -#define ED_CASE_CONFLICT 0x10 - -#endif /* _SPL_EXTDIRENT_H */ diff --git a/include/sys/fm/Makefile.am b/include/sys/fm/Makefile.am deleted file mode 100644 index 2821cbe33..000000000 --- a/include/sys/fm/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -COMMON_H = - -KERNEL_H = \ - $(top_srcdir)/include/sys/fm/protocol.h \ - $(top_srcdir)/include/sys/fm/util.h - -USER_H = - -EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H) - -if CONFIG_KERNEL -kerneldir = @prefix@/src/spl-$(VERSION)/include/sys/fm -kernel_HEADERS = $(KERNEL_H) -endif diff --git a/include/sys/fm/protocol.h b/include/sys/fm/protocol.h deleted file mode 100644 index 39f6cb1e5..000000000 --- a/include/sys/fm/protocol.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_FM_PROTOCOL_H -#define _SPL_FM_PROTOCOL_H - -#endif /* _SPL_FM_PROTOCOL_H */ diff --git a/include/sys/fm/util.h b/include/sys/fm/util.h deleted file mode 100644 index d8f68433d..000000000 --- a/include/sys/fm/util.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_FM_UTIL_H -#define _SPL_FM_UTIL_H - -#endif /* _SPL_FM_UTIL_H */ diff --git a/include/sys/fs/Makefile.am b/include/sys/fs/Makefile.am deleted file mode 100644 index 581083e9c..000000000 --- a/include/sys/fs/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -COMMON_H = - -KERNEL_H = \ - $(top_srcdir)/include/sys/fs/swapnode.h - -USER_H = - -EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H) - -if CONFIG_KERNEL -kerneldir = @prefix@/src/spl-$(VERSION)/include/sys/fs -kernel_HEADERS = $(KERNEL_H) -endif diff --git a/include/sys/fs/swapnode.h b/include/sys/fs/swapnode.h deleted file mode 100644 index 1fa5fdc83..000000000 --- a/include/sys/fs/swapnode.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_SWAPNODE_H -#define _SPL_SWAPNODE_H - -#endif /* SPL_SWAPNODE_H */ diff --git a/include/sys/int_limits.h b/include/sys/int_limits.h deleted file mode 100644 index 5d7e9be89..000000000 --- a/include/sys/int_limits.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_INT_LIMITS_H -#define _SPL_INT_LIMITS_H - -#endif /* SPL_INT_LIMITS_H */ diff --git a/include/sys/int_types.h b/include/sys/int_types.h deleted file mode 100644 index 7e3b7329f..000000000 --- a/include/sys/int_types.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_INT_TYPES_H -#define _SPL_INT_TYPES_H - -#include - -#endif /* SPL_INT_TYPES_H */ diff --git a/include/sys/kidmap.h b/include/sys/kidmap.h deleted file mode 100644 index a5e6375c3..000000000 --- a/include/sys/kidmap.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_KIDMAP_H -#define _SPL_KIDMAP_H - -#include - -#endif /* SPL_KIDMAP_H */ diff --git a/include/sys/mkdev.h b/include/sys/mkdev.h deleted file mode 100644 index 7dff2d22d..000000000 --- a/include/sys/mkdev.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_MKDEV_H -#define _SPL_MKDEV_H - -#endif /* SPL_MKDEV_H */ diff --git a/include/sys/mntent.h b/include/sys/mntent.h deleted file mode 100644 index cac28c530..000000000 --- a/include/sys/mntent.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_MNTENT_H -#define _SPL_MNTENT_H - -#endif /* SPL_MNTENT_H */ diff --git a/include/sys/modctl.h b/include/sys/modctl.h deleted file mode 100644 index 8f9ae496d..000000000 --- a/include/sys/modctl.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_MODCTL_H -#define _SPL_MODCTL_H - -#endif /* SPL_MODCTL_H */ diff --git a/include/sys/mount.h b/include/sys/mount.h deleted file mode 100644 index fdd1c6678..000000000 --- a/include/sys/mount.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_MOUNT_H -#define _SPL_MOUNT_H - -#endif /* SPL_MOUNT_H */ diff --git a/include/sys/note.h b/include/sys/note.h deleted file mode 100644 index f7f9b70ef..000000000 --- a/include/sys/note.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_NOTE_H -#define _SPL_NOTE_H - -#endif /* SPL_NOTE_H */ diff --git a/include/sys/open.h b/include/sys/open.h deleted file mode 100644 index 7c9e0cb7a..000000000 --- a/include/sys/open.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_OPEN_H -#define _SPL_OPEN_H - -#endif /* SPL_OPEN_H */ diff --git a/include/sys/pathname.h b/include/sys/pathname.h deleted file mode 100644 index fde1b3c1e..000000000 --- a/include/sys/pathname.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_PATHNAME_H -#define _SPL_PATHNAME_H - -typedef struct pathname { - char *pn_buf; /* underlying storage */ - char *pn_path; /* remaining pathname */ - size_t pn_pathlen; /* remaining length */ - size_t pn_bufsize; /* total size of pn_buf */ -} pathname_t; - -#endif /* SPL_PATHNAME_H */ diff --git a/include/sys/policy.h b/include/sys/policy.h deleted file mode 100644 index e4333cfcf..000000000 --- a/include/sys/policy.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_POLICY_H -#define _SPL_POLICY_H - -#define secpolicy_fs_unmount(c, vfs) (0) -#define secpolicy_nfs(c) (0) -#define secpolicy_sys_config(c, co) (0) -#define secpolicy_zfs(c) (0) -#define secpolicy_zinject(c) (0) -#define secpolicy_vnode_setids_setgids(c, id) (0) -#define secpolicy_vnode_setid_retain(c, sr) (0) -#define secpolicy_setid_clear(v, c) (0) -#define secpolicy_vnode_any_access(c, vp, o) (0) -#define secpolicy_vnode_access2(c, cp, o, m1, m2) (0) -#define secpolicy_vnode_chown(c, o) (0) -#define secpolicy_vnode_setdac(c, o) (0) -#define secpolicy_vnode_remove(c) (0) -#define secpolicy_vnode_setattr(c, v, a, o, f, func, n) (0) -#define secpolicy_xvattr(x, o, c, t) (0) -#define secpolicy_vnode_stky_modify(c) (0) -#define secpolicy_setid_setsticky_clear(v, a, o, c) (0) -#define secpolicy_basic_link(c) (0) - -#endif /* SPL_POLICY_H */ diff --git a/include/sys/pool.h b/include/sys/pool.h deleted file mode 100644 index 392c14b5e..000000000 --- a/include/sys/pool.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_POOL_H -#define _SPL_POOL_H - -#include - -#endif /* SPL_POOL_H */ diff --git a/include/sys/priv_impl.h b/include/sys/priv_impl.h deleted file mode 100644 index 822c2dec1..000000000 --- a/include/sys/priv_impl.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_PRIV_IMPL_H -#define _SPL_PRIV_IMPL_H - -#endif /* _SPL_PRIV_IMPL_H */ diff --git a/include/sys/pset.h b/include/sys/pset.h deleted file mode 100644 index a6a9d343b..000000000 --- a/include/sys/pset.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_PSET_H -#define _SPL_PSET_H - -typedef int psetid_t; - -/* special processor set id's */ -#define PS_NONE -1 -#define PS_QUERY -2 -#define PS_MYID -3 -#define PS_SOFT -4 -#define PS_HARD -5 -#define PS_QUERY_TYPE -6 - -#endif /* SPL_PSET_H */ diff --git a/include/sys/refstr.h b/include/sys/refstr.h deleted file mode 100644 index 1b54dab45..000000000 --- a/include/sys/refstr.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_REFSTR_H -#define _SPL_REFSTR_H - -#endif /* SPL_REFSTR_H */ diff --git a/include/sys/resource.h b/include/sys/resource.h deleted file mode 100644 index d1ffb6c2d..000000000 --- a/include/sys/resource.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_RESOURCE_H -#define _SPL_RESOURCE_H - -#include - -#endif /* SPL_RESOURCE_H */ diff --git a/include/sys/sdt.h b/include/sys/sdt.h deleted file mode 100644 index 2d4679d65..000000000 --- a/include/sys/sdt.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_SDT_H -#define _SPL_SDT_H - -#define SET_ERROR(x) (x) - -#endif /* SPL_SDT_H */ diff --git a/include/sys/stropts.h b/include/sys/stropts.h deleted file mode 100644 index 746141fe8..000000000 --- a/include/sys/stropts.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_STROPTS_H -#define _SPL_STROPTS_H - -#endif /* SPL_STROPTS_H */ diff --git a/include/sys/sunldi.h b/include/sys/sunldi.h deleted file mode 100644 index a5045f891..000000000 --- a/include/sys/sunldi.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_SUNLDI_H -#define _SPL_SUNLDI_H - -#include -#include -#include -#include -#include -#include - -/* - * SECTOR_SIZE can be defined in blkdev.h. See - * https://github.com/torvalds/linux/commit/233bde21. - */ -#ifndef SECTOR_SIZE -#define SECTOR_SIZE 512 -#endif - -#endif /* SPL_SUNLDI_H */ diff --git a/include/sys/sysdc.h b/include/sys/sysdc.h deleted file mode 100644 index d963774ac..000000000 --- a/include/sys/sysdc.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_SYSDC_H -#define _SPL_SYSDC_H - -#endif /* SPL_SYSDC_H */ diff --git a/include/sys/systm.h b/include/sys/systm.h deleted file mode 100644 index 2420e7e9d..000000000 --- a/include/sys/systm.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_SYSTM_H -#define _SPL_SYSTM_H - -#include - -typedef uintptr_t pc_t; - -#endif /* SPL_SYSTM_H */ diff --git a/include/sys/t_lock.h b/include/sys/t_lock.h deleted file mode 100644 index dcdfaeec5..000000000 --- a/include/sys/t_lock.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_T_LOCK_H -#define _SPL_T_LOCK_H - -#include -#include -#include -#include - -#endif /* SPL_T_LOCK_H */ diff --git a/include/sys/u8_textprep.h b/include/sys/u8_textprep.h deleted file mode 100644 index 6e76651d5..000000000 --- a/include/sys/u8_textprep.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_U8_TEXTPREP_H -#define _SPL_U8_TEXTPREP_H - -#endif /* SPL_U8_TEXTPREP_H */ diff --git a/include/sys/unistd.h b/include/sys/unistd.h deleted file mode 100644 index d86de891c..000000000 --- a/include/sys/unistd.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_UNISTD_H -#define _SPL_UNISTD_H - -#endif /* SPL_UNISTD_H */ diff --git a/include/sys/va_list.h b/include/sys/va_list.h deleted file mode 100644 index 62d18b9ae..000000000 --- a/include/sys/va_list.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_VA_LIST_H -#define _SPL_VA_LIST_H - -#endif /* SPL_VA_LIST_H */ diff --git a/include/sys/varargs.h b/include/sys/varargs.h deleted file mode 100644 index cdb73fbbd..000000000 --- a/include/sys/varargs.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_VARARGS_H -#define _SPL_VARARGS_H - -#define __va_list va_list - -#endif /* SPL_VARARGS_H */ diff --git a/include/sys/vfs_opreg.h b/include/sys/vfs_opreg.h deleted file mode 100644 index 1d48f2d5a..000000000 --- a/include/sys/vfs_opreg.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_OPREG_H -#define _SPL_OPREG_H - -#endif /* SPL_OPREG_H */ diff --git a/include/unistd.h b/include/unistd.h deleted file mode 100644 index d86de891c..000000000 --- a/include/unistd.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_UNISTD_H -#define _SPL_UNISTD_H - -#endif /* SPL_UNISTD_H */ diff --git a/include/util/Makefile.am b/include/util/Makefile.am deleted file mode 100644 index e2bf09fb1..000000000 --- a/include/util/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -COMMON_H = - -KERNEL_H = \ - $(top_srcdir)/include/util/qsort.h \ - $(top_srcdir)/include/util/sscanf.h - -USER_H = - -EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H) - -if CONFIG_KERNEL -kerneldir = @prefix@/src/spl-$(VERSION)/include/util -kernel_HEADERS = $(KERNEL_H) -endif diff --git a/include/util/qsort.h b/include/util/qsort.h deleted file mode 100644 index 90ae6e4c2..000000000 --- a/include/util/qsort.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_QSORT_H -#define _SPL_QSORT_H - -#include - -#define qsort(base, num, size, cmp) sort(base, num, size, cmp, NULL) - -#endif /* SPL_QSORT_H */ diff --git a/include/util/sscanf.h b/include/util/sscanf.h deleted file mode 100644 index 9788234bb..000000000 --- a/include/util/sscanf.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_UTIL_SSCANF_H -#define _SPL_UTIL_SSCANF_H - -#endif /* SPL_UTIL_SSCAN_H */ diff --git a/include/vm/Makefile.am b/include/vm/Makefile.am deleted file mode 100644 index 7faab0aab..000000000 --- a/include/vm/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -COMMON_H = - -KERNEL_H = \ - $(top_srcdir)/include/vm/anon.h \ - $(top_srcdir)/include/vm/pvn.h \ - $(top_srcdir)/include/vm/seg_kmem.h - -USER_H = - -EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H) - -if CONFIG_KERNEL -kerneldir = @prefix@/src/spl-$(VERSION)/include/vm -kernel_HEADERS = $(KERNEL_H) -endif diff --git a/include/vm/anon.h b/include/vm/anon.h deleted file mode 100644 index 706734ff3..000000000 --- a/include/vm/anon.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_VM_ANON_H -#define _SPL_VM_ANON_H - -#endif /* SPL_VM_ANON_H */ diff --git a/include/vm/pvn.h b/include/vm/pvn.h deleted file mode 100644 index 1011e6cd8..000000000 --- a/include/vm/pvn.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_VM_PVN_H -#define _SPL_VM_PVN_H - -#endif /* SPL_VM_PVN_H */ diff --git a/include/vm/seg_kmem.h b/include/vm/seg_kmem.h deleted file mode 100644 index a0ab7fce6..000000000 --- a/include/vm/seg_kmem.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPL_SEG_KMEM_H -#define _SPL_SEG_KMEM_H - -#include - -#endif /* SPL_SEG_KMEM_H */ diff --git a/lib/Makefile.am b/lib/Makefile.am deleted file mode 100644 index 0f2826bb2..000000000 --- a/lib/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -noinst_LTLIBRARIES = libcommon.la -libcommon_la_SOURCES = list.c - -EXTRA_DIST = list.h diff --git a/lib/list.c b/lib/list.c deleted file mode 100644 index 140a1bbdd..000000000 --- a/lib/list.c +++ /dev/null @@ -1,837 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2001-2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Chris Dunlap . - * UCRL-CODE-235197 - * - * This file is from LSD-Tools, the LLNL Software Development Toolbox. - * - * LSD-Tools is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * LSD-Tools is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with LSD-Tools. If not, see . - ***************************************************************************** - * Refer to "list.h" for documentation on public functions. - *****************************************************************************/ - -#ifdef WITH_PTHREADS -# include -#endif /* WITH_PTHREADS */ - -#include -#include -#include -#include -#include "list.h" - - -/********************* - * lsd_fatal_error * - *********************/ - -#ifdef WITH_LSD_FATAL_ERROR_FUNC -# undef lsd_fatal_error - extern void lsd_fatal_error(char *file, int line, char *mesg); -#else /* !WITH_LSD_FATAL_ERROR_FUNC */ -# ifndef lsd_fatal_error -# include -# include -# include -# define lsd_fatal_error(file, line, mesg) \ - do { \ - fprintf(stderr, "ERROR: [%s:%d] %s: %s\n", \ - file, line, mesg, strerror(errno)); \ - } while (0) -# endif /* !lsd_fatal_error */ -#endif /* !WITH_LSD_FATAL_ERROR_FUNC */ - - -/********************* - * lsd_nomem_error * - *********************/ - -#ifdef WITH_LSD_NOMEM_ERROR_FUNC -# undef lsd_nomem_error - extern void * lsd_nomem_error(char *file, int line, char *mesg); -#else /* !WITH_LSD_NOMEM_ERROR_FUNC */ -# ifndef lsd_nomem_error -# define lsd_nomem_error(file, line, mesg) (NULL) -# endif /* !lsd_nomem_error */ -#endif /* !WITH_LSD_NOMEM_ERROR_FUNC */ - - -/*************** - * Constants * - ***************/ - -#define LIST_ALLOC 32 -#define LIST_MAGIC 0xDEADBEEF - - -/**************** - * Data Types * - ****************/ - -struct listNode { - void *data; /* node's data */ - struct listNode *next; /* next node in list */ -}; - -struct listIterator { - struct list *list; /* the list being iterated */ - struct listNode *pos; /* the next node to be iterated */ - struct listNode **prev; /* addr of 'next' ptr to prv It node */ - struct listIterator *iNext; /* iterator chain for list_destroy() */ -#ifndef NDEBUG - unsigned int magic; /* sentinel for asserting validity */ -#endif /* !NDEBUG */ -}; - -struct list { - struct listNode *head; /* head of the list */ - struct listNode **tail; /* addr of last node's 'next' ptr */ - struct listIterator *iNext; /* iterator chain for list_destroy() */ - ListDelF fDel; /* function to delete node data */ - int count; /* number of nodes in list */ -#ifdef WITH_PTHREADS - pthread_mutex_t mutex; /* mutex to protect access to list */ -#endif /* WITH_PTHREADS */ -#ifndef NDEBUG - unsigned int magic; /* sentinel for asserting validity */ -#endif /* !NDEBUG */ -}; - -typedef struct listNode * ListNode; - - -/**************** - * Prototypes * - ****************/ - -static void * list_node_create (List l, ListNode *pp, void *x); -static void * list_node_destroy (List l, ListNode *pp); -static List list_alloc (void); -static void list_free (List l); -static ListNode list_node_alloc (void); -static void list_node_free (ListNode p); -static ListIterator list_iterator_alloc (void); -static void list_iterator_free (ListIterator i); -static void * list_alloc_aux (int size, void *pfreelist); -static void list_free_aux (void *x, void *pfreelist); - - -/*************** - * Variables * - ***************/ - -static List list_free_lists = NULL; -static ListNode list_free_nodes = NULL; -static ListIterator list_free_iterators = NULL; - -#ifdef WITH_PTHREADS -static pthread_mutex_t list_free_lock = PTHREAD_MUTEX_INITIALIZER; -#endif /* WITH_PTHREADS */ - - -/************ - * Macros * - ************/ - -#ifdef WITH_PTHREADS - -# define list_mutex_init(mutex) \ - do { \ - int e = pthread_mutex_init(mutex, NULL); \ - if (e != 0) { \ - errno = e; \ - lsd_fatal_error(__FILE__, __LINE__, "list mutex init"); \ - abort(); \ - } \ - } while (0) - -# define list_mutex_lock(mutex) \ - do { \ - int e = pthread_mutex_lock(mutex); \ - if (e != 0) { \ - errno = e; \ - lsd_fatal_error(__FILE__, __LINE__, "list mutex lock"); \ - abort(); \ - } \ - } while (0) - -# define list_mutex_unlock(mutex) \ - do { \ - int e = pthread_mutex_unlock(mutex); \ - if (e != 0) { \ - errno = e; \ - lsd_fatal_error(__FILE__, __LINE__, "list mutex unlock"); \ - abort(); \ - } \ - } while (0) - -# define list_mutex_destroy(mutex) \ - do { \ - int e = pthread_mutex_destroy(mutex); \ - if (e != 0) { \ - errno = e; \ - lsd_fatal_error(__FILE__, __LINE__, "list mutex destroy"); \ - abort(); \ - } \ - } while (0) - -# ifndef NDEBUG - static int list_mutex_is_locked (pthread_mutex_t *mutex); -# endif /* !NDEBUG */ - -#else /* !WITH_PTHREADS */ - -# define list_mutex_init(mutex) -# define list_mutex_lock(mutex) -# define list_mutex_unlock(mutex) -# define list_mutex_destroy(mutex) -# define list_mutex_is_locked(mutex) (1) - -#endif /* !WITH_PTHREADS */ - - -/*************** - * Functions * - ***************/ - -List -list_create (ListDelF f) -{ - List l; - - if (!(l = list_alloc())) - return(lsd_nomem_error(__FILE__, __LINE__, "list create")); - l->head = NULL; - l->tail = &l->head; - l->iNext = NULL; - l->fDel = f; - l->count = 0; - list_mutex_init(&l->mutex); -#ifndef NDEBUG - l->magic = LIST_MAGIC; -#endif - return(l); -} - - -void -list_destroy (List l) -{ - ListIterator i, iTmp; - ListNode p, pTmp; - - assert(l != NULL); - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - i = l->iNext; - while (i) { - assert(i->magic == LIST_MAGIC); - iTmp = i->iNext; -#ifndef NDEBUG - i->magic = ~LIST_MAGIC; -#endif /* !NDEBUG */ - list_iterator_free(i); - i = iTmp; - } - p = l->head; - while (p) { - pTmp = p->next; - if (p->data && l->fDel) - l->fDel(p->data); - list_node_free(p); - p = pTmp; - } -#ifndef NDEBUG - l->magic = ~LIST_MAGIC; -#endif /* !NDEBUG */ - list_mutex_unlock(&l->mutex); - list_mutex_destroy(&l->mutex); - list_free(l); - return; -} - - -int -list_is_empty (List l) -{ - int n; - - assert(l != NULL); - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - n = l->count; - list_mutex_unlock(&l->mutex); - return(n == 0); -} - - -int -list_count (List l) -{ - int n; - - assert(l != NULL); - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - n = l->count; - list_mutex_unlock(&l->mutex); - return(n); -} - - -void * -list_append (List l, void *x) -{ - void *v; - - assert(l != NULL); - assert(x != NULL); - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - v = list_node_create(l, l->tail, x); - list_mutex_unlock(&l->mutex); - return(v); -} - - -void * -list_prepend (List l, void *x) -{ - void *v; - - assert(l != NULL); - assert(x != NULL); - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - v = list_node_create(l, &l->head, x); - list_mutex_unlock(&l->mutex); - return(v); -} - - -void * -list_find_first (List l, ListFindF f, void *key) -{ - ListNode p; - void *v = NULL; - - assert(l != NULL); - assert(f != NULL); - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - for (p=l->head; p; p=p->next) { - if (f(p->data, key)) { - v = p->data; - break; - } - } - list_mutex_unlock(&l->mutex); - return(v); -} - - -int -list_delete_all (List l, ListFindF f, void *key) -{ - ListNode *pp; - void *v; - int n = 0; - - assert(l != NULL); - assert(f != NULL); - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - pp = &l->head; - while (*pp) { - if (f((*pp)->data, key)) { - if ((v = list_node_destroy(l, pp))) { - if (l->fDel) - l->fDel(v); - n++; - } - } - else { - pp = &(*pp)->next; - } - } - list_mutex_unlock(&l->mutex); - return(n); -} - - -int -list_for_each (List l, ListForF f, void *arg) -{ - ListNode p; - int n = 0; - - assert(l != NULL); - assert(f != NULL); - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - for (p=l->head; p; p=p->next) { - n++; - if (f(p->data, arg) < 0) { - n = -n; - break; - } - } - list_mutex_unlock(&l->mutex); - return(n); -} - - -void -list_sort (List l, ListCmpF f) -{ -/* Note: Time complexity O(n^2). - */ - ListNode *pp, *ppPrev, *ppPos, pTmp; - ListIterator i; - - assert(l != NULL); - assert(f != NULL); - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - if (l->count > 1) { - ppPrev = &l->head; - pp = &(*ppPrev)->next; - while (*pp) { - if (f((*pp)->data, (*ppPrev)->data) < 0) { - ppPos = &l->head; - while (f((*pp)->data, (*ppPos)->data) >= 0) - ppPos = &(*ppPos)->next; - pTmp = (*pp)->next; - (*pp)->next = *ppPos; - *ppPos = *pp; - *pp = pTmp; - if (ppPrev == ppPos) - ppPrev = &(*ppPrev)->next; - } - else { - ppPrev = pp; - pp = &(*pp)->next; - } - } - l->tail = pp; - - for (i=l->iNext; i; i=i->iNext) { - assert(i->magic == LIST_MAGIC); - i->pos = i->list->head; - i->prev = &i->list->head; - } - } - list_mutex_unlock(&l->mutex); - return; -} - - -void * -list_push (List l, void *x) -{ - void *v; - - assert(l != NULL); - assert(x != NULL); - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - v = list_node_create(l, &l->head, x); - list_mutex_unlock(&l->mutex); - return(v); -} - - -void * -list_pop (List l) -{ - void *v; - - assert(l != NULL); - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - v = list_node_destroy(l, &l->head); - list_mutex_unlock(&l->mutex); - return(v); -} - - -void * -list_peek (List l) -{ - void *v; - - assert(l != NULL); - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - v = (l->head) ? l->head->data : NULL; - list_mutex_unlock(&l->mutex); - return(v); -} - - -void * -list_enqueue (List l, void *x) -{ - void *v; - - assert(l != NULL); - assert(x != NULL); - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - v = list_node_create(l, l->tail, x); - list_mutex_unlock(&l->mutex); - return(v); -} - - -void * -list_dequeue (List l) -{ - void *v; - - assert(l != NULL); - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - v = list_node_destroy(l, &l->head); - list_mutex_unlock(&l->mutex); - return(v); -} - - -ListIterator -list_iterator_create (List l) -{ - ListIterator i; - - assert(l != NULL); - if (!(i = list_iterator_alloc())) - return(lsd_nomem_error(__FILE__, __LINE__, "list iterator create")); - i->list = l; - list_mutex_lock(&l->mutex); - assert(l->magic == LIST_MAGIC); - i->pos = l->head; - i->prev = &l->head; - i->iNext = l->iNext; - l->iNext = i; -#ifndef NDEBUG - i->magic = LIST_MAGIC; -#endif /* !NDEBUG */ - list_mutex_unlock(&l->mutex); - return(i); -} - - -void -list_iterator_reset (ListIterator i) -{ - assert(i != NULL); - assert(i->magic == LIST_MAGIC); - list_mutex_lock(&i->list->mutex); - assert(i->list->magic == LIST_MAGIC); - i->pos = i->list->head; - i->prev = &i->list->head; - list_mutex_unlock(&i->list->mutex); - return; -} - - -void -list_iterator_destroy (ListIterator i) -{ - ListIterator *pi; - - assert(i != NULL); - assert(i->magic == LIST_MAGIC); - list_mutex_lock(&i->list->mutex); - assert(i->list->magic == LIST_MAGIC); - for (pi=&i->list->iNext; *pi; pi=&(*pi)->iNext) { - assert((*pi)->magic == LIST_MAGIC); - if (*pi == i) { - *pi = (*pi)->iNext; - break; - } - } - list_mutex_unlock(&i->list->mutex); -#ifndef NDEBUG - i->magic = ~LIST_MAGIC; -#endif /* !NDEBUG */ - list_iterator_free(i); - return; -} - - -void * -list_next (ListIterator i) -{ - ListNode p; - - assert(i != NULL); - assert(i->magic == LIST_MAGIC); - list_mutex_lock(&i->list->mutex); - assert(i->list->magic == LIST_MAGIC); - if ((p = i->pos)) - i->pos = p->next; - if (*i->prev != p) - i->prev = &(*i->prev)->next; - list_mutex_unlock(&i->list->mutex); - return(p ? p->data : NULL); -} - - -void * -list_insert (ListIterator i, void *x) -{ - void *v; - - assert(i != NULL); - assert(x != NULL); - assert(i->magic == LIST_MAGIC); - list_mutex_lock(&i->list->mutex); - assert(i->list->magic == LIST_MAGIC); - v = list_node_create(i->list, i->prev, x); - list_mutex_unlock(&i->list->mutex); - return(v); -} - - -void * -list_find (ListIterator i, ListFindF f, void *key) -{ - void *v; - - assert(i != NULL); - assert(f != NULL); - assert(i->magic == LIST_MAGIC); - while ((v=list_next(i)) && !f(v,key)) {;} - return(v); -} - - -void * -list_remove (ListIterator i) -{ - void *v = NULL; - - assert(i != NULL); - assert(i->magic == LIST_MAGIC); - list_mutex_lock(&i->list->mutex); - assert(i->list->magic == LIST_MAGIC); - if (*i->prev != i->pos) - v = list_node_destroy(i->list, i->prev); - list_mutex_unlock(&i->list->mutex); - return(v); -} - - -int -list_delete (ListIterator i) -{ - void *v; - - assert(i != NULL); - assert(i->magic == LIST_MAGIC); - if ((v = list_remove(i))) { - if (i->list->fDel) - i->list->fDel(v); - return(1); - } - return(0); -} - - -static void * -list_node_create (List l, ListNode *pp, void *x) -{ -/* Inserts data pointed to by [x] into list [l] after [pp], - * the address of the previous node's "next" ptr. - * Returns a ptr to data [x], or NULL if insertion fails. - * This routine assumes the list is already locked upon entry. - */ - ListNode p; - ListIterator i; - - assert(l != NULL); - assert(l->magic == LIST_MAGIC); - assert(list_mutex_is_locked(&l->mutex)); - assert(pp != NULL); - assert(x != NULL); - if (!(p = list_node_alloc())) - return(lsd_nomem_error(__FILE__, __LINE__, "list node create")); - p->data = x; - if (!(p->next = *pp)) - l->tail = &p->next; - *pp = p; - l->count++; - for (i=l->iNext; i; i=i->iNext) { - assert(i->magic == LIST_MAGIC); - if (i->prev == pp) - i->prev = &p->next; - else if (i->pos == p->next) - i->pos = p; - assert((i->pos == *i->prev) || (i->pos == (*i->prev)->next)); - } - return(x); -} - - -static void * -list_node_destroy (List l, ListNode *pp) -{ -/* Removes the node pointed to by [*pp] from from list [l], - * where [pp] is the address of the previous node's "next" ptr. - * Returns the data ptr associated with list item being removed, - * or NULL if [*pp] points to the NULL element. - * This routine assumes the list is already locked upon entry. - */ - void *v; - ListNode p; - ListIterator i; - - assert(l != NULL); - assert(l->magic == LIST_MAGIC); - assert(list_mutex_is_locked(&l->mutex)); - assert(pp != NULL); - if (!(p = *pp)) - return(NULL); - v = p->data; - if (!(*pp = p->next)) - l->tail = pp; - l->count--; - for (i=l->iNext; i; i=i->iNext) { - assert(i->magic == LIST_MAGIC); - if (i->pos == p) - i->pos = p->next, i->prev = pp; - else if (i->prev == &p->next) - i->prev = pp; - assert((i->pos == *i->prev) || (i->pos == (*i->prev)->next)); - } - list_node_free(p); - return(v); -} - - -static List -list_alloc (void) -{ - return(list_alloc_aux(sizeof(struct list), &list_free_lists)); -} - - -static void -list_free (List l) -{ - list_free_aux(l, &list_free_lists); - return; -} - - -static ListNode -list_node_alloc (void) -{ - return(list_alloc_aux(sizeof(struct listNode), &list_free_nodes)); -} - - -static void -list_node_free (ListNode p) -{ - list_free_aux(p, &list_free_nodes); - return; -} - - -static ListIterator -list_iterator_alloc (void) -{ - return(list_alloc_aux(sizeof(struct listIterator), &list_free_iterators)); -} - - -static void -list_iterator_free (ListIterator i) -{ - list_free_aux(i, &list_free_iterators); - return; -} - - -static void * -list_alloc_aux (int size, void *pfreelist) -{ -/* Allocates an object of [size] bytes from the freelist [*pfreelist]. - * Memory is added to the freelist in chunks of size LIST_ALLOC. - * Returns a ptr to the object, or NULL if the memory request fails. - */ - void **px; - void **pfree = pfreelist; - void **plast; - - assert(sizeof(char) == 1); - assert(size >= (int)sizeof(void *)); - assert(pfreelist != NULL); - assert(LIST_ALLOC > 0); - list_mutex_lock(&list_free_lock); - if (!*pfree) { - if ((*pfree = malloc(LIST_ALLOC * size))) { - px = *pfree; - plast = (void **) ((char *) *pfree + ((LIST_ALLOC - 1) * size)); - while (px < plast) - *px = (char *) px + size, px = *px; - *plast = NULL; - } - } - if ((px = *pfree)) - *pfree = *px; - else - errno = ENOMEM; - list_mutex_unlock(&list_free_lock); - return(px); -} - - -static void -list_free_aux (void *x, void *pfreelist) -{ -/* Frees the object [x], returning it to the freelist [*pfreelist]. - */ - void **px = x; - void **pfree = pfreelist; - - assert(x != NULL); - assert(pfreelist != NULL); - list_mutex_lock(&list_free_lock); - *px = *pfree; - *pfree = px; - list_mutex_unlock(&list_free_lock); - return; -} - - -#ifndef NDEBUG -#ifdef WITH_PTHREADS -static int -list_mutex_is_locked (pthread_mutex_t *mutex) -{ -/* Returns true if the mutex is locked; o/w, returns false. - */ - int rc; - - assert(mutex != NULL); - rc = pthread_mutex_trylock(mutex); - return(rc == EBUSY ? 1 : 0); -} -#endif /* WITH_PTHREADS */ -#endif /* !NDEBUG */ diff --git a/lib/list.h b/lib/list.h deleted file mode 100644 index 01adedd59..000000000 --- a/lib/list.h +++ /dev/null @@ -1,279 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2001-2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Chris Dunlap . - * UCRL-CODE-235197 - * - * This file is from LSD-Tools, the LLNL Software Development Toolbox. - * - * LSD-Tools is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * LSD-Tools is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with LSD-Tools. If not, see . - *****************************************************************************/ - -#ifndef LSD_LIST_H -#define LSD_LIST_H - - -/*********** - * Notes * - ***********/ -/* - * If NDEBUG is not defined, internal debug code will be enabled. This is - * intended for development use only and production code should define NDEBUG. - * - * If WITH_LSD_FATAL_ERROR_FUNC is defined, the linker will expect to - * find an external lsd_fatal_error(file,line,mesg) function. By default, - * lsd_fatal_error(file,line,mesg) is a macro definition that outputs an - * error message to stderr. This macro may be redefined to invoke another - * routine instead. - * - * If WITH_LSD_NOMEM_ERROR_FUNC is defined, the linker will expect to - * find an external lsd_nomem_error(file,line,mesg) function. By default, - * lsd_nomem_error(file,line,mesg) is a macro definition that returns NULL. - * This macro may be redefined to invoke another routine instead. - * - * If WITH_PTHREADS is defined, these routines will be thread-safe. - */ - - -/**************** - * Data Types * - ****************/ - -typedef struct list * List; -/* - * List opaque data type. - */ - -typedef struct listIterator * ListIterator; -/* - * List Iterator opaque data type. - */ - -typedef void (*ListDelF) (void *x); -/* - * Function prototype to deallocate data stored in a list. - * This function is responsible for freeing all memory associated - * with an item, including all subordinate items (if applicable). - */ - -typedef int (*ListCmpF) (void *x, void *y); -/* - * Function prototype for comparing two items in a list. - * Returns less-than-zero if (xy). - */ - -typedef int (*ListFindF) (void *x, void *key); -/* - * Function prototype for matching items in a list. - * Returns non-zero if (x==key); o/w returns zero. - */ - -typedef int (*ListForF) (void *x, void *arg); -/* - * Function prototype for operating on each item in a list. - * Returns less-than-zero on error. - */ - - -/******************************* - * General-Purpose Functions * - *******************************/ - -List list_create (ListDelF f); -/* - * Creates and returns a new empty list, or lsd_nomem_error() on failure. - * The deletion function [f] is used to deallocate memory used by items - * in the list; if this is NULL, memory associated with these items - * will not be freed when the list is destroyed. - * Note: Abandoning a list without calling list_destroy() will result - * in a memory leak. - */ - -void list_destroy (List l); -/* - * Destroys list [l], freeing memory used for list iterators and the - * list itself; if a deletion function was specified when the list - * was created, it will be called for each item in the list. - */ - -int list_is_empty (List l); -/* - * Returns non-zero if list [l] is empty; o/w returns zero. - */ - -int list_count (List l); -/* - * Returns the number of items in list [l]. - */ - - -/*************************** - * List Access Functions * - ***************************/ - -void * list_append (List l, void *x); -/* - * Inserts data [x] at the end of list [l]. - * Returns the data's ptr, or lsd_nomem_error() if insertion failed. - */ - -void * list_prepend (List l, void *x); -/* - * Inserts data [x] at the beginning of list [l]. - * Returns the data's ptr, or lsd_nomem_error() if insertion failed. - */ - -void * list_find_first (List l, ListFindF f, void *key); -/* - * Traverses list [l] using [f] to match each item with [key]. - * Returns a ptr to the first item for which the function [f] - * returns non-zero, or NULL if no such item is found. - * Note: This function differs from list_find() in that it does not require - * a list iterator; it should only be used when all list items are known - * to be unique (according to the function [f]). - */ - -int list_delete_all (List l, ListFindF f, void *key); -/* - * Traverses list [l] using [f] to match each item with [key]. - * Removes all items from the list for which the function [f] returns - * non-zero; if a deletion function was specified when the list was - * created, it will be called to deallocate each item being removed. - * Returns a count of the number of items removed from the list. - */ - -int list_for_each (List l, ListForF f, void *arg); -/* - * For each item in list [l], invokes the function [f] with [arg]. - * Returns a count of the number of items on which [f] was invoked. - * If [f] returns <0 for a given item, the iteration is aborted and the - * function returns the negative of that item's position in the list. - */ - -void list_sort (List l, ListCmpF f); -/* - * Sorts list [l] into ascending order according to the function [f]. - * Note: Sorting a list resets all iterators associated with the list. - * Note: The sort algorithm is stable. - */ - - -/**************************** - * Stack Access Functions * - ****************************/ - -void * list_push (List l, void *x); -/* - * Pushes data [x] onto the top of stack [l]. - * Returns the data's ptr, or lsd_nomem_error() if insertion failed. - */ - -void * list_pop (List l); -/* - * Pops the data item at the top of the stack [l]. - * Returns the data's ptr, or NULL if the stack is empty. - */ - -void * list_peek (List l); -/* - * Peeks at the data item at the top of the stack (or head of the queue) [l]. - * Returns the data's ptr, or NULL if the stack (or queue) is empty. - * Note: The item is not removed from the list. - */ - - -/**************************** - * Queue Access Functions * - ****************************/ - -void * list_enqueue (List l, void *x); -/* - * Enqueues data [x] at the tail of queue [l]. - * Returns the data's ptr, or lsd_nomem_error() if insertion failed. - */ - -void * list_dequeue (List l); -/* - * Dequeues the data item at the head of the queue [l]. - * Returns the data's ptr, or NULL if the queue is empty. - */ - - -/***************************** - * List Iterator Functions * - *****************************/ - -ListIterator list_iterator_create (List l); -/* - * Creates and returns a list iterator for non-destructively traversing - * list [l], or lsd_nomem_error() on failure. - */ - -void list_iterator_reset (ListIterator i); -/* - * Resets the list iterator [i] to start traversal at the beginning - * of the list. - */ - -void list_iterator_destroy (ListIterator i); -/* - * Destroys the list iterator [i]; list iterators not explicitly destroyed - * in this manner will be destroyed when the list is deallocated via - * list_destroy(). - */ - -void * list_next (ListIterator i); -/* - * Returns a ptr to the next item's data, - * or NULL once the end of the list is reached. - * Example: i=list_iterator_create(i); while ((x=list_next(i))) {...} - */ - -void * list_insert (ListIterator i, void *x); -/* - * Inserts data [x] immediately before the last item returned via list - * iterator [i]; once the list iterator reaches the end of the list, - * insertion is made at the list's end. - * Returns the data's ptr, or lsd_nomem_error() if insertion failed. - */ - -void * list_find (ListIterator i, ListFindF f, void *key); -/* - * Traverses the list from the point of the list iterator [i] - * using [f] to match each item with [key]. - * Returns a ptr to the next item for which the function [f] - * returns non-zero, or NULL once the end of the list is reached. - * Example: i=list_iterator_reset(i); while ((x=list_find(i,f,k))) {...} - */ - -void * list_remove (ListIterator i); -/* - * Removes from the list the last item returned via list iterator [i] - * and returns the data's ptr. - * Note: The client is responsible for freeing the returned data. - */ - -int list_delete (ListIterator i); -/* - * Removes from the list the last item returned via list iterator [i]; - * if a deletion function was specified when the list was created, - * it will be called to deallocate the item being removed. - * Returns a count of the number of items removed from the list - * (ie, '1' if the item was removed, and '0' otherwise). - */ - - -#endif /* !LSD_LIST_H */ diff --git a/man/Makefile.am b/man/Makefile.am deleted file mode 100644 index 7791945cf..000000000 --- a/man/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = man1 man5 diff --git a/man/man1/Makefile.am b/man/man1/Makefile.am deleted file mode 100644 index d6becca6e..000000000 --- a/man/man1/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -dist_man_MANS = splat.1 - -install-data-local: - $(INSTALL) -d -m 0755 "$(DESTDIR)$(mandir)/man1" diff --git a/man/man1/splat.1 b/man/man1/splat.1 deleted file mode 100644 index 407680b28..000000000 --- a/man/man1/splat.1 +++ /dev/null @@ -1,94 +0,0 @@ -'\" t -.\" -.\" Copyright 2013 Darik Horn . All rights reserved. -.\" -.TH splat 1 "2013 MAR 16" "ZFS on Linux" "User Commands" - -.SH NAME -splat \- Solaris Porting LAyer Tests -.SH SYNOPSIS -.LP -.BI "splat [\-chvx] < \-\-all | \-\-list | \-\-test " "subsystem" ":" "test" " [...] >" - -.SH DESCRIPTION -This utility uses the splat.ko kernel module to test the spl.ko kernel -module. Run "modprobe splat" before invoking \fBsplat\fR. - -.SH OPTIONS -.HP -.BI "\-a" "" ", \-\-all" "" -.IP -Run all available tests on all subsystems. -.HP -.BI "\-c" "" ", \-\-nocolor" "" -.IP -Disable output highlighting. By default, "Fail" is printed in red text -and "Pass" is printed in green text. -.HP -.BI "\-h" "" ", \-\-help" "" -.IP -Print the usage message. -.HP -.BI "\-l" "" ", \-\-list" "" -.IP -For each spl.ko subsystem, print all available test names and -hexadecimal identifiers with a short description. -.HP -.BI "\-t" " subsystem" ":" "test" ", \-\-test" " subsystem" ":" "test" -.HP -.BI "\-t" " subsystem" ":all" "" ", \-\-test" " subsystem" ":all" "" -.IP -Run the \fItest\fR diagnostic routine for the spl.ko \fIsubsystem\fR. -Specify this option more than once to run multiple tests. - -The \fItest\fR and \fIsubsystem\fR parameters are the names or -hexadecimal identifiers returned by the \fBsplat --list\fR command. - -If \fIsubsystem\fR is a name and not a hexadecimal identifier, then the -\fBall\fR keyword can be used to run all available \fIsubsystem\fR -tests. - -.HP -.BI "\-v" "" ", \-\-verbose" "" -.HP -.IP -Increase verbosity. -.HP -.BI "\-x" "" ", \-\-exit" "" -.IP -Stop running tests after the first failure. - -.SH "EXAMPLES" -.LP -Test everything in the spl.ko kernel module: -.IP -# splat --all --verbose -.LP -Test the entire kernel memory subsystem: -.IP -# splat --test kmem:all -.LP -Test the kernel compression and queue waiting facilities: -.IP -# splat --test zlib:compress/uncompress --test taskq:wait -.LP -This is the same as the previous command, except that the subsystems -and tests are referenced by hexadecimal identifier instead of by name: -.IP -# splat -t 0x0f00:0x0f01 -t 0x0200:0x0204 - -.SH "NOTES" -All tests always return a green "Pass" result on a healthy system. Any -red "Fail" result should be investigated or reported. - -.SH "BUGS" -Some tests can deadlock the kernel if an X11 desktop is running, -especially if a proprietary blob driver is loaded for the video -hardware. - -.SH "AUTHORS" -This man page was written by Darik Horn . - -.SH "SEE ALSO" -.BR zpios (1), -.BR ztest (1) diff --git a/man/man5/Makefile.am b/man/man5/Makefile.am deleted file mode 100644 index fb22beb11..000000000 --- a/man/man5/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -dist_man_MANS = spl-module-parameters.5 - -install-data-local: - $(INSTALL) -d -m 0755 "$(DESTDIR)$(mandir)/man5" diff --git a/module/.gitignore b/module/.gitignore deleted file mode 100644 index 907099287..000000000 --- a/module/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.ko -*.ko.unsigned -*.ko.out -*.ko.out.sig -*.mod.c -.*.cmd -modules.order - -/.tmp_versions -/Module.markers -/Module.symvers - -!Makefile.in diff --git a/module/Makefile.in b/module/Makefile.in deleted file mode 100644 index d4e62e152..000000000 --- a/module/Makefile.in +++ /dev/null @@ -1,54 +0,0 @@ -subdir-m += spl -subdir-m += splat - -INSTALL_MOD_DIR ?= extra - -SPL_MODULE_CFLAGS = -I@abs_top_srcdir@/include -SPL_MODULE_CFLAGS += -include @abs_top_builddir@/spl_config.h -export SPL_MODULE_CFLAGS - -modules: - $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ CONFIG_SPL=m $@ - -clean: - @# Only cleanup the kernel build directories when CONFIG_KERNEL - @# is defined. This indicates that kernel modules should be built. -@CONFIG_KERNEL_TRUE@ $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@ - - if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi - if [ -f Module.markers ]; then $(RM) Module.markers; fi - -modules_install: - @# Install the kernel modules - $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` $@ \ - INSTALL_MOD_PATH=$(DESTDIR)$(INSTALL_MOD_PATH) \ - INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \ - KERNELRELEASE=@LINUX_VERSION@ - @# Remove extraneous build products when packaging - kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \ - if [ -n "$(DESTDIR)" ]; then \ - find $$kmoddir -name 'modules.*' | xargs $(RM); \ - fi - sysmap=$(DESTDIR)$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \ - if [ -f $$sysmap ]; then \ - depmod -ae -F $$sysmap @LINUX_VERSION@; \ - fi - -modules_uninstall: - @# Uninstall the kernel modules - kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@ - list='$(subdir-m)'; for subdir in $$list; do \ - $(RM) -R $$kmoddir/$(INSTALL_MOD_DIR)/$$subdir; \ - done - -distdir: - list='$(subdir-m)'; for subdir in $$list; do \ - (find @top_srcdir@/module/$$subdir -name '*.c' -o -name '*.h' |\ - xargs /bin/cp -t $$distdir/$$subdir); \ - done - -distclean maintainer-clean: clean -install: modules_install -uninstall: modules_uninstall -all: modules -check: diff --git a/module/spl/Makefile.in b/module/spl/Makefile.in deleted file mode 100644 index a1f1ab823..000000000 --- a/module/spl/Makefile.in +++ /dev/null @@ -1,30 +0,0 @@ -# Makefile.in for spl kernel module - -src = @abs_top_srcdir@/module/spl -obj = @abs_builddir@ - -MODULE := spl -EXTRA_CFLAGS = $(SPL_MODULE_CFLAGS) @KERNELCPPFLAGS@ - -# Solaris porting layer module -obj-$(CONFIG_SPL) := $(MODULE).o - -$(MODULE)-objs += spl-proc.o -$(MODULE)-objs += spl-kmem.o -$(MODULE)-objs += spl-kmem-cache.o -$(MODULE)-objs += spl-vmem.o -$(MODULE)-objs += spl-thread.o -$(MODULE)-objs += spl-taskq.o -$(MODULE)-objs += spl-rwlock.o -$(MODULE)-objs += spl-vnode.o -$(MODULE)-objs += spl-err.o -$(MODULE)-objs += spl-kobj.o -$(MODULE)-objs += spl-generic.o -$(MODULE)-objs += spl-atomic.o -$(MODULE)-objs += spl-mutex.o -$(MODULE)-objs += spl-kstat.o -$(MODULE)-objs += spl-condvar.o -$(MODULE)-objs += spl-xdr.o -$(MODULE)-objs += spl-cred.o -$(MODULE)-objs += spl-tsd.o -$(MODULE)-objs += spl-zlib.o diff --git a/module/spl/THIRDPARTYLICENSE.gplv2 b/module/spl/THIRDPARTYLICENSE.gplv2 new file mode 100644 index 000000000..d159169d1 --- /dev/null +++ b/module/spl/THIRDPARTYLICENSE.gplv2 @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/module/spl/THIRDPARTYLICENSE.gplv2.descrip b/module/spl/THIRDPARTYLICENSE.gplv2.descrip new file mode 100644 index 000000000..78535a8ee --- /dev/null +++ b/module/spl/THIRDPARTYLICENSE.gplv2.descrip @@ -0,0 +1 @@ +COMPATIBILITY LAYER FOR OPENZFS ON LINUX diff --git a/module/spl/spl-generic.c b/module/spl/spl-generic.c index 2a8972691..b38fe254c 100644 --- a/module/spl/spl-generic.c +++ b/module/spl/spl-generic.c @@ -43,9 +43,8 @@ #include #include #include +#include #include -#include -#include char spl_version[32] = "SPL v" SPL_META_VERSION "-" SPL_META_RELEASE; EXPORT_SYMBOL(spl_version); @@ -260,6 +259,12 @@ __udivdi3(uint64_t u, uint64_t v) } EXPORT_SYMBOL(__udivdi3); +/* BEGIN CSTYLED */ +#ifndef abs64 +#define abs64(x) ({ uint64_t t = (x) >> 63; ((x) ^ t) - t; }) +#endif +/* END CSTYLED */ + /* * Implementation of 64-bit signed division for 32-bit machines. */ diff --git a/module/spl/spl-kmem-cache.c b/module/spl/spl-kmem-cache.c index c73a2fdc2..5492c6a46 100644 --- a/module/spl/spl-kmem-cache.c +++ b/module/spl/spl-kmem-cache.c @@ -24,13 +24,13 @@ #include #include +#include #include #include #include +#include #include #include -#include -#include #include /* diff --git a/module/spl/spl-kstat.c b/module/spl/spl-kstat.c index 10e93f318..bcbff94a6 100644 --- a/module/spl/spl-kstat.c +++ b/module/spl/spl-kstat.c @@ -28,6 +28,7 @@ #include #include #include +#include #ifndef HAVE_PDE_DATA #define PDE_DATA(x) (PDE(x)->data) diff --git a/module/spl/spl-proc.c b/module/spl/spl-proc.c index 796f69e48..9c52924a4 100644 --- a/module/spl/spl-proc.c +++ b/module/spl/spl-proc.c @@ -30,10 +30,10 @@ #include #include #include +#include #include #include #include -#include #include #include diff --git a/module/spl/spl-vmem.c b/module/spl/spl-vmem.c index dd10607dc..e1a84a911 100644 --- a/module/spl/spl-vmem.c +++ b/module/spl/spl-vmem.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include vmem_t *heap_arena = NULL; diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c index a371fb966..28ce21276 100644 --- a/module/spl/spl-vnode.c +++ b/module/spl/spl-vnode.c @@ -28,7 +28,11 @@ #include #include #include -#include +#include +#include +#ifdef HAVE_FDTABLE_HEADER +#include +#endif vnode_t *rootdir = (vnode_t *)0xabcd1234; EXPORT_SYMBOL(rootdir); @@ -39,6 +43,76 @@ static spl_kmem_cache_t *vn_file_cache; static DEFINE_SPINLOCK(vn_file_lock); static LIST_HEAD(vn_file_list); +static int +spl_filp_fallocate(struct file *fp, int mode, loff_t offset, loff_t len) +{ + int error = -EOPNOTSUPP; + +#ifdef HAVE_FILE_FALLOCATE + if (fp->f_op->fallocate) + error = fp->f_op->fallocate(fp, mode, offset, len); +#else +#ifdef HAVE_INODE_FALLOCATE + if (fp->f_dentry && fp->f_dentry->d_inode && + fp->f_dentry->d_inode->i_op->fallocate) + error = fp->f_dentry->d_inode->i_op->fallocate( + fp->f_dentry->d_inode, mode, offset, len); +#endif /* HAVE_INODE_FALLOCATE */ +#endif /* HAVE_FILE_FALLOCATE */ + + return (error); +} + +static int +spl_filp_fsync(struct file *fp, int sync) +{ +#ifdef HAVE_2ARGS_VFS_FSYNC + return (vfs_fsync(fp, sync)); +#else + return (vfs_fsync(fp, (fp)->f_dentry, sync)); +#endif /* HAVE_2ARGS_VFS_FSYNC */ +} + +static ssize_t +spl_kernel_write(struct file *file, const void *buf, size_t count, loff_t *pos) +{ +#if defined(HAVE_KERNEL_WRITE_PPOS) + return (kernel_write(file, buf, count, pos)); +#else + mm_segment_t saved_fs; + ssize_t ret; + + saved_fs = get_fs(); + set_fs(get_ds()); + + ret = vfs_write(file, (__force const char __user *)buf, count, pos); + + set_fs(saved_fs); + + return (ret); +#endif +} + +static ssize_t +spl_kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) +{ +#if defined(HAVE_KERNEL_READ_PPOS) + return (kernel_read(file, buf, count, pos)); +#else + mm_segment_t saved_fs; + ssize_t ret; + + saved_fs = get_fs(); + set_fs(get_ds()); + + ret = vfs_read(file, (void __user *)buf, count, pos); + + set_fs(saved_fs); + + return (ret); +#endif +} + vtype_t vn_mode_to_vtype(mode_t mode) { diff --git a/module/spl/spl-xdr.c b/module/spl/spl-xdr.c index 4055921b4..2cc3e2a03 100644 --- a/module/spl/spl-xdr.c +++ b/module/spl/spl-xdr.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include /* @@ -131,6 +131,8 @@ static struct xdr_ops xdrmem_encode_ops; static struct xdr_ops xdrmem_decode_ops; +typedef int bool_t; + void xdrmem_create(XDR *xdrs, const caddr_t addr, const uint_t size, const enum xdr_op op) diff --git a/module/spl/spl-zlib.c b/module/spl/spl-zlib.c index 177a626df..229e6a44b 100644 --- a/module/spl/spl-zlib.c +++ b/module/spl/spl-zlib.c @@ -57,7 +57,6 @@ #include #include #include -#include static spl_kmem_cache_t *zlib_workspace_cache; diff --git a/module/splat/Makefile.in b/module/splat/Makefile.in deleted file mode 100644 index 680f28492..000000000 --- a/module/splat/Makefile.in +++ /dev/null @@ -1,28 +0,0 @@ -# Makefile.in for splat kernel module - -src = @abs_top_srcdir@/module/splat -obj = @abs_builddir@ - -MODULE := splat -EXTRA_CFLAGS = $(SPL_MODULE_CFLAGS) @KERNELCPPFLAGS@ - -# Solaris Porting LAyer Tests -obj-$(CONFIG_SPL) := $(MODULE).o - -$(MODULE)-objs += splat-ctl.o -$(MODULE)-objs += splat-kmem.o -$(MODULE)-objs += splat-taskq.o -$(MODULE)-objs += splat-random.o -$(MODULE)-objs += splat-mutex.o -$(MODULE)-objs += splat-condvar.o -$(MODULE)-objs += splat-thread.o -$(MODULE)-objs += splat-rwlock.o -$(MODULE)-objs += splat-time.o -$(MODULE)-objs += splat-vnode.o -$(MODULE)-objs += splat-kobj.o -$(MODULE)-objs += splat-atomic.o -$(MODULE)-objs += splat-list.o -$(MODULE)-objs += splat-generic.o -$(MODULE)-objs += splat-cred.o -$(MODULE)-objs += splat-zlib.o -$(MODULE)-objs += splat-linux.o diff --git a/module/splat/splat-atomic.c b/module/splat/splat-atomic.c deleted file mode 100644 index 8aaa0835d..000000000 --- a/module/splat/splat-atomic.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Atomic Tests. - */ - -#include -#include -#include -#include -#include -#include -#include "splat-internal.h" - -#define SPLAT_ATOMIC_NAME "atomic" -#define SPLAT_ATOMIC_DESC "Kernel Atomic Tests" - -#define SPLAT_ATOMIC_TEST1_ID 0x0b01 -#define SPLAT_ATOMIC_TEST1_NAME "64-bit" -#define SPLAT_ATOMIC_TEST1_DESC "Validate 64-bit atomic ops" - -#define SPLAT_ATOMIC_TEST_MAGIC 0x43435454UL -#define SPLAT_ATOMIC_INIT_VALUE 10000000UL - -typedef enum { - SPLAT_ATOMIC_INC_64 = 0, - SPLAT_ATOMIC_DEC_64 = 1, - SPLAT_ATOMIC_ADD_64 = 2, - SPLAT_ATOMIC_SUB_64 = 3, - SPLAT_ATOMIC_ADD_64_NV = 4, - SPLAT_ATOMIC_SUB_64_NV = 5, - SPLAT_ATOMIC_COUNT_64 = 6 -} atomic_op_t; - -typedef struct atomic_priv { - unsigned long ap_magic; - struct file *ap_file; - kmutex_t ap_lock; - spl_wait_queue_head_t ap_waitq; - volatile uint64_t ap_atomic; - volatile uint64_t ap_atomic_exited; - atomic_op_t ap_op; - -} atomic_priv_t; - -static void -splat_atomic_work(void *priv) -{ - atomic_priv_t *ap; - atomic_op_t op; - int i; - - ap = (atomic_priv_t *)priv; - ASSERT(ap->ap_magic == SPLAT_ATOMIC_TEST_MAGIC); - - mutex_enter(&ap->ap_lock); - op = ap->ap_op; - wake_up(&ap->ap_waitq); - mutex_exit(&ap->ap_lock); - - splat_vprint(ap->ap_file, SPLAT_ATOMIC_TEST1_NAME, - "Thread %d successfully started: %lu/%lu\n", op, - (long unsigned)ap->ap_atomic, - (long unsigned)ap->ap_atomic_exited); - - for (i = 0; i < SPLAT_ATOMIC_INIT_VALUE / 10; i++) { - - /* Periodically sleep to mix up the ordering */ - if ((i % (SPLAT_ATOMIC_INIT_VALUE / 100)) == 0) { - splat_vprint(ap->ap_file, SPLAT_ATOMIC_TEST1_NAME, - "Thread %d sleeping: %lu/%lu\n", op, - (long unsigned)ap->ap_atomic, - (long unsigned)ap->ap_atomic_exited); - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(HZ / 100); - } - - switch (op) { - case SPLAT_ATOMIC_INC_64: - atomic_inc_64(&ap->ap_atomic); - break; - case SPLAT_ATOMIC_DEC_64: - atomic_dec_64(&ap->ap_atomic); - break; - case SPLAT_ATOMIC_ADD_64: - atomic_add_64(&ap->ap_atomic, 3); - break; - case SPLAT_ATOMIC_SUB_64: - atomic_sub_64(&ap->ap_atomic, 3); - break; - case SPLAT_ATOMIC_ADD_64_NV: - atomic_add_64_nv(&ap->ap_atomic, 5); - break; - case SPLAT_ATOMIC_SUB_64_NV: - atomic_sub_64_nv(&ap->ap_atomic, 5); - break; - default: - PANIC("Undefined op %d\n", op); - } - } - - atomic_inc_64(&ap->ap_atomic_exited); - - splat_vprint(ap->ap_file, SPLAT_ATOMIC_TEST1_NAME, - "Thread %d successfully exited: %lu/%lu\n", op, - (long unsigned)ap->ap_atomic, - (long unsigned)ap->ap_atomic_exited); - - wake_up(&ap->ap_waitq); - thread_exit(); -} - -static int -splat_atomic_test1_cond(atomic_priv_t *ap, int started) -{ - return (ap->ap_atomic_exited == started); -} - -static int -splat_atomic_test1(struct file *file, void *arg) -{ - atomic_priv_t ap; - DEFINE_WAIT(wait); - kthread_t *thr; - int i, rc = 0; - - ap.ap_magic = SPLAT_ATOMIC_TEST_MAGIC; - ap.ap_file = file; - mutex_init(&ap.ap_lock, SPLAT_ATOMIC_TEST1_NAME, MUTEX_DEFAULT, NULL); - init_waitqueue_head(&ap.ap_waitq); - ap.ap_atomic = SPLAT_ATOMIC_INIT_VALUE; - ap.ap_atomic_exited = 0; - - for (i = 0; i < SPLAT_ATOMIC_COUNT_64; i++) { - mutex_enter(&ap.ap_lock); - ap.ap_op = i; - - thr = (kthread_t *)thread_create(NULL, 0, splat_atomic_work, - &ap, 0, &p0, TS_RUN, - defclsyspri); - if (thr == NULL) { - rc = -ESRCH; - mutex_exit(&ap.ap_lock); - break; - } - - /* Prepare to wait, the new thread will wake us once it - * has made a copy of the unique private passed data */ - prepare_to_wait(&ap.ap_waitq, &wait, TASK_UNINTERRUPTIBLE); - mutex_exit(&ap.ap_lock); - schedule(); - } - - wait_event(ap.ap_waitq, splat_atomic_test1_cond(&ap, i)); - - if (rc) { - splat_vprint(file, SPLAT_ATOMIC_TEST1_NAME, "Only started " - "%d/%d test threads\n", i, SPLAT_ATOMIC_COUNT_64); - return rc; - } - - if (ap.ap_atomic != SPLAT_ATOMIC_INIT_VALUE) { - splat_vprint(file, SPLAT_ATOMIC_TEST1_NAME, - "Final value %lu does not match initial value %lu\n", - (long unsigned)ap.ap_atomic, SPLAT_ATOMIC_INIT_VALUE); - return -EINVAL; - } - - splat_vprint(file, SPLAT_ATOMIC_TEST1_NAME, - "Success initial and final values match, %lu == %lu\n", - (long unsigned)ap.ap_atomic, SPLAT_ATOMIC_INIT_VALUE); - - mutex_destroy(&ap.ap_lock); - - return 0; -} - -splat_subsystem_t * -splat_atomic_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_ATOMIC_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_ATOMIC_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_ATOMIC; - - splat_test_init(sub, SPLAT_ATOMIC_TEST1_NAME, SPLAT_ATOMIC_TEST1_DESC, - SPLAT_ATOMIC_TEST1_ID, splat_atomic_test1); - - return sub; -} - -void -splat_atomic_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - splat_test_fini(sub, SPLAT_ATOMIC_TEST1_ID); - - kfree(sub); -} - -int -splat_atomic_id(void) { - return SPLAT_SUBSYSTEM_ATOMIC; -} diff --git a/module/splat/splat-condvar.c b/module/splat/splat-condvar.c deleted file mode 100644 index 0804baf50..000000000 --- a/module/splat/splat-condvar.c +++ /dev/null @@ -1,511 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Condition Variable Tests. - */ - -#include -#include -#include -#include "splat-internal.h" - -#define SPLAT_CONDVAR_NAME "condvar" -#define SPLAT_CONDVAR_DESC "Kernel Condition Variable Tests" - -#define SPLAT_CONDVAR_TEST1_ID 0x0501 -#define SPLAT_CONDVAR_TEST1_NAME "signal1" -#define SPLAT_CONDVAR_TEST1_DESC "Wake a single thread, cv_wait()/cv_signal()" - -#define SPLAT_CONDVAR_TEST2_ID 0x0502 -#define SPLAT_CONDVAR_TEST2_NAME "broadcast1" -#define SPLAT_CONDVAR_TEST2_DESC "Wake all threads, cv_wait()/cv_broadcast()" - -#define SPLAT_CONDVAR_TEST3_ID 0x0503 -#define SPLAT_CONDVAR_TEST3_NAME "signal2" -#define SPLAT_CONDVAR_TEST3_DESC "Wake a single thread, cv_wait_timeout()/cv_signal()" - -#define SPLAT_CONDVAR_TEST4_ID 0x0504 -#define SPLAT_CONDVAR_TEST4_NAME "broadcast2" -#define SPLAT_CONDVAR_TEST4_DESC "Wake all threads, cv_wait_timeout()/cv_broadcast()" - -#define SPLAT_CONDVAR_TEST5_ID 0x0505 -#define SPLAT_CONDVAR_TEST5_NAME "timeout" -#define SPLAT_CONDVAR_TEST5_DESC "Timeout thread, cv_wait_timeout()" - -#define SPLAT_CONDVAR_TEST_MAGIC 0x115599DDUL -#define SPLAT_CONDVAR_TEST_NAME "condvar" -#define SPLAT_CONDVAR_TEST_COUNT 8 - -typedef struct condvar_priv { - unsigned long cv_magic; - struct file *cv_file; - kcondvar_t cv_condvar; - kmutex_t cv_mtx; -} condvar_priv_t; - -typedef struct condvar_thr { - const char *ct_name; - condvar_priv_t *ct_cvp; - struct task_struct *ct_thread; - int ct_rc; -} condvar_thr_t; - -int -splat_condvar_test12_thread(void *arg) -{ - condvar_thr_t *ct = (condvar_thr_t *)arg; - condvar_priv_t *cv = ct->ct_cvp; - - ASSERT(cv->cv_magic == SPLAT_CONDVAR_TEST_MAGIC); - - mutex_enter(&cv->cv_mtx); - splat_vprint(cv->cv_file, ct->ct_name, - "%s thread sleeping with %d waiters\n", - ct->ct_thread->comm, atomic_read(&cv->cv_condvar.cv_waiters)); - cv_wait(&cv->cv_condvar, &cv->cv_mtx); - splat_vprint(cv->cv_file, ct->ct_name, - "%s thread woken %d waiters remain\n", - ct->ct_thread->comm, atomic_read(&cv->cv_condvar.cv_waiters)); - mutex_exit(&cv->cv_mtx); - - /* wait for main thread reap us */ - while (!kthread_should_stop()) - schedule(); - return 0; -} - -static int -splat_condvar_test1(struct file *file, void *arg) -{ - int i, count = 0, rc = 0; - condvar_thr_t ct[SPLAT_CONDVAR_TEST_COUNT]; - condvar_priv_t cv; - - cv.cv_magic = SPLAT_CONDVAR_TEST_MAGIC; - cv.cv_file = file; - mutex_init(&cv.cv_mtx, SPLAT_CONDVAR_TEST_NAME, MUTEX_DEFAULT, NULL); - cv_init(&cv.cv_condvar, NULL, CV_DEFAULT, NULL); - - /* Create some threads, the exact number isn't important just as - * long as we know how many we managed to create and should expect. */ - for (i = 0; i < SPLAT_CONDVAR_TEST_COUNT; i++) { - ct[i].ct_cvp = &cv; - ct[i].ct_name = SPLAT_CONDVAR_TEST1_NAME; - ct[i].ct_rc = 0; - ct[i].ct_thread = spl_kthread_create(splat_condvar_test12_thread, - &ct[i], "%s/%d", SPLAT_CONDVAR_TEST_NAME, i); - - if (!IS_ERR(ct[i].ct_thread)) { - wake_up_process(ct[i].ct_thread); - count++; - } - } - - /* Wait until all threads are waiting on the condition variable */ - while (atomic_read(&cv.cv_condvar.cv_waiters) != count) - schedule(); - - /* Wake a single thread at a time, wait until it exits */ - for (i = 1; i <= count; i++) { - cv_signal(&cv.cv_condvar); - - while (atomic_read(&cv.cv_condvar.cv_waiters) > (count - i)) - schedule(); - - /* Correct behavior 1 thread woken */ - if (atomic_read(&cv.cv_condvar.cv_waiters) == (count - i)) - continue; - - splat_vprint(file, SPLAT_CONDVAR_TEST1_NAME, "Attempted to " - "wake %d thread but work %d threads woke\n", - 1, count - atomic_read(&cv.cv_condvar.cv_waiters)); - rc = -EINVAL; - break; - } - - if (!rc) - splat_vprint(file, SPLAT_CONDVAR_TEST1_NAME, "Correctly woke " - "%d sleeping threads %d at a time\n", count, 1); - - /* Wait until that last nutex is dropped */ - while (mutex_owner(&cv.cv_mtx)) - schedule(); - - /* Wake everything for the failure case */ - cv_broadcast(&cv.cv_condvar); - cv_destroy(&cv.cv_condvar); - - /* wait for threads to exit */ - for (i = 0; i < SPLAT_CONDVAR_TEST_COUNT; i++) { - if (!IS_ERR(ct[i].ct_thread)) - kthread_stop(ct[i].ct_thread); - } - mutex_destroy(&cv.cv_mtx); - - return rc; -} - -static int -splat_condvar_test2(struct file *file, void *arg) -{ - int i, count = 0, rc = 0; - condvar_thr_t ct[SPLAT_CONDVAR_TEST_COUNT]; - condvar_priv_t cv; - - cv.cv_magic = SPLAT_CONDVAR_TEST_MAGIC; - cv.cv_file = file; - mutex_init(&cv.cv_mtx, SPLAT_CONDVAR_TEST_NAME, MUTEX_DEFAULT, NULL); - cv_init(&cv.cv_condvar, NULL, CV_DEFAULT, NULL); - - /* Create some threads, the exact number isn't important just as - * long as we know how many we managed to create and should expect. */ - for (i = 0; i < SPLAT_CONDVAR_TEST_COUNT; i++) { - ct[i].ct_cvp = &cv; - ct[i].ct_name = SPLAT_CONDVAR_TEST2_NAME; - ct[i].ct_rc = 0; - ct[i].ct_thread = spl_kthread_create(splat_condvar_test12_thread, - &ct[i], "%s/%d", SPLAT_CONDVAR_TEST_NAME, i); - - if (!IS_ERR(ct[i].ct_thread)) { - wake_up_process(ct[i].ct_thread); - count++; - } - } - - /* Wait until all threads are waiting on the condition variable */ - while (atomic_read(&cv.cv_condvar.cv_waiters) != count) - schedule(); - - /* Wake all threads waiting on the condition variable */ - cv_broadcast(&cv.cv_condvar); - - /* Wait until all threads have exited */ - while ((atomic_read(&cv.cv_condvar.cv_waiters) > 0) || mutex_owner(&cv.cv_mtx)) - schedule(); - - splat_vprint(file, SPLAT_CONDVAR_TEST2_NAME, "Correctly woke all " - "%d sleeping threads at once\n", count); - - /* Wake everything for the failure case */ - cv_destroy(&cv.cv_condvar); - - /* wait for threads to exit */ - for (i = 0; i < SPLAT_CONDVAR_TEST_COUNT; i++) { - if (!IS_ERR(ct[i].ct_thread)) - kthread_stop(ct[i].ct_thread); - } - mutex_destroy(&cv.cv_mtx); - - return rc; -} - -int -splat_condvar_test34_thread(void *arg) -{ - condvar_thr_t *ct = (condvar_thr_t *)arg; - condvar_priv_t *cv = ct->ct_cvp; - clock_t rc; - - ASSERT(cv->cv_magic == SPLAT_CONDVAR_TEST_MAGIC); - - mutex_enter(&cv->cv_mtx); - splat_vprint(cv->cv_file, ct->ct_name, - "%s thread sleeping with %d waiters\n", - ct->ct_thread->comm, atomic_read(&cv->cv_condvar.cv_waiters)); - - /* Sleep no longer than 3 seconds, for this test we should - * actually never sleep that long without being woken up. */ - rc = cv_timedwait(&cv->cv_condvar, &cv->cv_mtx, lbolt + HZ * 3); - if (rc == -1) { - ct->ct_rc = -ETIMEDOUT; - splat_vprint(cv->cv_file, ct->ct_name, "%s thread timed out, " - "should have been woken\n", ct->ct_thread->comm); - } else { - splat_vprint(cv->cv_file, ct->ct_name, - "%s thread woken %d waiters remain\n", - ct->ct_thread->comm, - atomic_read(&cv->cv_condvar.cv_waiters)); - } - - mutex_exit(&cv->cv_mtx); - - /* wait for main thread reap us */ - while (!kthread_should_stop()) - schedule(); - return 0; -} - -static int -splat_condvar_test3(struct file *file, void *arg) -{ - int i, count = 0, rc = 0; - condvar_thr_t ct[SPLAT_CONDVAR_TEST_COUNT]; - condvar_priv_t cv; - - cv.cv_magic = SPLAT_CONDVAR_TEST_MAGIC; - cv.cv_file = file; - mutex_init(&cv.cv_mtx, SPLAT_CONDVAR_TEST_NAME, MUTEX_DEFAULT, NULL); - cv_init(&cv.cv_condvar, NULL, CV_DEFAULT, NULL); - - /* Create some threads, the exact number isn't important just as - * long as we know how many we managed to create and should expect. */ - for (i = 0; i < SPLAT_CONDVAR_TEST_COUNT; i++) { - ct[i].ct_cvp = &cv; - ct[i].ct_name = SPLAT_CONDVAR_TEST3_NAME; - ct[i].ct_rc = 0; - ct[i].ct_thread = spl_kthread_create(splat_condvar_test34_thread, - &ct[i], "%s/%d", SPLAT_CONDVAR_TEST_NAME, i); - - if (!IS_ERR(ct[i].ct_thread)) { - wake_up_process(ct[i].ct_thread); - count++; - } - } - - /* Wait until all threads are waiting on the condition variable */ - while (atomic_read(&cv.cv_condvar.cv_waiters) != count) - schedule(); - - /* Wake a single thread at a time, wait until it exits */ - for (i = 1; i <= count; i++) { - cv_signal(&cv.cv_condvar); - - while (atomic_read(&cv.cv_condvar.cv_waiters) > (count - i)) - schedule(); - - /* Correct behavior 1 thread woken */ - if (atomic_read(&cv.cv_condvar.cv_waiters) == (count - i)) - continue; - - splat_vprint(file, SPLAT_CONDVAR_TEST3_NAME, "Attempted to " - "wake %d thread but work %d threads woke\n", - 1, count - atomic_read(&cv.cv_condvar.cv_waiters)); - rc = -EINVAL; - break; - } - - /* Validate no waiting thread timed out early */ - for (i = 0; i < count; i++) - if (ct[i].ct_rc) - rc = ct[i].ct_rc; - - if (!rc) - splat_vprint(file, SPLAT_CONDVAR_TEST3_NAME, "Correctly woke " - "%d sleeping threads %d at a time\n", count, 1); - - /* Wait until that last nutex is dropped */ - while (mutex_owner(&cv.cv_mtx)) - schedule(); - - /* Wake everything for the failure case */ - cv_broadcast(&cv.cv_condvar); - cv_destroy(&cv.cv_condvar); - - /* wait for threads to exit */ - for (i = 0; i < SPLAT_CONDVAR_TEST_COUNT; i++) { - if (!IS_ERR(ct[i].ct_thread)) - kthread_stop(ct[i].ct_thread); - } - mutex_destroy(&cv.cv_mtx); - - return rc; -} - -static int -splat_condvar_test4(struct file *file, void *arg) -{ - int i, count = 0, rc = 0; - condvar_thr_t ct[SPLAT_CONDVAR_TEST_COUNT]; - condvar_priv_t cv; - - cv.cv_magic = SPLAT_CONDVAR_TEST_MAGIC; - cv.cv_file = file; - mutex_init(&cv.cv_mtx, SPLAT_CONDVAR_TEST_NAME, MUTEX_DEFAULT, NULL); - cv_init(&cv.cv_condvar, NULL, CV_DEFAULT, NULL); - - /* Create some threads, the exact number isn't important just as - * long as we know how many we managed to create and should expect. */ - for (i = 0; i < SPLAT_CONDVAR_TEST_COUNT; i++) { - ct[i].ct_cvp = &cv; - ct[i].ct_name = SPLAT_CONDVAR_TEST3_NAME; - ct[i].ct_rc = 0; - ct[i].ct_thread = spl_kthread_create(splat_condvar_test34_thread, - &ct[i], "%s/%d", SPLAT_CONDVAR_TEST_NAME, i); - - if (!IS_ERR(ct[i].ct_thread)) { - wake_up_process(ct[i].ct_thread); - count++; - } - } - - /* Wait until all threads are waiting on the condition variable */ - while (atomic_read(&cv.cv_condvar.cv_waiters) != count) - schedule(); - - /* Wake a single thread at a time, wait until it exits */ - for (i = 1; i <= count; i++) { - cv_signal(&cv.cv_condvar); - - while (atomic_read(&cv.cv_condvar.cv_waiters) > (count - i)) - schedule(); - - /* Correct behavior 1 thread woken */ - if (atomic_read(&cv.cv_condvar.cv_waiters) == (count - i)) - continue; - - splat_vprint(file, SPLAT_CONDVAR_TEST3_NAME, "Attempted to " - "wake %d thread but work %d threads woke\n", - 1, count - atomic_read(&cv.cv_condvar.cv_waiters)); - rc = -EINVAL; - break; - } - - /* Validate no waiting thread timed out early */ - for (i = 0; i < count; i++) - if (ct[i].ct_rc) - rc = ct[i].ct_rc; - - if (!rc) - splat_vprint(file, SPLAT_CONDVAR_TEST3_NAME, "Correctly woke " - "%d sleeping threads %d at a time\n", count, 1); - - /* Wait until that last nutex is dropped */ - while (mutex_owner(&cv.cv_mtx)) - schedule(); - - /* Wake everything for the failure case */ - cv_broadcast(&cv.cv_condvar); - cv_destroy(&cv.cv_condvar); - - /* wait for threads to exit */ - for (i = 0; i < SPLAT_CONDVAR_TEST_COUNT; i++) { - if (!IS_ERR(ct[i].ct_thread)) - kthread_stop(ct[i].ct_thread); - } - mutex_destroy(&cv.cv_mtx); - - return rc; -} - -static int -splat_condvar_test5(struct file *file, void *arg) -{ - kcondvar_t condvar; - kmutex_t mtx; - clock_t time_left, time_before, time_after, time_delta; - uint64_t whole_delta; - uint32_t remain_delta; - int rc = 0; - - mutex_init(&mtx, SPLAT_CONDVAR_TEST_NAME, MUTEX_DEFAULT, NULL); - cv_init(&condvar, NULL, CV_DEFAULT, NULL); - - splat_vprint(file, SPLAT_CONDVAR_TEST5_NAME, "Thread going to sleep for " - "%d second and expecting to be woken by timeout\n", 1); - - /* Allow a 1 second timeout, plenty long to validate correctness. */ - time_before = lbolt; - mutex_enter(&mtx); - time_left = cv_timedwait(&condvar, &mtx, lbolt + HZ); - mutex_exit(&mtx); - time_after = lbolt; - time_delta = time_after - time_before; /* XXX - Handle jiffie wrap */ - whole_delta = time_delta; - remain_delta = do_div(whole_delta, HZ); - - if (time_left == -1) { - if (time_delta >= HZ) { - splat_vprint(file, SPLAT_CONDVAR_TEST5_NAME, - "Thread correctly timed out and was asleep " - "for %d.%d seconds (%d second min)\n", - (int)whole_delta, (int)remain_delta, 1); - } else { - splat_vprint(file, SPLAT_CONDVAR_TEST5_NAME, - "Thread correctly timed out but was only " - "asleep for %d.%d seconds (%d second " - "min)\n", (int)whole_delta, - (int)remain_delta, 1); - rc = -ETIMEDOUT; - } - } else { - splat_vprint(file, SPLAT_CONDVAR_TEST5_NAME, - "Thread exited after only %d.%d seconds, it " - "did not hit the %d second timeout\n", - (int)whole_delta, (int)remain_delta, 1); - rc = -ETIMEDOUT; - } - - cv_destroy(&condvar); - mutex_destroy(&mtx); - - return rc; -} - -splat_subsystem_t * -splat_condvar_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_CONDVAR_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_CONDVAR_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_CONDVAR; - - splat_test_init(sub, SPLAT_CONDVAR_TEST1_NAME, SPLAT_CONDVAR_TEST1_DESC, - SPLAT_CONDVAR_TEST1_ID, splat_condvar_test1); - splat_test_init(sub, SPLAT_CONDVAR_TEST2_NAME, SPLAT_CONDVAR_TEST2_DESC, - SPLAT_CONDVAR_TEST2_ID, splat_condvar_test2); - splat_test_init(sub, SPLAT_CONDVAR_TEST3_NAME, SPLAT_CONDVAR_TEST3_DESC, - SPLAT_CONDVAR_TEST3_ID, splat_condvar_test3); - splat_test_init(sub, SPLAT_CONDVAR_TEST4_NAME, SPLAT_CONDVAR_TEST4_DESC, - SPLAT_CONDVAR_TEST4_ID, splat_condvar_test4); - splat_test_init(sub, SPLAT_CONDVAR_TEST5_NAME, SPLAT_CONDVAR_TEST5_DESC, - SPLAT_CONDVAR_TEST5_ID, splat_condvar_test5); - - return sub; -} - -void -splat_condvar_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - splat_test_fini(sub, SPLAT_CONDVAR_TEST5_ID); - splat_test_fini(sub, SPLAT_CONDVAR_TEST4_ID); - splat_test_fini(sub, SPLAT_CONDVAR_TEST3_ID); - splat_test_fini(sub, SPLAT_CONDVAR_TEST2_ID); - splat_test_fini(sub, SPLAT_CONDVAR_TEST1_ID); - - kfree(sub); -} - -int -splat_condvar_id(void) { - return SPLAT_SUBSYSTEM_CONDVAR; -} diff --git a/module/splat/splat-cred.c b/module/splat/splat-cred.c deleted file mode 100644 index f13c0f752..000000000 --- a/module/splat/splat-cred.c +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Credential Tests. - */ - -#include -#include -#include "splat-internal.h" - -#define SPLAT_CRED_NAME "cred" -#define SPLAT_CRED_DESC "Kernel Cred Tests" - -#define SPLAT_CRED_TEST1_ID 0x0e01 -#define SPLAT_CRED_TEST1_NAME "cred" -#define SPLAT_CRED_TEST1_DESC "Task Credential Test" - -#define SPLAT_CRED_TEST2_ID 0x0e02 -#define SPLAT_CRED_TEST2_NAME "kcred" -#define SPLAT_CRED_TEST2_DESC "Kernel Credential Test" - -#define SPLAT_CRED_TEST3_ID 0x0e03 -#define SPLAT_CRED_TEST3_NAME "groupmember" -#define SPLAT_CRED_TEST3_DESC "Group Member Test" - -#define GROUP_STR_SIZE 128 -#define GROUP_STR_REDZONE 16 - -static int -splat_cred_test1(struct file *file, void *arg) -{ - char str[GROUP_STR_SIZE]; - uid_t uid, ruid, suid; - gid_t gid, rgid, sgid, *groups; - int ngroups, i, count = 0; - cred_t *cr = CRED(); - - uid = crgetuid(cr); - ruid = crgetruid(cr); - suid = crgetsuid(cr); - - gid = crgetgid(cr); - rgid = crgetrgid(cr); - sgid = crgetsgid(cr); - - ngroups = crgetngroups(cr); - groups = crgetgroups(cr); - - memset(str, 0, GROUP_STR_SIZE); - for (i = 0; i < ngroups; i++) { - count += sprintf(str + count, "%d ", groups[i]); - - if (count > (GROUP_STR_SIZE - GROUP_STR_REDZONE)) { - splat_vprint(file, SPLAT_CRED_TEST1_NAME, - "Failed too many group entries for temp " - "buffer: %d, %s\n", ngroups, str); - return -ENOSPC; - } - } - - splat_vprint(file, SPLAT_CRED_TEST1_NAME, - "uid: %d ruid: %d suid: %d " - "gid: %d rgid: %d sgid: %d\n", - uid, ruid, suid, gid, rgid, sgid); - splat_vprint(file, SPLAT_CRED_TEST1_NAME, - "ngroups: %d groups: %s\n", ngroups, str); - - if (uid || ruid || suid || gid || rgid || sgid) { - splat_vprint(file, SPLAT_CRED_TEST1_NAME, - "Failed expected all uids+gids to be %d\n", 0); - return -EIDRM; - } - - if (ngroups > NGROUPS_MAX) { - splat_vprint(file, SPLAT_CRED_TEST1_NAME, - "Failed ngroups must not exceed NGROUPS_MAX: " - "%d > %d\n", ngroups, NGROUPS_MAX); - return -EIDRM; - } - - splat_vprint(file, SPLAT_CRED_TEST1_NAME, - "Success sane CRED(): %d\n", 0); - - return 0; -} /* splat_cred_test1() */ - -static int -splat_cred_test2(struct file *file, void *arg) -{ - char str[GROUP_STR_SIZE]; - uid_t uid, ruid, suid; - gid_t gid, rgid, sgid, *groups; - int ngroups, i, count = 0; - - crhold(kcred); - - uid = crgetuid(kcred); - ruid = crgetruid(kcred); - suid = crgetsuid(kcred); - - gid = crgetgid(kcred); - rgid = crgetrgid(kcred); - sgid = crgetsgid(kcred); - - ngroups = crgetngroups(kcred); - groups = crgetgroups(kcred); - - memset(str, 0, GROUP_STR_SIZE); - for (i = 0; i < ngroups; i++) { - count += sprintf(str + count, "%d ", groups[i]); - - if (count > (GROUP_STR_SIZE - GROUP_STR_REDZONE)) { - splat_vprint(file, SPLAT_CRED_TEST2_NAME, - "Failed too many group entries for temp " - "buffer: %d, %s\n", ngroups, str); - crfree(kcred); - return -ENOSPC; - } - } - - crfree(kcred); - - splat_vprint(file, SPLAT_CRED_TEST2_NAME, - "uid: %d ruid: %d suid: %d " - "gid: %d rgid: %d sgid: %d\n", - uid, ruid, suid, gid, rgid, sgid); - splat_vprint(file, SPLAT_CRED_TEST2_NAME, - "ngroups: %d groups: %s\n", ngroups, str); - - if (uid || ruid || suid || gid || rgid || sgid) { - splat_vprint(file, SPLAT_CRED_TEST2_NAME, - "Failed expected all uids+gids to be %d\n", 0); - return -EIDRM; - } - - if (ngroups > NGROUPS_MAX) { - splat_vprint(file, SPLAT_CRED_TEST2_NAME, - "Failed ngroups must not exceed NGROUPS_MAX: " - "%d > %d\n", ngroups, NGROUPS_MAX); - return -EIDRM; - } - - splat_vprint(file, SPLAT_CRED_TEST2_NAME, - "Success sane kcred: %d\n", 0); - - return 0; -} /* splat_cred_test2() */ - -#define SPLAT_NGROUPS 32 -/* - * Verify the groupmember() works correctly by constructing an interesting - * CRED() and checking that the expected gids are part of it. - */ -static int -splat_cred_test3(struct file *file, void *arg) -{ - gid_t known_gid, missing_gid, tmp_gid; - unsigned char rnd; - struct group_info *gi; - int i, rc; - - get_random_bytes((void *)&rnd, 1); - known_gid = (rnd > 0) ? rnd : 1; - missing_gid = 0; - - /* - * Create an interesting known set of gids for test purposes. The - * gids are pseudo randomly selected are will be in the range of - * 1:(NGROUPS_MAX-1). Gid 0 is explicitly avoided so we can reliably - * test for its absence in the test cases. - */ - gi = groups_alloc(SPLAT_NGROUPS); - if (gi == NULL) { - splat_vprint(file, SPLAT_CRED_TEST3_NAME, "Failed create " - "group_info for known gids: %d\n", -ENOMEM); - rc = -ENOMEM; - goto show_groups; - } - - for (i = 0, tmp_gid = known_gid; i < SPLAT_NGROUPS; i++) { - splat_vprint(file, SPLAT_CRED_TEST3_NAME, "Adding gid %d " - "to current CRED() (%d/%d)\n", tmp_gid, i, gi->ngroups); -#ifdef HAVE_KUIDGID_T - GROUP_AT(gi, i) = make_kgid(current_user_ns(), tmp_gid); -#else - GROUP_AT(gi, i) = tmp_gid; -#endif /* HAVE_KUIDGID_T */ - tmp_gid = ((tmp_gid * 17) % (NGROUPS_MAX - 1)) + 1; - } - - /* Set the new groups in the CRED() and release our reference. */ - rc = set_current_groups(gi); - put_group_info(gi); - - if (rc) { - splat_vprint(file, SPLAT_CRED_TEST3_NAME, "Failed to add " - "gid %d to current group: %d\n", known_gid, rc); - goto show_groups; - } - - /* Verify groupmember() finds the known_gid in the CRED() */ - rc = groupmember(known_gid, CRED()); - if (!rc) { - splat_vprint(file, SPLAT_CRED_TEST3_NAME, "Failed to find " - "known gid %d in CRED()'s groups.\n", known_gid); - rc = -EIDRM; - goto show_groups; - } - - /* Verify groupmember() does NOT finds the missing gid in the CRED() */ - rc = groupmember(missing_gid, CRED()); - if (rc) { - splat_vprint(file, SPLAT_CRED_TEST3_NAME, "Failed missing " - "gid %d was found in CRED()'s groups.\n", missing_gid); - rc = -EIDRM; - goto show_groups; - } - - splat_vprint(file, SPLAT_CRED_TEST3_NAME, "Success groupmember() " - "correctly detects expected gids in CRED(): %d\n", rc); - -show_groups: - if (rc) { - int i, grps = crgetngroups(CRED()); - - splat_vprint(file, SPLAT_CRED_TEST3_NAME, "%d groups: ", grps); - for (i = 0; i < grps; i++) - splat_print(file, "%d ", crgetgroups(CRED())[i]); - splat_print(file, "%s", "\n"); - } - - - return (rc); -} /* splat_cred_test3() */ - -splat_subsystem_t * -splat_cred_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_CRED_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_CRED_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_CRED; - - splat_test_init(sub, SPLAT_CRED_TEST1_NAME, SPLAT_CRED_TEST1_DESC, - SPLAT_CRED_TEST1_ID, splat_cred_test1); - splat_test_init(sub, SPLAT_CRED_TEST2_NAME, SPLAT_CRED_TEST2_DESC, - SPLAT_CRED_TEST2_ID, splat_cred_test2); - splat_test_init(sub, SPLAT_CRED_TEST3_NAME, SPLAT_CRED_TEST3_DESC, - SPLAT_CRED_TEST3_ID, splat_cred_test3); - - return sub; -} /* splat_cred_init() */ - -void -splat_cred_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - - splat_test_fini(sub, SPLAT_CRED_TEST3_ID); - splat_test_fini(sub, SPLAT_CRED_TEST2_ID); - splat_test_fini(sub, SPLAT_CRED_TEST1_ID); - - kfree(sub); -} /* splat_cred_fini() */ - -int -splat_cred_id(void) -{ - return SPLAT_SUBSYSTEM_CRED; -} /* splat_cred_id() */ diff --git a/module/splat/splat-ctl.c b/module/splat/splat-ctl.c deleted file mode 100644 index cf6850100..000000000 --- a/module/splat/splat-ctl.c +++ /dev/null @@ -1,753 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Test Control Interface. - * - * The 'splat' (Solaris Porting LAyer Tests) module is designed as a - * framework which runs various in kernel regression tests to validate - * the SPL primitives honor the Solaris ABI. - * - * The splat module is constructed of various splat_* source files each - * of which contain regression tests for a particular subsystem. For - * example, the splat_kmem.c file contains all the tests for validating - * the kmem interfaces have been implemented correctly. When the splat - * module is loaded splat_*_init() will be called for each subsystems - * tests. It is the responsibility of splat_*_init() to register all - * the tests for this subsystem using the splat_test_init(). - * Similarly splat_*_fini() is called when the splat module is removed - * and is responsible for unregistering its tests via the splat_test_fini. - * Once a test is registered it can then be run with an ioctl() - * call which specifies the subsystem and test to be run. The provided - * splat command line tool can be used to display all available - * subsystems and tests. It can also be used to run the full suite - * of regression tests or particular tests. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "splat-internal.h" - -static struct list_head splat_module_list; -static spinlock_t splat_module_lock; - -static int -splat_open(struct inode *inode, struct file *file) -{ - splat_info_t *info; - - info = (splat_info_t *)kmalloc(sizeof(*info), GFP_KERNEL); - if (info == NULL) - return -ENOMEM; - - mutex_init(&info->info_lock, SPLAT_NAME, MUTEX_DEFAULT, NULL); - info->info_size = SPLAT_INFO_BUFFER_SIZE; - info->info_buffer = (char *)vmalloc(SPLAT_INFO_BUFFER_SIZE); - if (info->info_buffer == NULL) { - kfree(info); - return -ENOMEM; - } - memset(info->info_buffer, 0, info->info_size); - - info->info_head = info->info_buffer; - file->private_data = (void *)info; - - splat_print(file, "%s\n", spl_version); - - return 0; -} - -static int -splat_release(struct inode *inode, struct file *file) -{ - splat_info_t *info = (splat_info_t *)file->private_data; - - ASSERT(info); - ASSERT(info->info_buffer); - - mutex_destroy(&info->info_lock); - vfree(info->info_buffer); - kfree(info); - - return 0; -} - -static int -splat_buffer_clear(struct file *file, splat_cfg_t *kcfg, unsigned long arg) -{ - splat_info_t *info = (splat_info_t *)file->private_data; - - ASSERT(info); - ASSERT(info->info_buffer); - - mutex_enter(&info->info_lock); - memset(info->info_buffer, 0, info->info_size); - info->info_head = info->info_buffer; - mutex_exit(&info->info_lock); - - return 0; -} - -static int -splat_buffer_size(struct file *file, splat_cfg_t *kcfg, unsigned long arg) -{ - splat_info_t *info = (splat_info_t *)file->private_data; - char *buf; - int min, size, rc = 0; - - ASSERT(info); - ASSERT(info->info_buffer); - - mutex_enter(&info->info_lock); - if (kcfg->cfg_arg1 > 0) { - - size = kcfg->cfg_arg1; - buf = (char *)vmalloc(size); - if (buf == NULL) { - rc = -ENOMEM; - goto out; - } - - /* Zero fill and truncate contents when coping buffer */ - min = ((size < info->info_size) ? size : info->info_size); - memset(buf, 0, size); - memcpy(buf, info->info_buffer, min); - vfree(info->info_buffer); - info->info_size = size; - info->info_buffer = buf; - info->info_head = info->info_buffer; - } - - kcfg->cfg_rc1 = info->info_size; - - if (copy_to_user((struct splat_cfg_t __user *)arg, kcfg, sizeof(*kcfg))) - rc = -EFAULT; -out: - mutex_exit(&info->info_lock); - - return rc; -} - - -static splat_subsystem_t * -splat_subsystem_find(int id) { - splat_subsystem_t *sub; - - spin_lock(&splat_module_lock); - list_for_each_entry(sub, &splat_module_list, subsystem_list) { - if (id == sub->desc.id) { - spin_unlock(&splat_module_lock); - return sub; - } - } - spin_unlock(&splat_module_lock); - - return NULL; -} - -static int -splat_subsystem_count(splat_cfg_t *kcfg, unsigned long arg) -{ - splat_subsystem_t *sub; - int i = 0; - - spin_lock(&splat_module_lock); - list_for_each_entry(sub, &splat_module_list, subsystem_list) - i++; - - spin_unlock(&splat_module_lock); - kcfg->cfg_rc1 = i; - - if (copy_to_user((struct splat_cfg_t __user *)arg, kcfg, sizeof(*kcfg))) - return -EFAULT; - - return 0; -} - -static int -splat_subsystem_list(splat_cfg_t *kcfg, unsigned long arg) -{ - splat_subsystem_t *sub; - splat_cfg_t *tmp; - int size, i = 0; - - /* Structure will be sized large enough for N subsystem entries - * which is passed in by the caller. On exit the number of - * entries filled in with valid subsystems will be stored in - * cfg_rc1. If the caller does not provide enough entries - * for all subsystems we will truncate the list to avoid overrun. - */ - size = sizeof(*tmp) + kcfg->cfg_data.splat_subsystems.size * - sizeof(splat_user_t); - tmp = kmalloc(size, GFP_KERNEL); - if (tmp == NULL) - return -ENOMEM; - - /* Local 'tmp' is used as the structure copied back to user space */ - memset(tmp, 0, size); - memcpy(tmp, kcfg, sizeof(*kcfg)); - - spin_lock(&splat_module_lock); - list_for_each_entry(sub, &splat_module_list, subsystem_list) { - strncpy(tmp->cfg_data.splat_subsystems.descs[i].name, - sub->desc.name, SPLAT_NAME_SIZE); - strncpy(tmp->cfg_data.splat_subsystems.descs[i].desc, - sub->desc.desc, SPLAT_DESC_SIZE); - tmp->cfg_data.splat_subsystems.descs[i].id = sub->desc.id; - - /* Truncate list if we are about to overrun alloc'ed memory */ - if ((i++) == kcfg->cfg_data.splat_subsystems.size) - break; - } - spin_unlock(&splat_module_lock); - tmp->cfg_rc1 = i; - - if (copy_to_user((struct splat_cfg_t __user *)arg, tmp, size)) { - kfree(tmp); - return -EFAULT; - } - - kfree(tmp); - return 0; -} - -static int -splat_test_count(splat_cfg_t *kcfg, unsigned long arg) -{ - splat_subsystem_t *sub; - splat_test_t *test; - int i = 0; - - /* Subsystem ID passed as arg1 */ - sub = splat_subsystem_find(kcfg->cfg_arg1); - if (sub == NULL) - return -EINVAL; - - spin_lock(&(sub->test_lock)); - list_for_each_entry(test, &(sub->test_list), test_list) - i++; - - spin_unlock(&(sub->test_lock)); - kcfg->cfg_rc1 = i; - - if (copy_to_user((struct splat_cfg_t __user *)arg, kcfg, sizeof(*kcfg))) - return -EFAULT; - - return 0; -} - -static int -splat_test_list(splat_cfg_t *kcfg, unsigned long arg) -{ - splat_subsystem_t *sub; - splat_test_t *test; - splat_cfg_t *tmp; - int size, i = 0; - - /* Subsystem ID passed as arg1 */ - sub = splat_subsystem_find(kcfg->cfg_arg1); - if (sub == NULL) - return -EINVAL; - - /* Structure will be sized large enough for N test entries - * which is passed in by the caller. On exit the number of - * entries filled in with valid tests will be stored in - * cfg_rc1. If the caller does not provide enough entries - * for all tests we will truncate the list to avoid overrun. - */ - size = sizeof(*tmp)+kcfg->cfg_data.splat_tests.size*sizeof(splat_user_t); - tmp = kmalloc(size, GFP_KERNEL); - if (tmp == NULL) - return -ENOMEM; - - /* Local 'tmp' is used as the structure copied back to user space */ - memset(tmp, 0, size); - memcpy(tmp, kcfg, sizeof(*kcfg)); - - spin_lock(&(sub->test_lock)); - list_for_each_entry(test, &(sub->test_list), test_list) { - strncpy(tmp->cfg_data.splat_tests.descs[i].name, - test->desc.name, SPLAT_NAME_SIZE); - strncpy(tmp->cfg_data.splat_tests.descs[i].desc, - test->desc.desc, SPLAT_DESC_SIZE); - tmp->cfg_data.splat_tests.descs[i].id = test->desc.id; - - /* Truncate list if we are about to overrun alloc'ed memory */ - if ((i++) == kcfg->cfg_data.splat_tests.size) - break; - } - spin_unlock(&(sub->test_lock)); - tmp->cfg_rc1 = i; - - if (copy_to_user((struct splat_cfg_t __user *)arg, tmp, size)) { - kfree(tmp); - return -EFAULT; - } - - kfree(tmp); - return 0; -} - -static int -splat_validate(struct file *file, splat_subsystem_t *sub, int cmd, void *arg) -{ - splat_test_t *test; - - spin_lock(&(sub->test_lock)); - list_for_each_entry(test, &(sub->test_list), test_list) { - if (test->desc.id == cmd) { - spin_unlock(&(sub->test_lock)); - return test->test(file, arg); - } - } - spin_unlock(&(sub->test_lock)); - - return -EINVAL; -} - -static int -splat_ioctl_cfg(struct file *file, unsigned int cmd, unsigned long arg) -{ - splat_cfg_t kcfg; - int rc = 0; - - /* User and kernel space agree about arg size */ - if (_IOC_SIZE(cmd) != sizeof(kcfg)) - return -EBADMSG; - - if (copy_from_user(&kcfg, (splat_cfg_t *)arg, sizeof(kcfg))) - return -EFAULT; - - if (kcfg.cfg_magic != SPLAT_CFG_MAGIC) { - splat_print(file, "Bad config magic 0x%x != 0x%x\n", - kcfg.cfg_magic, SPLAT_CFG_MAGIC); - return -EINVAL; - } - - switch (kcfg.cfg_cmd) { - case SPLAT_CFG_BUFFER_CLEAR: - /* cfg_arg1 - Unused - * cfg_rc1 - Unused - */ - rc = splat_buffer_clear(file, &kcfg, arg); - break; - case SPLAT_CFG_BUFFER_SIZE: - /* cfg_arg1 - 0 - query size; >0 resize - * cfg_rc1 - Set to current buffer size - */ - rc = splat_buffer_size(file, &kcfg, arg); - break; - case SPLAT_CFG_SUBSYSTEM_COUNT: - /* cfg_arg1 - Unused - * cfg_rc1 - Set to number of subsystems - */ - rc = splat_subsystem_count(&kcfg, arg); - break; - case SPLAT_CFG_SUBSYSTEM_LIST: - /* cfg_arg1 - Unused - * cfg_rc1 - Set to number of subsystems - * cfg_data.splat_subsystems - Set with subsystems - */ - rc = splat_subsystem_list(&kcfg, arg); - break; - case SPLAT_CFG_TEST_COUNT: - /* cfg_arg1 - Set to a target subsystem - * cfg_rc1 - Set to number of tests - */ - rc = splat_test_count(&kcfg, arg); - break; - case SPLAT_CFG_TEST_LIST: - /* cfg_arg1 - Set to a target subsystem - * cfg_rc1 - Set to number of tests - * cfg_data.splat_subsystems - Populated with tests - */ - rc = splat_test_list(&kcfg, arg); - break; - default: - splat_print(file, "Bad config command %d\n", - kcfg.cfg_cmd); - rc = -EINVAL; - break; - } - - return rc; -} - -static int -splat_ioctl_cmd(struct file *file, unsigned int cmd, unsigned long arg) -{ - splat_subsystem_t *sub; - splat_cmd_t kcmd; - int rc = -EINVAL; - void *data = NULL; - - /* User and kernel space agree about arg size */ - if (_IOC_SIZE(cmd) != sizeof(kcmd)) - return -EBADMSG; - - if (copy_from_user(&kcmd, (splat_cfg_t *)arg, sizeof(kcmd))) - return -EFAULT; - - if (kcmd.cmd_magic != SPLAT_CMD_MAGIC) { - splat_print(file, "Bad command magic 0x%x != 0x%x\n", - kcmd.cmd_magic, SPLAT_CFG_MAGIC); - return -EINVAL; - } - - /* Allocate memory for any opaque data the caller needed to pass on */ - if (kcmd.cmd_data_size > 0) { - data = (void *)kmalloc(kcmd.cmd_data_size, GFP_KERNEL); - if (data == NULL) - return -ENOMEM; - - if (copy_from_user(data, (void *)(arg + offsetof(splat_cmd_t, - cmd_data_str)), kcmd.cmd_data_size)) { - kfree(data); - return -EFAULT; - } - } - - sub = splat_subsystem_find(kcmd.cmd_subsystem); - if (sub != NULL) - rc = splat_validate(file, sub, kcmd.cmd_test, data); - else - rc = -EINVAL; - - if (data != NULL) - kfree(data); - - return rc; -} - -static long -splat_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - int rc = 0; - - /* Ignore tty ioctls */ - if ((cmd & 0xffffff00) == ((int)'T') << 8) - return -ENOTTY; - - switch (cmd) { - case SPLAT_CFG: - rc = splat_ioctl_cfg(file, cmd, arg); - break; - case SPLAT_CMD: - rc = splat_ioctl_cmd(file, cmd, arg); - break; - default: - splat_print(file, "Bad ioctl command %d\n", cmd); - rc = -EINVAL; - break; - } - - return rc; -} - -#ifdef CONFIG_COMPAT -/* Compatibility handler for ioctls from 32-bit ELF binaries */ -static long -splat_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - return splat_unlocked_ioctl(file, cmd, arg); -} -#endif /* CONFIG_COMPAT */ - -/* I'm not sure why you would want to write in to this buffer from - * user space since its principle use is to pass test status info - * back to the user space, but I don't see any reason to prevent it. - */ -static ssize_t splat_write(struct file *file, const char __user *buf, - size_t count, loff_t *ppos) -{ - splat_info_t *info = (splat_info_t *)file->private_data; - int rc = 0; - - ASSERT(info); - ASSERT(info->info_buffer); - - mutex_enter(&info->info_lock); - - /* Write beyond EOF */ - if (*ppos >= info->info_size) { - rc = -EFBIG; - goto out; - } - - /* Resize count if beyond EOF */ - if (*ppos + count > info->info_size) - count = info->info_size - *ppos; - - if (copy_from_user(info->info_buffer, buf, count)) { - rc = -EFAULT; - goto out; - } - - *ppos += count; - rc = count; -out: - mutex_exit(&info->info_lock); - return rc; -} - -static ssize_t splat_read(struct file *file, char __user *buf, - size_t count, loff_t *ppos) -{ - splat_info_t *info = (splat_info_t *)file->private_data; - int rc = 0; - - ASSERT(info); - ASSERT(info->info_buffer); - - mutex_enter(&info->info_lock); - - /* Read beyond EOF */ - if (*ppos >= info->info_size) - goto out; - - /* Resize count if beyond EOF */ - if (*ppos + count > info->info_size) - count = info->info_size - *ppos; - - if (copy_to_user(buf, info->info_buffer + *ppos, count)) { - rc = -EFAULT; - goto out; - } - - *ppos += count; - rc = count; -out: - mutex_exit(&info->info_lock); - return rc; -} - -static loff_t splat_seek(struct file *file, loff_t offset, int origin) -{ - splat_info_t *info = (splat_info_t *)file->private_data; - int rc = -EINVAL; - - ASSERT(info); - ASSERT(info->info_buffer); - - mutex_enter(&info->info_lock); - - switch (origin) { - case 0: /* SEEK_SET - No-op just do it */ - break; - case 1: /* SEEK_CUR - Seek from current */ - offset = file->f_pos + offset; - break; - case 2: /* SEEK_END - Seek from end */ - offset = info->info_size + offset; - break; - } - - if (offset >= 0) { - file->f_pos = offset; - file->f_version = 0; - rc = offset; - } - - mutex_exit(&info->info_lock); - - return rc; -} - -static struct file_operations splat_fops = { - .owner = THIS_MODULE, - .open = splat_open, - .release = splat_release, - .unlocked_ioctl = splat_unlocked_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = splat_compat_ioctl, -#endif - .read = splat_read, - .write = splat_write, - .llseek = splat_seek, -}; - -static struct miscdevice splat_misc = { - .minor = MISC_DYNAMIC_MINOR, - .name = SPLAT_NAME, - .fops = &splat_fops, -}; - -static void splat_subsystem_init(const char *name, - splat_subsystem_t *(*init)(void)) -{ - splat_subsystem_t *sub; - sub = init(); - if (sub == NULL) { - printk(KERN_ERR "splat: Error initializing: %s\n", name); - return; - } - spin_lock(&splat_module_lock); - list_add_tail(&sub->subsystem_list, &splat_module_list); - spin_unlock(&splat_module_lock); -} - -static void splat_subsystem_fini(const char *name, - int (*id_func)(void), void (*fini)(splat_subsystem_t *)) -{ - splat_subsystem_t *sub, *tmp; - int id, flag = 0; - - id = id_func(); - spin_lock(&splat_module_lock); - list_for_each_entry_safe(sub, tmp, &splat_module_list, subsystem_list) { - if (sub->desc.id == id) { - list_del_init(&sub->subsystem_list); - flag = 1; - break; - } - } - spin_unlock(&splat_module_lock); - if (flag == 0) - printk(KERN_ERR "splat: Error finalizing: %s\n", name); - else - fini(sub); -} - -#define SPLAT_SUBSYSTEM_INIT(type) \ - splat_subsystem_init(#type, splat_##type##_init) -#define SPLAT_SUBSYSTEM_FINI(type) \ - splat_subsystem_fini(#type, splat_##type##_id, splat_##type##_fini) - -void splat_test_init(splat_subsystem_t *sub, const char *name, - const char *desc, unsigned int tid, splat_test_func_t func) -{ - splat_test_t *test; - test = kmalloc(sizeof (splat_test_t), GFP_KERNEL); - if (test == NULL) { - printk(KERN_ERR "splat: Error initializing: %s/%u\n", - name, tid); - return; - } - memset(test, 0, sizeof (splat_test_t)); - strncpy(test->desc.name, name, SPLAT_NAME_SIZE-1); - strncpy(test->desc.desc, desc, SPLAT_DESC_SIZE-1); - test->desc.id = tid; - test->test = func; - INIT_LIST_HEAD(&test->test_list); - spin_lock(&sub->test_lock); - list_add_tail(&test->test_list, &sub->test_list); - spin_unlock(&sub->test_lock); -} - -void splat_test_fini(splat_subsystem_t *sub, unsigned int tid) -{ - splat_test_t *test, *tmp; - int flag = 0; - - spin_lock(&sub->test_lock); - list_for_each_entry_safe(test, tmp, &sub->test_list, test_list) { - if (test->desc.id == tid) { - list_del_init(&test->test_list); - kfree(test); - flag = 1; - break; - } - } - spin_unlock(&sub->test_lock); - - if (flag == 0) - printk(KERN_ERR "splat: Error finalizing: %u\n", tid); -} - -static int __init -splat_init(void) -{ - int error; - - spin_lock_init(&splat_module_lock); - INIT_LIST_HEAD(&splat_module_list); - - SPLAT_SUBSYSTEM_INIT(kmem); - SPLAT_SUBSYSTEM_INIT(taskq); - SPLAT_SUBSYSTEM_INIT(krng); - SPLAT_SUBSYSTEM_INIT(mutex); - SPLAT_SUBSYSTEM_INIT(condvar); - SPLAT_SUBSYSTEM_INIT(thread); - SPLAT_SUBSYSTEM_INIT(rwlock); - SPLAT_SUBSYSTEM_INIT(time); - SPLAT_SUBSYSTEM_INIT(vnode); - SPLAT_SUBSYSTEM_INIT(kobj); - SPLAT_SUBSYSTEM_INIT(atomic); - SPLAT_SUBSYSTEM_INIT(list); - SPLAT_SUBSYSTEM_INIT(generic); - SPLAT_SUBSYSTEM_INIT(cred); - SPLAT_SUBSYSTEM_INIT(zlib); - SPLAT_SUBSYSTEM_INIT(linux); - - error = misc_register(&splat_misc); - if (error) { - printk(KERN_INFO "SPLAT: misc_register() failed %d\n", error); - } else { - printk(KERN_INFO "SPLAT: Loaded module v%s-%s%s\n", - SPL_META_VERSION, SPL_META_RELEASE, SPL_DEBUG_STR); - } - - return (error); -} - -static void __exit -splat_fini(void) -{ - misc_deregister(&splat_misc); - - SPLAT_SUBSYSTEM_FINI(linux); - SPLAT_SUBSYSTEM_FINI(zlib); - SPLAT_SUBSYSTEM_FINI(cred); - SPLAT_SUBSYSTEM_FINI(generic); - SPLAT_SUBSYSTEM_FINI(list); - SPLAT_SUBSYSTEM_FINI(atomic); - SPLAT_SUBSYSTEM_FINI(kobj); - SPLAT_SUBSYSTEM_FINI(vnode); - SPLAT_SUBSYSTEM_FINI(time); - SPLAT_SUBSYSTEM_FINI(rwlock); - SPLAT_SUBSYSTEM_FINI(thread); - SPLAT_SUBSYSTEM_FINI(condvar); - SPLAT_SUBSYSTEM_FINI(mutex); - SPLAT_SUBSYSTEM_FINI(krng); - SPLAT_SUBSYSTEM_FINI(taskq); - SPLAT_SUBSYSTEM_FINI(kmem); - - ASSERT(list_empty(&splat_module_list)); - printk(KERN_INFO "SPLAT: Unloaded module v%s-%s%s\n", - SPL_META_VERSION, SPL_META_RELEASE, SPL_DEBUG_STR); -} - -module_init(splat_init); -module_exit(splat_fini); - -MODULE_DESCRIPTION("Solaris Porting LAyer Tests"); -MODULE_AUTHOR(SPL_META_AUTHOR); -MODULE_LICENSE(SPL_META_LICENSE); -MODULE_VERSION(SPL_META_VERSION "-" SPL_META_RELEASE); diff --git a/module/splat/splat-generic.c b/module/splat/splat-generic.c deleted file mode 100644 index e256c83f0..000000000 --- a/module/splat/splat-generic.c +++ /dev/null @@ -1,367 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Generic Tests. - */ - -#include -#include -#include "splat-internal.h" - -#define SPLAT_GENERIC_NAME "generic" -#define SPLAT_GENERIC_DESC "Kernel Generic Tests" - -#define SPLAT_GENERIC_TEST1_ID 0x0d01 -#define SPLAT_GENERIC_TEST1_NAME "ddi_strtoul" -#define SPLAT_GENERIC_TEST1_DESC "ddi_strtoul Test" - -#define SPLAT_GENERIC_TEST2_ID 0x0d02 -#define SPLAT_GENERIC_TEST2_NAME "ddi_strtol" -#define SPLAT_GENERIC_TEST2_DESC "ddi_strtol Test" - -#define SPLAT_GENERIC_TEST3_ID 0x0d03 -#define SPLAT_GENERIC_TEST3_NAME "ddi_strtoull" -#define SPLAT_GENERIC_TEST3_DESC "ddi_strtoull Test" - -#define SPLAT_GENERIC_TEST4_ID 0x0d04 -#define SPLAT_GENERIC_TEST4_NAME "ddi_strtoll" -#define SPLAT_GENERIC_TEST4_DESC "ddi_strtoll Test" - -# define SPLAT_GENERIC_TEST5_ID 0x0d05 -# define SPLAT_GENERIC_TEST5_NAME "udivdi3" -# define SPLAT_GENERIC_TEST5_DESC "Unsigned Div-64 Test" - -# define SPLAT_GENERIC_TEST6_ID 0x0d06 -# define SPLAT_GENERIC_TEST6_NAME "divdi3" -# define SPLAT_GENERIC_TEST6_DESC "Signed Div-64 Test" - -#define STR_POS "123456789" -#define STR_NEG "-123456789" -#define STR_BASE "0xabcdef" -#define STR_RANGE_MAX "10000000000000000" -#define STR_RANGE_MIN "-10000000000000000" -#define STR_INVAL1 "12345U" -#define STR_INVAL2 "invald" - -#define VAL_POS 123456789 -#define VAL_NEG -123456789 -#define VAL_BASE 0xabcdef -#define VAL_INVAL1 12345U - -#define define_generic_msg_strtox(type, valtype) \ -static void \ -generic_msg_strto##type(struct file *file, char *msg, int rc, int *err, \ - const char *s, valtype d, char *endptr) \ -{ \ - splat_vprint(file, SPLAT_GENERIC_TEST1_NAME, \ - "%s (%d) %s: %s == %lld, 0x%p\n", \ - rc ? "Fail" : "Pass", *err, msg, s, \ - (unsigned long long)d, endptr); \ - *err = rc; \ -} - -define_generic_msg_strtox(ul, unsigned long); -define_generic_msg_strtox(l, long); -define_generic_msg_strtox(ull, unsigned long long); -define_generic_msg_strtox(ll, long long); - -#define define_splat_generic_test_strtox(type, valtype) \ -static int \ -splat_generic_test_strto##type(struct file *file, void *arg) \ -{ \ - int rc, rc1, rc2, rc3, rc4, rc5, rc6, rc7; \ - char str[20], *endptr; \ - valtype r; \ - \ - /* Positive value: expect success */ \ - r = 0; \ - rc = 1; \ - endptr = NULL; \ - rc1 = ddi_strto##type(STR_POS, &endptr, 10, &r); \ - if (rc1 == 0 && r == VAL_POS && endptr && *endptr == '\0') \ - rc = 0; \ - \ - generic_msg_strto##type(file, "positive", rc , &rc1, \ - STR_POS, r, endptr); \ - \ - /* Negative value: expect success */ \ - r = 0; \ - rc = 1; \ - endptr = NULL; \ - strcpy(str, STR_NEG); \ - rc2 = ddi_strto##type(str, &endptr, 10, &r); \ - if (#type[0] == 'u') { \ - if (rc2 == 0 && r == 0 && endptr == str) \ - rc = 0; \ - } else { \ - if (rc2 == 0 && r == VAL_NEG && \ - endptr && *endptr == '\0') \ - rc = 0; \ - } \ - \ - generic_msg_strto##type(file, "negative", rc, &rc2, \ - STR_NEG, r, endptr); \ - \ - /* Non decimal base: expect sucess */ \ - r = 0; \ - rc = 1; \ - endptr = NULL; \ - rc3 = ddi_strto##type(STR_BASE, &endptr, 0, &r); \ - if (rc3 == 0 && r == VAL_BASE && endptr && *endptr == '\0') \ - rc = 0; \ - \ - generic_msg_strto##type(file, "base", rc, &rc3, \ - STR_BASE, r, endptr); \ - \ - /* Max out of range: failure expected, r unchanged */ \ - r = 0; \ - rc = 1; \ - endptr = NULL; \ - rc4 = ddi_strto##type(STR_RANGE_MAX, &endptr, 16, &r); \ - if (rc4 == ERANGE && r == 0 && endptr == NULL) \ - rc = 0; \ - \ - generic_msg_strto##type(file, "max", rc, &rc4, \ - STR_RANGE_MAX, r, endptr); \ - \ - /* Min out of range: failure expected, r unchanged */ \ - r = 0; \ - rc = 1; \ - endptr = NULL; \ - strcpy(str, STR_RANGE_MIN); \ - rc5 = ddi_strto##type(str, &endptr, 16, &r); \ - if (#type[0] == 'u') { \ - if (rc5 == 0 && r == 0 && endptr == str) \ - rc = 0; \ - } else { \ - if (rc5 == ERANGE && r == 0 && endptr == NULL) \ - rc = 0; \ - } \ - \ - generic_msg_strto##type(file, "min", rc, &rc5, \ - STR_RANGE_MIN, r, endptr); \ - \ - /* Invalid string: success expected, endptr == 'U' */ \ - r = 0; \ - rc = 1; \ - endptr = NULL; \ - rc6 = ddi_strto##type(STR_INVAL1, &endptr, 10, &r); \ - if (rc6 == 0 && r == VAL_INVAL1 && endptr && *endptr == 'U') \ - rc = 0; \ - \ - generic_msg_strto##type(file, "invalid", rc, &rc6, \ - STR_INVAL1, r, endptr); \ - \ - /* Invalid string: failure expected, endptr == str */ \ - r = 0; \ - rc = 1; \ - endptr = NULL; \ - strcpy(str, STR_INVAL2); \ - rc7 = ddi_strto##type(str, &endptr, 10, &r); \ - if (rc7 == 0 && r == 0 && endptr == str) \ - rc = 0; \ - \ - generic_msg_strto##type(file, "invalid", rc, &rc7, \ - STR_INVAL2, r, endptr); \ - \ - return (rc1 || rc2 || rc3 || rc4 || rc5 || rc6 || rc7) ? \ - -EINVAL : 0; \ -} - -define_splat_generic_test_strtox(ul, unsigned long); -define_splat_generic_test_strtox(l, long); -define_splat_generic_test_strtox(ull, unsigned long long); -define_splat_generic_test_strtox(ll, long long); - -/* - * The entries in the table are used in all combinations and the - * return value is checked to ensure it is range. On 32-bit - * systems __udivdi3 will be invoked for the 64-bit division. - * On 64-bit system the native 64-bit divide will be used so - * __udivdi3 isn't used but we might as well stil run the test. - */ -static int -splat_generic_test_udivdi3(struct file *file, void *arg) -{ - const uint64_t tabu[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 1000, 2003, - 32765, 32766, 32767, 32768, 32769, 32760, - 65533, 65534, 65535, 65536, 65537, 65538, - 0x7ffffffeULL, 0x7fffffffULL, 0x80000000ULL, 0x80000001ULL, - 0x7000000000000000ULL, 0x7000000080000000ULL, 0x7000000080000001ULL, - 0x7fffffffffffffffULL, 0x7fffffff8fffffffULL, 0x7fffffff8ffffff1ULL, - 0x7fffffff00000000ULL, 0x7fffffff80000000ULL, 0x7fffffff00000001ULL, - 0x8000000000000000ULL, 0x8000000080000000ULL, 0x8000000080000001ULL, - 0xc000000000000000ULL, 0xc000000080000000ULL, 0xc000000080000001ULL, - 0xfffffffffffffffdULL, 0xfffffffffffffffeULL, 0xffffffffffffffffULL, - }; - uint64_t uu, vu, qu, ru; - int n, i, j, errors = 0; - - splat_vprint(file, SPLAT_GENERIC_TEST5_NAME, "%s", - "Testing unsigned 64-bit division.\n"); - n = sizeof(tabu) / sizeof(tabu[0]); - for (i = 0; i < n; i++) { - for (j = 1; j < n; j++) { - uu = tabu[i]; - vu = tabu[j]; - qu = uu / vu; /* __udivdi3 */ - ru = uu - qu * vu; - if (qu > uu || ru >= vu) { - splat_vprint(file, SPLAT_GENERIC_TEST5_NAME, - "%016llx/%016llx != %016llx rem %016llx\n", - uu, vu, qu, ru); - errors++; - } - } - } - - if (errors) { - splat_vprint(file, SPLAT_GENERIC_TEST5_NAME, - "Failed %d/%d tests\n", errors, n * (n - 1)); - return -ERANGE; - } - - splat_vprint(file, SPLAT_GENERIC_TEST5_NAME, - "Passed all %d tests\n", n * (n - 1)); - - return 0; -} - -/* - * The entries the table are used in all combinations, with + and - signs - * preceding them. The return value is checked to ensure it is range. - * On 32-bit systems __divdi3 will be invoked for the 64-bit division. - * On 64-bit system the native 64-bit divide will be used so __divdi3 - * isn't used but we might as well stil run the test. - */ -static int -splat_generic_test_divdi3(struct file *file, void *arg) -{ - const int64_t tabs[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 1000, 2003, - 32765, 32766, 32767, 32768, 32769, 32760, - 65533, 65534, 65535, 65536, 65537, 65538, - 0x7ffffffeLL, 0x7fffffffLL, 0x80000000LL, 0x80000001LL, - 0x7000000000000000LL, 0x7000000080000000LL, 0x7000000080000001LL, - 0x7fffffffffffffffLL, 0x7fffffff8fffffffLL, 0x7fffffff8ffffff1LL, - 0x7fffffff00000000LL, 0x7fffffff80000000LL, 0x7fffffff00000001LL, - 0x0123456789abcdefLL, 0x00000000abcdef01LL, 0x0000000012345678LL, -#if BITS_PER_LONG == 32 - 0x8000000000000000LL, 0x8000000080000000LL, 0x8000000080000001LL, -#endif - }; - int64_t u, v, q, r; - int n, i, j, k, errors = 0; - - splat_vprint(file, SPLAT_GENERIC_TEST6_NAME, "%s", - "Testing signed 64-bit division.\n"); - n = sizeof(tabs) / sizeof(tabs[0]); - for (i = 0; i < n; i++) { - for (j = 1; j < n; j++) { - for (k = 0; k <= 3; k++) { - u = (k & 1) ? -tabs[i] : tabs[i]; - v = (k >= 2) ? -tabs[j] : tabs[j]; - - q = u / v; /* __divdi3 */ - r = u - q * v; - if (abs64(q) > abs64(u) || - abs64(r) >= abs64(v) || - (r != 0 && (r ^ u) < 0)) { - splat_vprint(file, - SPLAT_GENERIC_TEST6_NAME, - "%016llx/%016llx != %016llx " - "rem %016llx\n", u, v, q, r); - errors++; - } - } - } - } - - if (errors) { - splat_vprint(file, SPLAT_GENERIC_TEST6_NAME, - "Failed %d/%d tests\n", errors, n * (n - 1)); - return -ERANGE; - } - - splat_vprint(file, SPLAT_GENERIC_TEST6_NAME, - "Passed all %d tests\n", n * (n - 1)); - - return 0; -} - -splat_subsystem_t * -splat_generic_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_GENERIC_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_GENERIC_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_GENERIC; - - splat_test_init(sub, SPLAT_GENERIC_TEST1_NAME, SPLAT_GENERIC_TEST1_DESC, - SPLAT_GENERIC_TEST1_ID, splat_generic_test_strtoul); - splat_test_init(sub, SPLAT_GENERIC_TEST2_NAME, SPLAT_GENERIC_TEST2_DESC, - SPLAT_GENERIC_TEST2_ID, splat_generic_test_strtol); - splat_test_init(sub, SPLAT_GENERIC_TEST3_NAME, SPLAT_GENERIC_TEST3_DESC, - SPLAT_GENERIC_TEST3_ID, splat_generic_test_strtoull); - splat_test_init(sub, SPLAT_GENERIC_TEST4_NAME, SPLAT_GENERIC_TEST4_DESC, - SPLAT_GENERIC_TEST4_ID, splat_generic_test_strtoll); - splat_test_init(sub, SPLAT_GENERIC_TEST5_NAME, SPLAT_GENERIC_TEST5_DESC, - SPLAT_GENERIC_TEST5_ID, splat_generic_test_udivdi3); - splat_test_init(sub, SPLAT_GENERIC_TEST6_NAME, SPLAT_GENERIC_TEST6_DESC, - SPLAT_GENERIC_TEST6_ID, splat_generic_test_divdi3); - - return sub; -} - -void -splat_generic_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - - splat_test_fini(sub, SPLAT_GENERIC_TEST6_ID); - splat_test_fini(sub, SPLAT_GENERIC_TEST5_ID); - splat_test_fini(sub, SPLAT_GENERIC_TEST4_ID); - splat_test_fini(sub, SPLAT_GENERIC_TEST3_ID); - splat_test_fini(sub, SPLAT_GENERIC_TEST2_ID); - splat_test_fini(sub, SPLAT_GENERIC_TEST1_ID); - - kfree(sub); -} - -int -splat_generic_id(void) -{ - return SPLAT_SUBSYSTEM_GENERIC; -} diff --git a/module/splat/splat-internal.h b/module/splat/splat-internal.h deleted file mode 100644 index 97c10acfd..000000000 --- a/module/splat/splat-internal.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - */ - -#ifndef _SPLAT_INTERNAL_H -#define _SPLAT_INTERNAL_H - -#include "splat-ctl.h" -#include -#include -#include - -typedef int (*splat_test_func_t)(struct file *, void *); - -typedef struct splat_test { - struct list_head test_list; - splat_user_t desc; - splat_test_func_t test; -} splat_test_t; - -typedef struct splat_subsystem { - struct list_head subsystem_list;/* List had to chain entries */ - splat_user_t desc; - spinlock_t test_lock; - struct list_head test_list; -} splat_subsystem_t; - -void splat_test_init(splat_subsystem_t *sub, const char *name, - const char *desc, unsigned int tid, splat_test_func_t func); -void splat_test_fini(splat_subsystem_t *sub, unsigned int tid); - -#define SPLAT_INFO_BUFFER_SIZE 65536 -#define SPLAT_INFO_BUFFER_REDZONE 256 - -typedef struct splat_info { - kmutex_t info_lock; - int info_size; - char *info_buffer; - char *info_head; /* Internal kernel use only */ -} splat_info_t; - -#define sym2str(sym) (char *)(#sym) - -#define splat_print(file, format, args...) \ -({ splat_info_t *_info_ = (splat_info_t *)file->private_data; \ - int _rc_; \ - \ - ASSERT(_info_); \ - ASSERT(_info_->info_buffer); \ - \ - mutex_enter(&_info_->info_lock); \ - \ - /* Don't allow the kernel to start a write in the red zone */ \ - if ((int)(_info_->info_head - _info_->info_buffer) > \ - (SPLAT_INFO_BUFFER_SIZE - SPLAT_INFO_BUFFER_REDZONE)) { \ - _rc_ = -EOVERFLOW; \ - } else { \ - _rc_ = sprintf(_info_->info_head, format, args); \ - if (_rc_ >= 0) \ - _info_->info_head += _rc_; \ - } \ - \ - mutex_exit(&_info_->info_lock); \ - _rc_; \ -}) - -#define splat_vprint(file, test, format, args...) \ - splat_print(file, "%*s: " format, SPLAT_NAME_SIZE, test, args) - -#define splat_locked_test(lock, test) \ -({ \ - int _rc_; \ - spin_lock(lock); \ - _rc_ = (test) ? 1 : 0; \ - spin_unlock(lock); \ - _rc_; \ -}) - -splat_subsystem_t *splat_condvar_init(void); -splat_subsystem_t *splat_kmem_init(void); -splat_subsystem_t *splat_mutex_init(void); -splat_subsystem_t *splat_krng_init(void); -splat_subsystem_t *splat_rwlock_init(void); -splat_subsystem_t *splat_taskq_init(void); -splat_subsystem_t *splat_thread_init(void); -splat_subsystem_t *splat_time_init(void); -splat_subsystem_t *splat_vnode_init(void); -splat_subsystem_t *splat_kobj_init(void); -splat_subsystem_t *splat_atomic_init(void); -splat_subsystem_t *splat_list_init(void); -splat_subsystem_t *splat_generic_init(void); -splat_subsystem_t *splat_cred_init(void); -splat_subsystem_t *splat_zlib_init(void); -splat_subsystem_t *splat_linux_init(void); - -void splat_condvar_fini(splat_subsystem_t *); -void splat_kmem_fini(splat_subsystem_t *); -void splat_mutex_fini(splat_subsystem_t *); -void splat_krng_fini(splat_subsystem_t *); -void splat_rwlock_fini(splat_subsystem_t *); -void splat_taskq_fini(splat_subsystem_t *); -void splat_thread_fini(splat_subsystem_t *); -void splat_time_fini(splat_subsystem_t *); -void splat_vnode_fini(splat_subsystem_t *); -void splat_kobj_fini(splat_subsystem_t *); -void splat_atomic_fini(splat_subsystem_t *); -void splat_list_fini(splat_subsystem_t *); -void splat_generic_fini(splat_subsystem_t *); -void splat_cred_fini(splat_subsystem_t *); -void splat_zlib_fini(splat_subsystem_t *); -void splat_linux_fini(splat_subsystem_t *); - -int splat_condvar_id(void); -int splat_kmem_id(void); -int splat_mutex_id(void); -int splat_krng_id(void); -int splat_rwlock_id(void); -int splat_taskq_id(void); -int splat_thread_id(void); -int splat_time_id(void); -int splat_vnode_id(void); -int splat_kobj_id(void); -int splat_atomic_id(void); -int splat_list_id(void); -int splat_generic_id(void); -int splat_cred_id(void); -int splat_zlib_id(void); -int splat_linux_id(void); - -#endif /* _SPLAT_INTERNAL_H */ diff --git a/module/splat/splat-kmem.c b/module/splat/splat-kmem.c deleted file mode 100644 index 282f42d77..000000000 --- a/module/splat/splat-kmem.c +++ /dev/null @@ -1,1410 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Kmem Tests. - */ - -#include -#include -#include -#include -#include -#include -#include "splat-internal.h" - -#define SPLAT_KMEM_NAME "kmem" -#define SPLAT_KMEM_DESC "Kernel Malloc/Slab Tests" - -#define SPLAT_KMEM_TEST1_ID 0x0101 -#define SPLAT_KMEM_TEST1_NAME "kmem_alloc" -#define SPLAT_KMEM_TEST1_DESC "Memory allocation test (kmem_alloc)" - -#define SPLAT_KMEM_TEST2_ID 0x0102 -#define SPLAT_KMEM_TEST2_NAME "kmem_zalloc" -#define SPLAT_KMEM_TEST2_DESC "Memory allocation test (kmem_zalloc)" - -#define SPLAT_KMEM_TEST3_ID 0x0103 -#define SPLAT_KMEM_TEST3_NAME "vmem_alloc" -#define SPLAT_KMEM_TEST3_DESC "Memory allocation test (vmem_alloc)" - -#define SPLAT_KMEM_TEST4_ID 0x0104 -#define SPLAT_KMEM_TEST4_NAME "vmem_zalloc" -#define SPLAT_KMEM_TEST4_DESC "Memory allocation test (vmem_zalloc)" - -#define SPLAT_KMEM_TEST5_ID 0x0105 -#define SPLAT_KMEM_TEST5_NAME "slab_small" -#define SPLAT_KMEM_TEST5_DESC "Slab ctor/dtor test (small)" - -#define SPLAT_KMEM_TEST6_ID 0x0106 -#define SPLAT_KMEM_TEST6_NAME "slab_large" -#define SPLAT_KMEM_TEST6_DESC "Slab ctor/dtor test (large)" - -#define SPLAT_KMEM_TEST7_ID 0x0107 -#define SPLAT_KMEM_TEST7_NAME "slab_align" -#define SPLAT_KMEM_TEST7_DESC "Slab alignment test" - -#define SPLAT_KMEM_TEST8_ID 0x0108 -#define SPLAT_KMEM_TEST8_NAME "slab_reap" -#define SPLAT_KMEM_TEST8_DESC "Slab reaping test" - -#define SPLAT_KMEM_TEST9_ID 0x0109 -#define SPLAT_KMEM_TEST9_NAME "slab_age" -#define SPLAT_KMEM_TEST9_DESC "Slab aging test" - -#define SPLAT_KMEM_TEST10_ID 0x010a -#define SPLAT_KMEM_TEST10_NAME "slab_lock" -#define SPLAT_KMEM_TEST10_DESC "Slab locking test" - -#if 0 -#define SPLAT_KMEM_TEST11_ID 0x010b -#define SPLAT_KMEM_TEST11_NAME "slab_overcommit" -#define SPLAT_KMEM_TEST11_DESC "Slab memory overcommit test" -#endif - -#define SPLAT_KMEM_TEST13_ID 0x010d -#define SPLAT_KMEM_TEST13_NAME "slab_reclaim" -#define SPLAT_KMEM_TEST13_DESC "Slab direct memory reclaim test" - -#define SPLAT_KMEM_ALLOC_COUNT 10 -#define SPLAT_VMEM_ALLOC_COUNT 10 - - -static int -splat_kmem_test1(struct file *file, void *arg) -{ - void *ptr[SPLAT_KMEM_ALLOC_COUNT]; - int size = PAGE_SIZE; - int i, count, rc = 0; - - while ((!rc) && (size <= spl_kmem_alloc_warn)) { - count = 0; - - for (i = 0; i < SPLAT_KMEM_ALLOC_COUNT; i++) { - ptr[i] = kmem_alloc(size, KM_SLEEP); - if (ptr[i]) - count++; - } - - for (i = 0; i < SPLAT_KMEM_ALLOC_COUNT; i++) - if (ptr[i]) - kmem_free(ptr[i], size); - - splat_vprint(file, SPLAT_KMEM_TEST1_NAME, - "%d byte allocations, %d/%d successful\n", - size, count, SPLAT_KMEM_ALLOC_COUNT); - if (count != SPLAT_KMEM_ALLOC_COUNT) - rc = -ENOMEM; - - size *= 2; - } - - return rc; -} - -static int -splat_kmem_test2(struct file *file, void *arg) -{ - void *ptr[SPLAT_KMEM_ALLOC_COUNT]; - int size = PAGE_SIZE; - int i, j, count, rc = 0; - - while ((!rc) && (size <= spl_kmem_alloc_warn)) { - count = 0; - - for (i = 0; i < SPLAT_KMEM_ALLOC_COUNT; i++) { - ptr[i] = kmem_zalloc(size, KM_SLEEP); - if (ptr[i]) - count++; - } - - /* Ensure buffer has been zero filled */ - for (i = 0; i < SPLAT_KMEM_ALLOC_COUNT; i++) { - for (j = 0; j < size; j++) { - if (((char *)ptr[i])[j] != '\0') { - splat_vprint(file,SPLAT_KMEM_TEST2_NAME, - "%d-byte allocation was " - "not zeroed\n", size); - rc = -EFAULT; - } - } - } - - for (i = 0; i < SPLAT_KMEM_ALLOC_COUNT; i++) - if (ptr[i]) - kmem_free(ptr[i], size); - - splat_vprint(file, SPLAT_KMEM_TEST2_NAME, - "%d byte allocations, %d/%d successful\n", - size, count, SPLAT_KMEM_ALLOC_COUNT); - if (count != SPLAT_KMEM_ALLOC_COUNT) - rc = -ENOMEM; - - size *= 2; - } - - return rc; -} - -static int -splat_kmem_test3(struct file *file, void *arg) -{ - void *ptr[SPLAT_VMEM_ALLOC_COUNT]; - int size = PAGE_SIZE; - int i, count, rc = 0; - - /* - * Test up to 4x the maximum kmem_alloc() size to ensure both - * the kmem_alloc() and vmem_alloc() call paths are used. - */ - while ((!rc) && (size <= (4 * spl_kmem_alloc_max))) { - count = 0; - - for (i = 0; i < SPLAT_VMEM_ALLOC_COUNT; i++) { - ptr[i] = vmem_alloc(size, KM_SLEEP); - if (ptr[i]) - count++; - } - - for (i = 0; i < SPLAT_VMEM_ALLOC_COUNT; i++) - if (ptr[i]) - vmem_free(ptr[i], size); - - splat_vprint(file, SPLAT_KMEM_TEST3_NAME, - "%d byte allocations, %d/%d successful\n", - size, count, SPLAT_VMEM_ALLOC_COUNT); - if (count != SPLAT_VMEM_ALLOC_COUNT) - rc = -ENOMEM; - - size *= 2; - } - - return rc; -} - -static int -splat_kmem_test4(struct file *file, void *arg) -{ - void *ptr[SPLAT_VMEM_ALLOC_COUNT]; - int size = PAGE_SIZE; - int i, j, count, rc = 0; - - /* - * Test up to 4x the maximum kmem_zalloc() size to ensure both - * the kmem_zalloc() and vmem_zalloc() call paths are used. - */ - while ((!rc) && (size <= (4 * spl_kmem_alloc_max))) { - count = 0; - - for (i = 0; i < SPLAT_VMEM_ALLOC_COUNT; i++) { - ptr[i] = vmem_zalloc(size, KM_SLEEP); - if (ptr[i]) - count++; - } - - /* Ensure buffer has been zero filled */ - for (i = 0; i < SPLAT_VMEM_ALLOC_COUNT; i++) { - for (j = 0; j < size; j++) { - if (((char *)ptr[i])[j] != '\0') { - splat_vprint(file, SPLAT_KMEM_TEST4_NAME, - "%d-byte allocation was " - "not zeroed\n", size); - rc = -EFAULT; - } - } - } - - for (i = 0; i < SPLAT_VMEM_ALLOC_COUNT; i++) - if (ptr[i]) - vmem_free(ptr[i], size); - - splat_vprint(file, SPLAT_KMEM_TEST4_NAME, - "%d byte allocations, %d/%d successful\n", - size, count, SPLAT_VMEM_ALLOC_COUNT); - if (count != SPLAT_VMEM_ALLOC_COUNT) - rc = -ENOMEM; - - size *= 2; - } - - return rc; -} - -#define SPLAT_KMEM_TEST_MAGIC 0x004488CCUL -#define SPLAT_KMEM_CACHE_NAME "kmem_test" -#define SPLAT_KMEM_OBJ_COUNT 1024 -#define SPLAT_KMEM_OBJ_RECLAIM 32 /* objects */ -#define SPLAT_KMEM_THREADS 32 - -#define KCP_FLAG_READY 0x01 - -typedef struct kmem_cache_data { - unsigned long kcd_magic; - struct list_head kcd_node; - int kcd_flag; - char kcd_buf[0]; -} kmem_cache_data_t; - -typedef struct kmem_cache_thread { - spinlock_t kct_lock; - int kct_id; - struct list_head kct_list; -} kmem_cache_thread_t; - -typedef struct kmem_cache_priv { - unsigned long kcp_magic; - struct file *kcp_file; - kmem_cache_t *kcp_cache; - spinlock_t kcp_lock; - spl_wait_queue_head_t kcp_ctl_waitq; - spl_wait_queue_head_t kcp_thr_waitq; - int kcp_flags; - int kcp_kct_count; - kmem_cache_thread_t *kcp_kct[SPLAT_KMEM_THREADS]; - int kcp_size; - int kcp_align; - int kcp_count; - int kcp_alloc; - int kcp_rc; -} kmem_cache_priv_t; - -static kmem_cache_priv_t * -splat_kmem_cache_test_kcp_alloc(struct file *file, char *name, - int size, int align, int alloc) -{ - kmem_cache_priv_t *kcp; - - kcp = kmem_zalloc(sizeof(kmem_cache_priv_t), KM_SLEEP); - if (!kcp) - return NULL; - - kcp->kcp_magic = SPLAT_KMEM_TEST_MAGIC; - kcp->kcp_file = file; - kcp->kcp_cache = NULL; - spin_lock_init(&kcp->kcp_lock); - init_waitqueue_head(&kcp->kcp_ctl_waitq); - init_waitqueue_head(&kcp->kcp_thr_waitq); - kcp->kcp_flags = 0; - kcp->kcp_kct_count = -1; - kcp->kcp_size = size; - kcp->kcp_align = align; - kcp->kcp_count = 0; - kcp->kcp_alloc = alloc; - kcp->kcp_rc = 0; - - return kcp; -} - -static void -splat_kmem_cache_test_kcp_free(kmem_cache_priv_t *kcp) -{ - kmem_free(kcp, sizeof(kmem_cache_priv_t)); -} - -static kmem_cache_thread_t * -splat_kmem_cache_test_kct_alloc(kmem_cache_priv_t *kcp, int id) -{ - kmem_cache_thread_t *kct; - - ASSERT3S(id, <, SPLAT_KMEM_THREADS); - ASSERT(kcp->kcp_kct[id] == NULL); - - kct = kmem_zalloc(sizeof(kmem_cache_thread_t), KM_SLEEP); - if (!kct) - return NULL; - - spin_lock_init(&kct->kct_lock); - kct->kct_id = id; - INIT_LIST_HEAD(&kct->kct_list); - - spin_lock(&kcp->kcp_lock); - kcp->kcp_kct[id] = kct; - spin_unlock(&kcp->kcp_lock); - - return kct; -} - -static void -splat_kmem_cache_test_kct_free(kmem_cache_priv_t *kcp, - kmem_cache_thread_t *kct) -{ - spin_lock(&kcp->kcp_lock); - kcp->kcp_kct[kct->kct_id] = NULL; - spin_unlock(&kcp->kcp_lock); - - kmem_free(kct, sizeof(kmem_cache_thread_t)); -} - -static void -splat_kmem_cache_test_kcd_free(kmem_cache_priv_t *kcp, - kmem_cache_thread_t *kct) -{ - kmem_cache_data_t *kcd; - - spin_lock(&kct->kct_lock); - while (!list_empty(&kct->kct_list)) { - kcd = list_entry(kct->kct_list.next, - kmem_cache_data_t, kcd_node); - list_del(&kcd->kcd_node); - spin_unlock(&kct->kct_lock); - - kmem_cache_free(kcp->kcp_cache, kcd); - - spin_lock(&kct->kct_lock); - } - spin_unlock(&kct->kct_lock); -} - -static int -splat_kmem_cache_test_kcd_alloc(kmem_cache_priv_t *kcp, - kmem_cache_thread_t *kct, int count) -{ - kmem_cache_data_t *kcd; - int i; - - for (i = 0; i < count; i++) { - kcd = kmem_cache_alloc(kcp->kcp_cache, KM_SLEEP); - if (kcd == NULL) { - splat_kmem_cache_test_kcd_free(kcp, kct); - return -ENOMEM; - } - - spin_lock(&kct->kct_lock); - list_add_tail(&kcd->kcd_node, &kct->kct_list); - spin_unlock(&kct->kct_lock); - } - - return 0; -} - -static void -splat_kmem_cache_test_debug(struct file *file, char *name, - kmem_cache_priv_t *kcp) -{ - int j; - - splat_vprint(file, name, "%s cache objects %d", - kcp->kcp_cache->skc_name, kcp->kcp_count); - - if (kcp->kcp_cache->skc_flags & (KMC_KMEM | KMC_VMEM)) { - splat_vprint(file, name, ", slabs %u/%u objs %u/%u", - (unsigned)kcp->kcp_cache->skc_slab_alloc, - (unsigned)kcp->kcp_cache->skc_slab_total, - (unsigned)kcp->kcp_cache->skc_obj_alloc, - (unsigned)kcp->kcp_cache->skc_obj_total); - - if (!(kcp->kcp_cache->skc_flags & KMC_NOMAGAZINE)) { - splat_vprint(file, name, "%s", "mags"); - - for_each_online_cpu(j) - splat_print(file, "%u/%u ", - kcp->kcp_cache->skc_mag[j]->skm_avail, - kcp->kcp_cache->skc_mag[j]->skm_size); - } - } - - splat_print(file, "%s\n", ""); -} - -static int -splat_kmem_cache_test_constructor(void *ptr, void *priv, int flags) -{ - kmem_cache_priv_t *kcp = (kmem_cache_priv_t *)priv; - kmem_cache_data_t *kcd = (kmem_cache_data_t *)ptr; - - if (kcd && kcp) { - kcd->kcd_magic = kcp->kcp_magic; - INIT_LIST_HEAD(&kcd->kcd_node); - kcd->kcd_flag = 1; - memset(kcd->kcd_buf, 0xaa, kcp->kcp_size - (sizeof *kcd)); - kcp->kcp_count++; - } - - return 0; -} - -static void -splat_kmem_cache_test_destructor(void *ptr, void *priv) -{ - kmem_cache_priv_t *kcp = (kmem_cache_priv_t *)priv; - kmem_cache_data_t *kcd = (kmem_cache_data_t *)ptr; - - if (kcd && kcp) { - kcd->kcd_magic = 0; - kcd->kcd_flag = 0; - memset(kcd->kcd_buf, 0xbb, kcp->kcp_size - (sizeof *kcd)); - kcp->kcp_count--; - } - - return; -} - -/* - * Generic reclaim function which assumes that all objects may - * be reclaimed at any time. We free a small percentage of the - * objects linked off the kcp or kct[] every time we are called. - */ -static void -splat_kmem_cache_test_reclaim(void *priv) -{ - kmem_cache_priv_t *kcp = (kmem_cache_priv_t *)priv; - kmem_cache_thread_t *kct; - kmem_cache_data_t *kcd; - LIST_HEAD(reclaim); - int i, count; - - ASSERT(kcp->kcp_magic == SPLAT_KMEM_TEST_MAGIC); - - /* For each kct thread reclaim some objects */ - spin_lock(&kcp->kcp_lock); - for (i = 0; i < SPLAT_KMEM_THREADS; i++) { - kct = kcp->kcp_kct[i]; - if (!kct) - continue; - - spin_unlock(&kcp->kcp_lock); - spin_lock(&kct->kct_lock); - - count = SPLAT_KMEM_OBJ_RECLAIM; - while (count > 0 && !list_empty(&kct->kct_list)) { - kcd = list_entry(kct->kct_list.next, - kmem_cache_data_t, kcd_node); - list_del(&kcd->kcd_node); - list_add(&kcd->kcd_node, &reclaim); - count--; - } - - spin_unlock(&kct->kct_lock); - spin_lock(&kcp->kcp_lock); - } - spin_unlock(&kcp->kcp_lock); - - /* Freed outside the spin lock */ - while (!list_empty(&reclaim)) { - kcd = list_entry(reclaim.next, kmem_cache_data_t, kcd_node); - list_del(&kcd->kcd_node); - kmem_cache_free(kcp->kcp_cache, kcd); - } - - return; -} - -static int -splat_kmem_cache_test_threads(kmem_cache_priv_t *kcp, int threads) -{ - int rc; - - spin_lock(&kcp->kcp_lock); - rc = (kcp->kcp_kct_count == threads); - spin_unlock(&kcp->kcp_lock); - - return rc; -} - -static int -splat_kmem_cache_test_flags(kmem_cache_priv_t *kcp, int flags) -{ - int rc; - - spin_lock(&kcp->kcp_lock); - rc = (kcp->kcp_flags & flags); - spin_unlock(&kcp->kcp_lock); - - return rc; -} - -static void -splat_kmem_cache_test_thread(void *arg) -{ - kmem_cache_priv_t *kcp = (kmem_cache_priv_t *)arg; - kmem_cache_thread_t *kct; - int rc = 0, id; - - ASSERT(kcp->kcp_magic == SPLAT_KMEM_TEST_MAGIC); - - /* Assign thread ids */ - spin_lock(&kcp->kcp_lock); - if (kcp->kcp_kct_count == -1) - kcp->kcp_kct_count = 0; - - id = kcp->kcp_kct_count; - kcp->kcp_kct_count++; - spin_unlock(&kcp->kcp_lock); - - kct = splat_kmem_cache_test_kct_alloc(kcp, id); - if (!kct) { - rc = -ENOMEM; - goto out; - } - - /* Wait for all threads to have started and report they are ready */ - if (kcp->kcp_kct_count == SPLAT_KMEM_THREADS) - wake_up(&kcp->kcp_ctl_waitq); - - wait_event(kcp->kcp_thr_waitq, - splat_kmem_cache_test_flags(kcp, KCP_FLAG_READY)); - - /* Create and destroy objects */ - rc = splat_kmem_cache_test_kcd_alloc(kcp, kct, kcp->kcp_alloc); - splat_kmem_cache_test_kcd_free(kcp, kct); -out: - if (kct) - splat_kmem_cache_test_kct_free(kcp, kct); - - spin_lock(&kcp->kcp_lock); - if (!kcp->kcp_rc) - kcp->kcp_rc = rc; - - if ((--kcp->kcp_kct_count) == 0) - wake_up(&kcp->kcp_ctl_waitq); - - spin_unlock(&kcp->kcp_lock); - - thread_exit(); -} - -static int -splat_kmem_cache_test(struct file *file, void *arg, char *name, - int size, int align, int flags) -{ - kmem_cache_priv_t *kcp = NULL; - kmem_cache_data_t **kcd = NULL; - int i, rc = 0, objs = 0; - - /* Limit size for low memory machines (1/128 of memory) */ - size = MIN(size, (physmem * PAGE_SIZE) >> 7); - - splat_vprint(file, name, - "Testing size=%d, align=%d, flags=0x%04x\n", - size, align, flags); - - kcp = splat_kmem_cache_test_kcp_alloc(file, name, size, align, 0); - if (!kcp) { - splat_vprint(file, name, "Unable to create '%s'\n", "kcp"); - return (-ENOMEM); - } - - kcp->kcp_cache = kmem_cache_create(SPLAT_KMEM_CACHE_NAME, - kcp->kcp_size, kcp->kcp_align, - splat_kmem_cache_test_constructor, - splat_kmem_cache_test_destructor, - NULL, kcp, NULL, flags); - if (kcp->kcp_cache == NULL) { - splat_vprint(file, name, "Unable to create " - "name='%s', size=%d, align=%d, flags=0x%x\n", - SPLAT_KMEM_CACHE_NAME, size, align, flags); - rc = -ENOMEM; - goto out_free; - } - - /* - * Allocate several slabs worth of objects to verify functionality. - * However, on 32-bit systems with limited address space constrain - * it to a single slab for the purposes of this test. - */ -#ifdef _LP64 - objs = kcp->kcp_cache->skc_slab_objs * 4; -#else - objs = 1; -#endif - kcd = kmem_zalloc(sizeof (kmem_cache_data_t *) * objs, KM_SLEEP); - if (kcd == NULL) { - splat_vprint(file, name, "Unable to allocate pointers " - "for %d objects\n", objs); - rc = -ENOMEM; - goto out_free; - } - - for (i = 0; i < objs; i++) { - kcd[i] = kmem_cache_alloc(kcp->kcp_cache, KM_SLEEP); - if (kcd[i] == NULL) { - splat_vprint(file, name, "Unable to allocate " - "from '%s'\n", SPLAT_KMEM_CACHE_NAME); - rc = -EINVAL; - goto out_free; - } - - if (!kcd[i]->kcd_flag) { - splat_vprint(file, name, "Failed to run constructor " - "for '%s'\n", SPLAT_KMEM_CACHE_NAME); - rc = -EINVAL; - goto out_free; - } - - if (kcd[i]->kcd_magic != kcp->kcp_magic) { - splat_vprint(file, name, - "Failed to pass private data to constructor " - "for '%s'\n", SPLAT_KMEM_CACHE_NAME); - rc = -EINVAL; - goto out_free; - } - } - - for (i = 0; i < objs; i++) { - kmem_cache_free(kcp->kcp_cache, kcd[i]); - - /* Destructors are run for every kmem_cache_free() */ - if (kcd[i]->kcd_flag) { - splat_vprint(file, name, - "Failed to run destructor for '%s'\n", - SPLAT_KMEM_CACHE_NAME); - rc = -EINVAL; - goto out_free; - } - } - - if (kcp->kcp_count) { - splat_vprint(file, name, - "Failed to run destructor on all slab objects for '%s'\n", - SPLAT_KMEM_CACHE_NAME); - rc = -EINVAL; - } - - kmem_free(kcd, sizeof (kmem_cache_data_t *) * objs); - kmem_cache_destroy(kcp->kcp_cache); - - splat_kmem_cache_test_kcp_free(kcp); - splat_vprint(file, name, - "Success ran alloc'd/free'd %d objects of size %d\n", - objs, size); - - return (rc); - -out_free: - if (kcd) { - for (i = 0; i < objs; i++) { - if (kcd[i] != NULL) - kmem_cache_free(kcp->kcp_cache, kcd[i]); - } - - kmem_free(kcd, sizeof (kmem_cache_data_t *) * objs); - } - - if (kcp->kcp_cache) - kmem_cache_destroy(kcp->kcp_cache); - - splat_kmem_cache_test_kcp_free(kcp); - - return (rc); -} - -static int -splat_kmem_cache_thread_test(struct file *file, void *arg, char *name, - int size, int alloc, int max_time) -{ - kmem_cache_priv_t *kcp; - kthread_t *thr; - struct timespec start, stop, delta; - char cache_name[32]; - int i, rc = 0; - - kcp = splat_kmem_cache_test_kcp_alloc(file, name, size, 0, alloc); - if (!kcp) { - splat_vprint(file, name, "Unable to create '%s'\n", "kcp"); - return -ENOMEM; - } - - (void)snprintf(cache_name, 32, "%s-%d-%d", - SPLAT_KMEM_CACHE_NAME, size, alloc); - kcp->kcp_cache = - kmem_cache_create(cache_name, kcp->kcp_size, 0, - splat_kmem_cache_test_constructor, - splat_kmem_cache_test_destructor, - splat_kmem_cache_test_reclaim, - kcp, NULL, 0); - if (!kcp->kcp_cache) { - splat_vprint(file, name, "Unable to create '%s'\n", cache_name); - rc = -ENOMEM; - goto out_kcp; - } - - getnstimeofday(&start); - - for (i = 0; i < SPLAT_KMEM_THREADS; i++) { - thr = thread_create(NULL, 0, - splat_kmem_cache_test_thread, - kcp, 0, &p0, TS_RUN, defclsyspri); - if (thr == NULL) { - rc = -ESRCH; - goto out_cache; - } - } - - /* Sleep until all threads have started, then set the ready - * flag and wake them all up for maximum concurrency. */ - wait_event(kcp->kcp_ctl_waitq, - splat_kmem_cache_test_threads(kcp, SPLAT_KMEM_THREADS)); - - spin_lock(&kcp->kcp_lock); - kcp->kcp_flags |= KCP_FLAG_READY; - spin_unlock(&kcp->kcp_lock); - wake_up_all(&kcp->kcp_thr_waitq); - - /* Sleep until all thread have finished */ - wait_event(kcp->kcp_ctl_waitq, splat_kmem_cache_test_threads(kcp, 0)); - - getnstimeofday(&stop); - delta = timespec_sub(stop, start); - - splat_vprint(file, name, - "%-22s %2ld.%09ld\t" - "%lu/%lu/%lu\t%lu/%lu/%lu\n", - kcp->kcp_cache->skc_name, - delta.tv_sec, delta.tv_nsec, - (unsigned long)kcp->kcp_cache->skc_slab_total, - (unsigned long)kcp->kcp_cache->skc_slab_max, - (unsigned long)(kcp->kcp_alloc * - SPLAT_KMEM_THREADS / - SPL_KMEM_CACHE_OBJ_PER_SLAB), - (unsigned long)kcp->kcp_cache->skc_obj_total, - (unsigned long)kcp->kcp_cache->skc_obj_max, - (unsigned long)(kcp->kcp_alloc * - SPLAT_KMEM_THREADS)); - - if (delta.tv_sec >= max_time) - rc = -ETIME; - - if (!rc && kcp->kcp_rc) - rc = kcp->kcp_rc; - -out_cache: - kmem_cache_destroy(kcp->kcp_cache); -out_kcp: - splat_kmem_cache_test_kcp_free(kcp); - return rc; -} - -/* Validate small object cache behavior for dynamic/kmem/vmem caches */ -static int -splat_kmem_test5(struct file *file, void *arg) -{ - char *name = SPLAT_KMEM_TEST5_NAME; - int i, rc = 0; - - /* Randomly pick small object sizes and alignments. */ - for (i = 0; i < 100; i++) { - int size, align, flags = 0; - uint32_t rnd; - - /* Evenly distribute tests over all value cache types */ - get_random_bytes((void *)&rnd, sizeof (uint32_t)); - switch (rnd & 0x03) { - default: - case 0x00: - flags = 0; - break; - case 0x01: - flags = KMC_KMEM; - break; - case 0x02: - flags = KMC_VMEM; - break; - case 0x03: - flags = KMC_SLAB; - break; - } - - /* The following flags are set with a 1/10 chance */ - flags |= ((((rnd >> 8) % 10) == 0) ? KMC_OFFSLAB : 0); - flags |= ((((rnd >> 16) % 10) == 0) ? KMC_NOEMERGENCY : 0); - - /* 32b - PAGE_SIZE */ - get_random_bytes((void *)&rnd, sizeof (uint32_t)); - size = MAX(rnd % (PAGE_SIZE + 1), 32); - - /* 2^N where (3 <= N <= PAGE_SHIFT) */ - get_random_bytes((void *)&rnd, sizeof (uint32_t)); - align = (1 << MAX(3, rnd % (PAGE_SHIFT + 1))); - - rc = splat_kmem_cache_test(file, arg, name, size, align, flags); - if (rc) - return (rc); - } - - return (rc); -} - -/* - * Validate large object cache behavior for dynamic/kmem/vmem caches - */ -static int -splat_kmem_test6(struct file *file, void *arg) -{ - char *name = SPLAT_KMEM_TEST6_NAME; - int i, max_size, rc = 0; - - /* Randomly pick large object sizes and alignments. */ - for (i = 0; i < 100; i++) { - int size, align, flags = 0; - uint32_t rnd; - - /* Evenly distribute tests over all value cache types */ - get_random_bytes((void *)&rnd, sizeof (uint32_t)); - switch (rnd & 0x03) { - default: - case 0x00: - flags = 0; - max_size = (SPL_KMEM_CACHE_MAX_SIZE * 1024 * 1024) / 2; - break; - case 0x01: - flags = KMC_KMEM; - max_size = (SPL_MAX_ORDER_NR_PAGES - 2) * PAGE_SIZE; - break; - case 0x02: - flags = KMC_VMEM; - max_size = (SPL_KMEM_CACHE_MAX_SIZE * 1024 * 1024) / 2; - break; - case 0x03: - flags = KMC_SLAB; - max_size = SPL_MAX_KMEM_ORDER_NR_PAGES * PAGE_SIZE; - break; - } - - /* The following flags are set with a 1/10 chance */ - flags |= ((((rnd >> 8) % 10) == 0) ? KMC_OFFSLAB : 0); - flags |= ((((rnd >> 16) % 10) == 0) ? KMC_NOEMERGENCY : 0); - - /* PAGE_SIZE - max_size */ - get_random_bytes((void *)&rnd, sizeof (uint32_t)); - size = MAX(rnd % (max_size + 1), PAGE_SIZE), - - /* 2^N where (3 <= N <= PAGE_SHIFT) */ - get_random_bytes((void *)&rnd, sizeof (uint32_t)); - align = (1 << MAX(3, rnd % (PAGE_SHIFT + 1))); - - rc = splat_kmem_cache_test(file, arg, name, size, align, flags); - if (rc) - return (rc); - } - - return (rc); -} - -/* - * Validate object alignment cache behavior for caches - */ -static int -splat_kmem_test7(struct file *file, void *arg) -{ - char *name = SPLAT_KMEM_TEST7_NAME; - int max_size = (SPL_KMEM_CACHE_MAX_SIZE * 1024 * 1024) / 2; - int i, rc; - - for (i = SPL_KMEM_CACHE_ALIGN; i <= PAGE_SIZE; i *= 2) { - uint32_t size; - - get_random_bytes((void *)&size, sizeof (uint32_t)); - size = MAX(size % (max_size + 1), 32); - - rc = splat_kmem_cache_test(file, arg, name, size, i, 0); - if (rc) - return rc; - - rc = splat_kmem_cache_test(file, arg, name, size, i, - KMC_OFFSLAB); - if (rc) - return rc; - } - - return rc; -} - -/* - * Validate kmem_cache_reap() by requesting the slab cache free any objects - * it can. For a few reasons this may not immediately result in more free - * memory even if objects are freed. First off, due to fragmentation we - * may not be able to reclaim any slabs. Secondly, even if we do we fully - * clear some slabs we will not want to immediately reclaim all of them - * because we may contend with cache allocations and thrash. What we want - * to see is the slab size decrease more gradually as it becomes clear they - * will not be needed. This should be achievable in less than a minute. - * If it takes longer than this something has gone wrong. - */ -static int -splat_kmem_test8(struct file *file, void *arg) -{ - kmem_cache_priv_t *kcp; - kmem_cache_thread_t *kct; - unsigned int spl_kmem_cache_expire_old; - int i, rc = 0; - - /* Enable cache aging just for this test if it is disabled */ - spl_kmem_cache_expire_old = spl_kmem_cache_expire; - spl_kmem_cache_expire = KMC_EXPIRE_AGE; - - kcp = splat_kmem_cache_test_kcp_alloc(file, SPLAT_KMEM_TEST8_NAME, - 256, 0, 0); - if (!kcp) { - splat_vprint(file, SPLAT_KMEM_TEST8_NAME, - "Unable to create '%s'\n", "kcp"); - rc = -ENOMEM; - goto out; - } - - kcp->kcp_cache = - kmem_cache_create(SPLAT_KMEM_CACHE_NAME, kcp->kcp_size, 0, - splat_kmem_cache_test_constructor, - splat_kmem_cache_test_destructor, - splat_kmem_cache_test_reclaim, - kcp, NULL, 0); - if (!kcp->kcp_cache) { - splat_vprint(file, SPLAT_KMEM_TEST8_NAME, - "Unable to create '%s'\n", SPLAT_KMEM_CACHE_NAME); - rc = -ENOMEM; - goto out_kcp; - } - - kct = splat_kmem_cache_test_kct_alloc(kcp, 0); - if (!kct) { - splat_vprint(file, SPLAT_KMEM_TEST8_NAME, - "Unable to create '%s'\n", "kct"); - rc = -ENOMEM; - goto out_cache; - } - - rc = splat_kmem_cache_test_kcd_alloc(kcp, kct, SPLAT_KMEM_OBJ_COUNT); - if (rc) { - splat_vprint(file, SPLAT_KMEM_TEST8_NAME, "Unable to " - "allocate from '%s'\n", SPLAT_KMEM_CACHE_NAME); - goto out_kct; - } - - /* Force reclaim every 1/10 a second for 60 seconds. */ - for (i = 0; i < 600; i++) { - kmem_cache_reap_now(kcp->kcp_cache); - splat_kmem_cache_test_debug(file, SPLAT_KMEM_TEST8_NAME, kcp); - - if (kcp->kcp_count == 0) - break; - - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(HZ / 10); - } - - if (kcp->kcp_count == 0) { - splat_vprint(file, SPLAT_KMEM_TEST8_NAME, - "Successfully created %d objects " - "in cache %s and reclaimed them\n", - SPLAT_KMEM_OBJ_COUNT, SPLAT_KMEM_CACHE_NAME); - } else { - splat_vprint(file, SPLAT_KMEM_TEST8_NAME, - "Failed to reclaim %u/%d objects from cache %s\n", - (unsigned)kcp->kcp_count, - SPLAT_KMEM_OBJ_COUNT, SPLAT_KMEM_CACHE_NAME); - rc = -ENOMEM; - } - - /* Cleanup our mess (for failure case of time expiring) */ - splat_kmem_cache_test_kcd_free(kcp, kct); -out_kct: - splat_kmem_cache_test_kct_free(kcp, kct); -out_cache: - kmem_cache_destroy(kcp->kcp_cache); -out_kcp: - splat_kmem_cache_test_kcp_free(kcp); -out: - spl_kmem_cache_expire = spl_kmem_cache_expire_old; - - return rc; -} - -/* Test cache aging, we have allocated a large number of objects thus - * creating a large number of slabs and then free'd them all. However, - * since there should be little memory pressure at the moment those - * slabs have not been freed. What we want to see is the slab size - * decrease gradually as it becomes clear they will not be be needed. - * This should be achievable in less than minute. If it takes longer - * than this something has gone wrong. - */ -static int -splat_kmem_test9(struct file *file, void *arg) -{ - kmem_cache_priv_t *kcp; - kmem_cache_thread_t *kct; - unsigned int spl_kmem_cache_expire_old; - int i, rc = 0, count = SPLAT_KMEM_OBJ_COUNT * 128; - - /* Enable cache aging just for this test if it is disabled */ - spl_kmem_cache_expire_old = spl_kmem_cache_expire; - spl_kmem_cache_expire = KMC_EXPIRE_AGE; - - kcp = splat_kmem_cache_test_kcp_alloc(file, SPLAT_KMEM_TEST9_NAME, - 256, 0, 0); - if (!kcp) { - splat_vprint(file, SPLAT_KMEM_TEST9_NAME, - "Unable to create '%s'\n", "kcp"); - rc = -ENOMEM; - goto out; - } - - kcp->kcp_cache = - kmem_cache_create(SPLAT_KMEM_CACHE_NAME, kcp->kcp_size, 0, - splat_kmem_cache_test_constructor, - splat_kmem_cache_test_destructor, - NULL, kcp, NULL, 0); - if (!kcp->kcp_cache) { - splat_vprint(file, SPLAT_KMEM_TEST9_NAME, - "Unable to create '%s'\n", SPLAT_KMEM_CACHE_NAME); - rc = -ENOMEM; - goto out_kcp; - } - - kct = splat_kmem_cache_test_kct_alloc(kcp, 0); - if (!kct) { - splat_vprint(file, SPLAT_KMEM_TEST8_NAME, - "Unable to create '%s'\n", "kct"); - rc = -ENOMEM; - goto out_cache; - } - - rc = splat_kmem_cache_test_kcd_alloc(kcp, kct, count); - if (rc) { - splat_vprint(file, SPLAT_KMEM_TEST9_NAME, "Unable to " - "allocate from '%s'\n", SPLAT_KMEM_CACHE_NAME); - goto out_kct; - } - - splat_kmem_cache_test_kcd_free(kcp, kct); - - for (i = 0; i < 60; i++) { - splat_kmem_cache_test_debug(file, SPLAT_KMEM_TEST9_NAME, kcp); - - if (kcp->kcp_count == 0) - break; - - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(HZ); - } - - if (kcp->kcp_count == 0) { - splat_vprint(file, SPLAT_KMEM_TEST9_NAME, - "Successfully created %d objects " - "in cache %s and reclaimed them\n", - count, SPLAT_KMEM_CACHE_NAME); - } else { - splat_vprint(file, SPLAT_KMEM_TEST9_NAME, - "Failed to reclaim %u/%d objects from cache %s\n", - (unsigned)kcp->kcp_count, count, - SPLAT_KMEM_CACHE_NAME); - rc = -ENOMEM; - } - -out_kct: - splat_kmem_cache_test_kct_free(kcp, kct); -out_cache: - kmem_cache_destroy(kcp->kcp_cache); -out_kcp: - splat_kmem_cache_test_kcp_free(kcp); -out: - spl_kmem_cache_expire = spl_kmem_cache_expire_old; - - return rc; -} - -/* - * This test creates N threads with a shared kmem cache. They then all - * concurrently allocate and free from the cache to stress the locking and - * concurrent cache performance. If any one test takes longer than 5 - * seconds to complete it is treated as a failure and may indicate a - * performance regression. On my test system no one test takes more - * than 1 second to complete so a 5x slowdown likely a problem. - */ -static int -splat_kmem_test10(struct file *file, void *arg) -{ - uint64_t size, alloc, maxsize, limit, rc = 0; - -#if defined(CONFIG_64BIT) - maxsize = (1024 * 1024); -#else - maxsize = (128 * 1024); -#endif - - for (size = 32; size <= maxsize; size *= 2) { - - splat_vprint(file, SPLAT_KMEM_TEST10_NAME, "%-22s %s", "name", - "time (sec)\tslabs \tobjs \thash\n"); - splat_vprint(file, SPLAT_KMEM_TEST10_NAME, "%-22s %s", "", - " \ttot/max/calc\ttot/max/calc\n"); - - for (alloc = 1; alloc <= 1024; alloc *= 2) { - - /* Skip tests which exceed 1/2 of memory. */ - limit = MIN(physmem * PAGE_SIZE, - vmem_size(NULL, VMEM_ALLOC | VMEM_FREE)) / 2; - if (size * alloc * SPLAT_KMEM_THREADS > limit) - continue; - - rc = splat_kmem_cache_thread_test(file, arg, - SPLAT_KMEM_TEST10_NAME, size, alloc, 5); - if (rc) - break; - } - } - - return rc; -} - -#if 0 -/* - * This test creates N threads with a shared kmem cache which overcommits - * memory by 4x. This makes it impossible for the slab to satify the - * thread requirements without having its reclaim hook run which will - * free objects back for use. This behavior is triggered by the linum VM - * detecting a low memory condition on the node and invoking the shrinkers. - * This should allow all the threads to complete while avoiding deadlock - * and for the most part out of memory events. This is very tough on the - * system so it is possible the test app may get oom'ed. This particular - * test has proven troublesome on 32-bit archs with limited virtual - * address space so it only run on 64-bit systems. - */ -static int -splat_kmem_test11(struct file *file, void *arg) -{ - uint64_t size, alloc, rc; - - size = 8 * 1024; - alloc = ((4 * physmem * PAGE_SIZE) / size) / SPLAT_KMEM_THREADS; - - splat_vprint(file, SPLAT_KMEM_TEST11_NAME, "%-22s %s", "name", - "time (sec)\tslabs \tobjs \thash\n"); - splat_vprint(file, SPLAT_KMEM_TEST11_NAME, "%-22s %s", "", - " \ttot/max/calc\ttot/max/calc\n"); - - rc = splat_kmem_cache_thread_test(file, arg, - SPLAT_KMEM_TEST11_NAME, size, alloc, 60); - - return rc; -} -#endif - -typedef struct dummy_page { - struct list_head dp_list; - char dp_pad[PAGE_SIZE - sizeof(struct list_head)]; -} dummy_page_t; - -/* - * This test is designed to verify that direct reclaim is functioning as - * expected. We allocate a large number of objects thus creating a large - * number of slabs. We then apply memory pressure and expect that the - * direct reclaim path can easily recover those slabs. The registered - * reclaim function will free the objects and the slab shrinker will call - * it repeatedly until at least a single slab can be freed. - * - * Note it may not be possible to reclaim every last slab via direct reclaim - * without a failure because the shrinker_rwsem may be contended. For this - * reason, quickly reclaiming 3/4 of the slabs is considered a success. - * - * This should all be possible within 10 seconds. For reference, on a - * system with 2G of memory this test takes roughly 0.2 seconds to run. - * It may take longer on larger memory systems but should still easily - * complete in the alloted 10 seconds. - */ -static int -splat_kmem_test13(struct file *file, void *arg) -{ - kmem_cache_priv_t *kcp; - kmem_cache_thread_t *kct; - dummy_page_t *dp; - struct list_head list; - struct timespec start, stop, delta = { 0, 0 }; - int size, count, slabs, fails = 0; - int i, rc = 0, max_time = 10; - - size = 128 * 1024; - count = MIN(physmem * PAGE_SIZE, vmem_size(NULL, - VMEM_ALLOC | VMEM_FREE)) / 4 / size; - - kcp = splat_kmem_cache_test_kcp_alloc(file, SPLAT_KMEM_TEST13_NAME, - size, 0, 0); - if (!kcp) { - splat_vprint(file, SPLAT_KMEM_TEST13_NAME, - "Unable to create '%s'\n", "kcp"); - rc = -ENOMEM; - goto out; - } - - kcp->kcp_cache = - kmem_cache_create(SPLAT_KMEM_CACHE_NAME, kcp->kcp_size, 0, - splat_kmem_cache_test_constructor, - splat_kmem_cache_test_destructor, - splat_kmem_cache_test_reclaim, - kcp, NULL, 0); - if (!kcp->kcp_cache) { - splat_vprint(file, SPLAT_KMEM_TEST13_NAME, - "Unable to create '%s'\n", SPLAT_KMEM_CACHE_NAME); - rc = -ENOMEM; - goto out_kcp; - } - - kct = splat_kmem_cache_test_kct_alloc(kcp, 0); - if (!kct) { - splat_vprint(file, SPLAT_KMEM_TEST13_NAME, - "Unable to create '%s'\n", "kct"); - rc = -ENOMEM; - goto out_cache; - } - - rc = splat_kmem_cache_test_kcd_alloc(kcp, kct, count); - if (rc) { - splat_vprint(file, SPLAT_KMEM_TEST13_NAME, "Unable to " - "allocate from '%s'\n", SPLAT_KMEM_CACHE_NAME); - goto out_kct; - } - - i = 0; - slabs = kcp->kcp_cache->skc_slab_total; - INIT_LIST_HEAD(&list); - getnstimeofday(&start); - - /* Apply memory pressure */ - while (kcp->kcp_cache->skc_slab_total > (slabs >> 2)) { - - if ((i % 10000) == 0) - splat_kmem_cache_test_debug( - file, SPLAT_KMEM_TEST13_NAME, kcp); - - getnstimeofday(&stop); - delta = timespec_sub(stop, start); - if (delta.tv_sec >= max_time) { - splat_vprint(file, SPLAT_KMEM_TEST13_NAME, - "Failed to reclaim 3/4 of cache in %ds, " - "%u/%u slabs remain\n", max_time, - (unsigned)kcp->kcp_cache->skc_slab_total, - slabs); - rc = -ETIME; - break; - } - - dp = (dummy_page_t *)__get_free_page(GFP_KERNEL); - if (!dp) { - fails++; - splat_vprint(file, SPLAT_KMEM_TEST13_NAME, - "Failed (%d) to allocate page with %u " - "slabs still in the cache\n", fails, - (unsigned)kcp->kcp_cache->skc_slab_total); - continue; - } - - list_add(&dp->dp_list, &list); - i++; - } - - if (rc == 0) - splat_vprint(file, SPLAT_KMEM_TEST13_NAME, - "Successfully created %u slabs and with %d alloc " - "failures reclaimed 3/4 of them in %d.%03ds\n", - slabs, fails, - (int)delta.tv_sec, (int)delta.tv_nsec / 1000000); - - /* Release memory pressure pages */ - while (!list_empty(&list)) { - dp = list_entry(list.next, dummy_page_t, dp_list); - list_del_init(&dp->dp_list); - free_page((unsigned long)dp); - } - - /* Release remaining kmem cache objects */ - splat_kmem_cache_test_kcd_free(kcp, kct); -out_kct: - splat_kmem_cache_test_kct_free(kcp, kct); -out_cache: - kmem_cache_destroy(kcp->kcp_cache); -out_kcp: - splat_kmem_cache_test_kcp_free(kcp); -out: - return rc; -} - -splat_subsystem_t * -splat_kmem_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_KMEM_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_KMEM_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_KMEM; - - splat_test_init(sub, SPLAT_KMEM_TEST1_NAME, SPLAT_KMEM_TEST1_DESC, - SPLAT_KMEM_TEST1_ID, splat_kmem_test1); - splat_test_init(sub, SPLAT_KMEM_TEST2_NAME, SPLAT_KMEM_TEST2_DESC, - SPLAT_KMEM_TEST2_ID, splat_kmem_test2); - splat_test_init(sub, SPLAT_KMEM_TEST3_NAME, SPLAT_KMEM_TEST3_DESC, - SPLAT_KMEM_TEST3_ID, splat_kmem_test3); - splat_test_init(sub, SPLAT_KMEM_TEST4_NAME, SPLAT_KMEM_TEST4_DESC, - SPLAT_KMEM_TEST4_ID, splat_kmem_test4); - splat_test_init(sub, SPLAT_KMEM_TEST5_NAME, SPLAT_KMEM_TEST5_DESC, - SPLAT_KMEM_TEST5_ID, splat_kmem_test5); - splat_test_init(sub, SPLAT_KMEM_TEST6_NAME, SPLAT_KMEM_TEST6_DESC, - SPLAT_KMEM_TEST6_ID, splat_kmem_test6); - splat_test_init(sub, SPLAT_KMEM_TEST7_NAME, SPLAT_KMEM_TEST7_DESC, - SPLAT_KMEM_TEST7_ID, splat_kmem_test7); - splat_test_init(sub, SPLAT_KMEM_TEST8_NAME, SPLAT_KMEM_TEST8_DESC, - SPLAT_KMEM_TEST8_ID, splat_kmem_test8); - splat_test_init(sub, SPLAT_KMEM_TEST9_NAME, SPLAT_KMEM_TEST9_DESC, - SPLAT_KMEM_TEST9_ID, splat_kmem_test9); - splat_test_init(sub, SPLAT_KMEM_TEST10_NAME, SPLAT_KMEM_TEST10_DESC, - SPLAT_KMEM_TEST10_ID, splat_kmem_test10); -#if 0 - splat_test_init(sub, SPLAT_KMEM_TEST11_NAME, SPLAT_KMEM_TEST11_DESC, - SPLAT_KMEM_TEST11_ID, splat_kmem_test11); -#endif - splat_test_init(sub, SPLAT_KMEM_TEST13_NAME, SPLAT_KMEM_TEST13_DESC, - SPLAT_KMEM_TEST13_ID, splat_kmem_test13); - - return sub; -} - -void -splat_kmem_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - splat_test_fini(sub, SPLAT_KMEM_TEST13_ID); -#if 0 - splat_test_fini(sub, SPLAT_KMEM_TEST11_ID); -#endif - splat_test_fini(sub, SPLAT_KMEM_TEST10_ID); - splat_test_fini(sub, SPLAT_KMEM_TEST9_ID); - splat_test_fini(sub, SPLAT_KMEM_TEST8_ID); - splat_test_fini(sub, SPLAT_KMEM_TEST7_ID); - splat_test_fini(sub, SPLAT_KMEM_TEST6_ID); - splat_test_fini(sub, SPLAT_KMEM_TEST5_ID); - splat_test_fini(sub, SPLAT_KMEM_TEST4_ID); - splat_test_fini(sub, SPLAT_KMEM_TEST3_ID); - splat_test_fini(sub, SPLAT_KMEM_TEST2_ID); - splat_test_fini(sub, SPLAT_KMEM_TEST1_ID); - - kfree(sub); -} - -int -splat_kmem_id(void) { - return SPLAT_SUBSYSTEM_KMEM; -} diff --git a/module/splat/splat-kobj.c b/module/splat/splat-kobj.c deleted file mode 100644 index bd44de395..000000000 --- a/module/splat/splat-kobj.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Kobj Tests. - */ - -#include -#include "splat-internal.h" - -#define SPLAT_KOBJ_NAME "kobj" -#define SPLAT_KOBJ_DESC "Kernel Kobj Tests" - -#define SPLAT_KOBJ_TEST1_ID 0x0a01 -#define SPLAT_KOBJ_TEST1_NAME "open" -#define SPLAT_KOBJ_TEST1_DESC "Kobj Open/Close Test" - -#define SPLAT_KOBJ_TEST2_ID 0x0a02 -#define SPLAT_KOBJ_TEST2_NAME "size/read" -#define SPLAT_KOBJ_TEST2_DESC "Kobj Size/Read Test" - -#define SPLAT_KOBJ_TEST_FILE "/etc/fstab" - -static int -splat_kobj_test1(struct file *file, void *arg) -{ - struct _buf *f; - - f = kobj_open_file(SPLAT_KOBJ_TEST_FILE); - if (f == (struct _buf *)-1) { - splat_vprint(file, SPLAT_KOBJ_TEST1_NAME, "Failed to open " - "test file: %s\n", SPLAT_KOBJ_TEST_FILE); - return -ENOENT; - } - - kobj_close_file(f); - splat_vprint(file, SPLAT_KOBJ_TEST1_NAME, "Successfully opened and " - "closed test file: %s\n", SPLAT_KOBJ_TEST_FILE); - - return 0; -} /* splat_kobj_test1() */ - -static int -splat_kobj_test2(struct file *file, void *arg) -{ - struct _buf *f; - char *buf; - uint64_t size; - int rc; - - f = kobj_open_file(SPLAT_KOBJ_TEST_FILE); - if (f == (struct _buf *)-1) { - splat_vprint(file, SPLAT_KOBJ_TEST2_NAME, "Failed to open " - "test file: %s\n", SPLAT_KOBJ_TEST_FILE); - return -ENOENT; - } - - rc = kobj_get_filesize(f, &size); - if (rc) { - splat_vprint(file, SPLAT_KOBJ_TEST2_NAME, "Failed stat of " - "test file: %s (%d)\n", SPLAT_KOBJ_TEST_FILE, rc); - goto out; - } - - buf = kmalloc(size + 1, GFP_KERNEL); - if (!buf) { - rc = -ENOMEM; - splat_vprint(file, SPLAT_KOBJ_TEST2_NAME, "Failed to alloc " - "%lld bytes for tmp buffer (%d)\n", - (long long)size, rc); - goto out; - } - - memset(buf, 0, size + 1); - rc = kobj_read_file(f, buf, size, 0); - if (rc < 0) { - splat_vprint(file, SPLAT_KOBJ_TEST2_NAME, "Failed read of " - "test file: %s (%d)\n", SPLAT_KOBJ_TEST_FILE, rc); - goto out2; - } - - /* Validate we read as many bytes as expected based on the stat. This - * isn't a perfect test since we didn't create the file however it is - * pretty unlikely there are garbage characters in your /etc/fstab */ - if (size != (uint64_t)strlen(buf)) { - rc = -EFBIG; - splat_vprint(file, SPLAT_KOBJ_TEST2_NAME, "Stat'ed size " - "(%lld) does not match number of bytes read " - "(%lld)\n", (long long)size, - (long long)strlen(buf)); - goto out2; - } - - rc = 0; - splat_vprint(file, SPLAT_KOBJ_TEST2_NAME, "\n%s\n", buf); - splat_vprint(file, SPLAT_KOBJ_TEST2_NAME, "Successfully stat'ed " - "and read expected number of bytes (%lld) from test " - "file: %s\n", (long long)size, SPLAT_KOBJ_TEST_FILE); -out2: - kfree(buf); -out: - kobj_close_file(f); - - return rc; -} /* splat_kobj_test2() */ - -splat_subsystem_t * -splat_kobj_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_KOBJ_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_KOBJ_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_KOBJ; - - splat_test_init(sub, SPLAT_KOBJ_TEST1_NAME, SPLAT_KOBJ_TEST1_DESC, - SPLAT_KOBJ_TEST1_ID, splat_kobj_test1); - splat_test_init(sub, SPLAT_KOBJ_TEST2_NAME, SPLAT_KOBJ_TEST2_DESC, - SPLAT_KOBJ_TEST2_ID, splat_kobj_test2); - - return sub; -} /* splat_kobj_init() */ - -void -splat_kobj_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - - splat_test_fini(sub, SPLAT_KOBJ_TEST2_ID); - splat_test_fini(sub, SPLAT_KOBJ_TEST1_ID); - - kfree(sub); -} /* splat_kobj_fini() */ - -int -splat_kobj_id(void) -{ - return SPLAT_SUBSYSTEM_KOBJ; -} /* splat_kobj_id() */ diff --git a/module/splat/splat-linux.c b/module/splat/splat-linux.c deleted file mode 100644 index 1565d74a3..000000000 --- a/module/splat/splat-linux.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (C) 2011 Lawrence Livermore National Security, LLC. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Kernel Compatibility Tests. - */ - -#include -#include -#include "splat-internal.h" - -#define SPLAT_LINUX_NAME "linux" -#define SPLAT_LINUX_DESC "Kernel Compatibility Tests" - -#define SPLAT_LINUX_TEST1_ID 0x1001 -#define SPLAT_LINUX_TEST1_NAME "shrinker" -#define SPLAT_LINUX_TEST1_DESC "Shrinker test" - -/* - * Wait queue used to eliminate race between dropping of slab - * and execution of the shrinker callback - */ -DECLARE_WAIT_QUEUE_HEAD(shrinker_wait); - -SPL_SHRINKER_CALLBACK_FWD_DECLARE(splat_linux_shrinker_fn); -SPL_SHRINKER_DECLARE(splat_linux_shrinker, splat_linux_shrinker_fn, 1); -static unsigned long splat_linux_shrinker_size = 0; -static struct file *splat_linux_shrinker_file = NULL; - -static spl_shrinker_t -__splat_linux_shrinker_fn(struct shrinker *shrink, struct shrink_control *sc) -{ - static int failsafe = 0; - static unsigned long last_splat_linux_shrinker_size = 0; - unsigned long size; - spl_shrinker_t count; - - /* - * shrinker_size can only decrease or stay the same between callbacks - * in the same run, so Reset failsafe whenever shrinker increases - * as this indicates a new run. - */ - if (last_splat_linux_shrinker_size < splat_linux_shrinker_size) - failsafe = 0; - - last_splat_linux_shrinker_size = splat_linux_shrinker_size; - - if (sc->nr_to_scan) { - size = MIN(sc->nr_to_scan, splat_linux_shrinker_size); - splat_linux_shrinker_size -= size; - - splat_vprint(splat_linux_shrinker_file, SPLAT_LINUX_TEST1_NAME, - "Reclaimed %lu objects, size now %lu\n", - size, splat_linux_shrinker_size); - -#ifdef HAVE_SPLIT_SHRINKER_CALLBACK - count = size; -#else - count = splat_linux_shrinker_size; -#endif /* HAVE_SPLIT_SHRINKER_CALLBACK */ - - } else { - count = splat_linux_shrinker_size; - splat_vprint(splat_linux_shrinker_file, SPLAT_LINUX_TEST1_NAME, - "Cache size is %lu\n", splat_linux_shrinker_size); - } - - /* Far more calls than expected abort drop_slab as a failsafe */ - if (failsafe > 100) { - splat_vprint(splat_linux_shrinker_file, SPLAT_LINUX_TEST1_NAME, - "Far more calls than expected (%d), size now %lu\n", - failsafe, splat_linux_shrinker_size); - return (SHRINK_STOP); - } else { - /* - * We only increment failsafe if it doesn't trigger. This - * makes any failsafe failure persistent until the next test. - */ - failsafe++; - } - - /* Shrinker has run, so signal back to test. */ - wake_up(&shrinker_wait); - - return (count); -} - -SPL_SHRINKER_CALLBACK_WRAPPER(splat_linux_shrinker_fn); - -#define DROP_SLAB_CMD \ - "exec 0/proc/sys/vm/drop_caches " \ - " 2>/dev/null; " \ - "echo 2" - -static int -splat_linux_drop_slab(struct file *file) -{ - char *argv[] = { "/bin/sh", - "-c", - DROP_SLAB_CMD, - NULL }; - char *envp[] = { "HOME=/", - "TERM=linux", - "PATH=/sbin:/usr/sbin:/bin:/usr/bin", - NULL }; - int rc; - - rc = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC); - if (rc) - splat_vprint(file, SPLAT_LINUX_TEST1_NAME, - "Failed user helper '%s %s %s', rc = %d\n", - argv[0], argv[1], argv[2], rc); - - return rc; -} - -/* - * Verify correct shrinker functionality by registering a shrinker - * with the required compatibility macros. We then use a simulated - * cache and force the systems caches to be dropped. The shrinker - * should be repeatedly called until it reports that the cache is - * empty. It is then cleanly unregistered and correct behavior is - * verified. There are now four slightly different supported shrinker - * API and this test ensures the compatibility code is correct. - */ -static int -splat_linux_test1(struct file *file, void *arg) -{ - int rc = -EINVAL; - - /* - * Globals used by the shrinker, it is not safe to run this - * test concurrently this is a safe assumption for SPLAT tests. - * Regardless we do some minimal checking a bail if concurrent - * use is detected. - */ - if (splat_linux_shrinker_size || splat_linux_shrinker_file) { - splat_vprint(file, SPLAT_LINUX_TEST1_NAME, - "Failed due to concurrent shrinker test, rc = %d\n", rc); - return (rc); - } - - splat_linux_shrinker_size = 1024; - splat_linux_shrinker_file = file; - - spl_register_shrinker(&splat_linux_shrinker); - rc = splat_linux_drop_slab(file); - if (rc) - goto out; - - /* - * By the time we get here, it is possible that the shrinker has not - * yet run. splat_linux_drop_slab sends a signal for it to run, but - * there is no guarantee of when it will actually run. We wait for it - * to run here, terminating when either the shrinker size is now 0 or - * we timeout after 1 second, which should be an eternity (error). - */ - rc = wait_event_timeout(shrinker_wait, !splat_linux_shrinker_size, HZ); - if (!rc) { - splat_vprint(file, SPLAT_LINUX_TEST1_NAME, - "Failed cache shrinking timed out, size now %lu", - splat_linux_shrinker_size); - rc = -ETIMEDOUT; - } else { - rc = 0; - } - - if (!rc && splat_linux_shrinker_size != 0) { - splat_vprint(file, SPLAT_LINUX_TEST1_NAME, - "Failed cache was not shrunk to 0, size now %lu", - splat_linux_shrinker_size); - rc = -EDOM; - } -out: - spl_unregister_shrinker(&splat_linux_shrinker); - - splat_linux_shrinker_size = 0; - splat_linux_shrinker_file = NULL; - - return rc; -} - -splat_subsystem_t * -splat_linux_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_LINUX_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_LINUX_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_LINUX; - - splat_test_init(sub, SPLAT_LINUX_TEST1_NAME, SPLAT_LINUX_TEST1_DESC, - SPLAT_LINUX_TEST1_ID, splat_linux_test1); - - return sub; -} - -void -splat_linux_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - splat_test_fini(sub, SPLAT_LINUX_TEST1_ID); - - kfree(sub); -} - -int -splat_linux_id(void) { - return SPLAT_SUBSYSTEM_LINUX; -} diff --git a/module/splat/splat-list.c b/module/splat/splat-list.c deleted file mode 100644 index 8a5f3c937..000000000 --- a/module/splat/splat-list.c +++ /dev/null @@ -1,475 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) List Tests. - */ - -#include -#include -#include "splat-internal.h" - -#define SPLAT_LIST_NAME "list" -#define SPLAT_LIST_DESC "Kernel List Tests" - -#define SPLAT_LIST_TEST1_ID 0x0c01 -#define SPLAT_LIST_TEST1_NAME "create/destroy" -#define SPLAT_LIST_TEST1_DESC "Create/destroy Test" - -#define SPLAT_LIST_TEST2_ID 0x0c02 -#define SPLAT_LIST_TEST2_NAME "ins/rm head" -#define SPLAT_LIST_TEST2_DESC "Insert/remove head Test" - -#define SPLAT_LIST_TEST3_ID 0x0c03 -#define SPLAT_LIST_TEST3_NAME "ins/rm tail" -#define SPLAT_LIST_TEST3_DESC "Insert/remove tail Test" - -#define SPLAT_LIST_TEST4_ID 0x0c04 -#define SPLAT_LIST_TEST4_NAME "insert_after" -#define SPLAT_LIST_TEST4_DESC "Insert_after Test" - -#define SPLAT_LIST_TEST5_ID 0x0c05 -#define SPLAT_LIST_TEST5_NAME "insert_before" -#define SPLAT_LIST_TEST5_DESC "Insert_before Test" - -#define SPLAT_LIST_TEST6_ID 0x0c06 -#define SPLAT_LIST_TEST6_NAME "remove" -#define SPLAT_LIST_TEST6_DESC "Remove Test" - -#define SPLAT_LIST_TEST7_ID 0x0c7 -#define SPLAT_LIST_TEST7_NAME "active" -#define SPLAT_LIST_TEST7_DESC "Active Test" - -/* It is important that li_node is not the first element, this - * ensures the list_d2l/list_object macros are working correctly. */ -typedef struct list_item { - int li_data; - list_node_t li_node; -} list_item_t; - -#define LIST_ORDER_STACK 0 -#define LIST_ORDER_QUEUE 1 - -static int -splat_list_test1(struct file *file, void *arg) -{ - list_t list; - - splat_vprint(file, SPLAT_LIST_TEST1_NAME, "Creating list\n%s", ""); - list_create(&list, sizeof(list_item_t), offsetof(list_item_t, li_node)); - - if (!list_is_empty(&list)) { - splat_vprint(file, SPLAT_LIST_TEST1_NAME, - "New list NOT empty%s\n", ""); - /* list_destroy() intentionally skipped to avoid assert */ - return -EEXIST; - } - - splat_vprint(file, SPLAT_LIST_TEST1_NAME, "Destroying list\n%s", ""); - list_destroy(&list); - - /* Validate the list has been destroyed */ - if (list_link_active(&list.list_head)) { - splat_vprint(file, SPLAT_LIST_TEST1_NAME, - "Destroyed list still active%s", ""); - return -EIO; - } - - return 0; -} - -static int -splat_list_validate(list_t *list, int size, int order, int mult) -{ - list_item_t *li; - int i; - - /* Walk all items in list from head to verify stack or queue - * ordering. We bound the for loop by size+1 to ensure that - * we still terminate if there is list corruption. We also - * intentionally make things a little more complex than they - * need to be by using list_head/list_next for queues, and - * list_tail/list_prev for stacks. This is simply done for - * coverage and to ensure these function are working right. - */ - for (i = 0, li = (order ? list_head(list) : list_tail(list)); - i < size + 1 && li != NULL; - i++, li = (order ? list_next(list, li) : list_prev(list, li))) - if (li->li_data != i * mult) - return -EIDRM; - - if (i != size) - return -E2BIG; - - return 0; -} - -static int -splat_list_test2(struct file *file, void *arg) -{ - list_t list; - list_item_t *li; - int i, list_size = 8, rc = 0; - - splat_vprint(file, SPLAT_LIST_TEST2_NAME, "Creating list\n%s", ""); - list_create(&list, sizeof(list_item_t), offsetof(list_item_t, li_node)); - - /* Insert all items at the list head to form a stack */ - splat_vprint(file, SPLAT_LIST_TEST2_NAME, - "Adding %d items to list head\n", list_size); - for (i = 0; i < list_size; i++) { - li = kmem_alloc(sizeof(list_item_t), KM_SLEEP); - if (li == NULL) { - rc = -ENOMEM; - goto out; - } - - list_link_init(&li->li_node); - li->li_data = i; - list_insert_head(&list, li); - } - - splat_vprint(file, SPLAT_LIST_TEST2_NAME, - "Validating %d item list is a stack\n", list_size); - rc = splat_list_validate(&list, list_size, LIST_ORDER_STACK, 1); - if (rc) - splat_vprint(file, SPLAT_LIST_TEST2_NAME, - "List validation failed, %d\n", rc); -out: - /* Remove all items */ - splat_vprint(file, SPLAT_LIST_TEST2_NAME, - "Removing %d items from list head\n", list_size); - while ((li = list_remove_head(&list))) - kmem_free(li, sizeof(list_item_t)); - - splat_vprint(file, SPLAT_LIST_TEST2_NAME, "Destroying list\n%s", ""); - list_destroy(&list); - - return rc; -} - -static int -splat_list_test3(struct file *file, void *arg) -{ - list_t list; - list_item_t *li; - int i, list_size = 8, rc = 0; - - splat_vprint(file, SPLAT_LIST_TEST3_NAME, "Creating list\n%s", ""); - list_create(&list, sizeof(list_item_t), offsetof(list_item_t, li_node)); - - /* Insert all items at the list tail to form a queue */ - splat_vprint(file, SPLAT_LIST_TEST3_NAME, - "Adding %d items to list tail\n", list_size); - for (i = 0; i < list_size; i++) { - li = kmem_alloc(sizeof(list_item_t), KM_SLEEP); - if (li == NULL) { - rc = -ENOMEM; - goto out; - } - - list_link_init(&li->li_node); - li->li_data = i; - list_insert_tail(&list, li); - } - - splat_vprint(file, SPLAT_LIST_TEST3_NAME, - "Validating %d item list is a queue\n", list_size); - rc = splat_list_validate(&list, list_size, LIST_ORDER_QUEUE, 1); - if (rc) - splat_vprint(file, SPLAT_LIST_TEST3_NAME, - "List validation failed, %d\n", rc); -out: - /* Remove all items */ - splat_vprint(file, SPLAT_LIST_TEST3_NAME, - "Removing %d items from list tail\n", list_size); - while ((li = list_remove_tail(&list))) - kmem_free(li, sizeof(list_item_t)); - - splat_vprint(file, SPLAT_LIST_TEST3_NAME, "Destroying list\n%s", ""); - list_destroy(&list); - - return rc; -} - -static int -splat_list_test4(struct file *file, void *arg) -{ - list_t list; - list_item_t *li_new, *li_last = NULL; - int i, list_size = 8, rc = 0; - - splat_vprint(file, SPLAT_LIST_TEST4_NAME, "Creating list\n%s", ""); - list_create(&list, sizeof(list_item_t), offsetof(list_item_t, li_node)); - - /* Insert all items after the last item to form a queue */ - splat_vprint(file, SPLAT_LIST_TEST4_NAME, - "Adding %d items each after the last item\n", list_size); - for (i = 0; i < list_size; i++) { - li_new = kmem_alloc(sizeof(list_item_t), KM_SLEEP); - if (li_new == NULL) { - rc = -ENOMEM; - goto out; - } - - list_link_init(&li_new->li_node); - li_new->li_data = i; - list_insert_after(&list, li_last, li_new); - li_last = li_new; - } - - splat_vprint(file, SPLAT_LIST_TEST4_NAME, - "Validating %d item list is a queue\n", list_size); - rc = splat_list_validate(&list, list_size, LIST_ORDER_QUEUE, 1); - if (rc) - splat_vprint(file, SPLAT_LIST_TEST4_NAME, - "List validation failed, %d\n", rc); -out: - /* Remove all items */ - splat_vprint(file, SPLAT_LIST_TEST4_NAME, - "Removing %d items from list tail\n", list_size); - while ((li_new = list_remove_head(&list))) - kmem_free(li_new, sizeof(list_item_t)); - - splat_vprint(file, SPLAT_LIST_TEST4_NAME, "Destroying list\n%s", ""); - list_destroy(&list); - - return rc; -} - -static int -splat_list_test5(struct file *file, void *arg) -{ - list_t list; - list_item_t *li_new, *li_last = NULL; - int i, list_size = 8, rc = 0; - - splat_vprint(file, SPLAT_LIST_TEST5_NAME, "Creating list\n%s", ""); - list_create(&list, sizeof(list_item_t), offsetof(list_item_t, li_node)); - - /* Insert all items before the last item to form a stack */ - splat_vprint(file, SPLAT_LIST_TEST5_NAME, - "Adding %d items each before the last item\n", list_size); - for (i = 0; i < list_size; i++) { - li_new = kmem_alloc(sizeof(list_item_t), KM_SLEEP); - if (li_new == NULL) { - rc = -ENOMEM; - goto out; - } - - list_link_init(&li_new->li_node); - li_new->li_data = i; - list_insert_before(&list, li_last, li_new); - li_last = li_new; - } - - splat_vprint(file, SPLAT_LIST_TEST5_NAME, - "Validating %d item list is a queue\n", list_size); - rc = splat_list_validate(&list, list_size, LIST_ORDER_STACK, 1); - if (rc) - splat_vprint(file, SPLAT_LIST_TEST5_NAME, - "List validation failed, %d\n", rc); -out: - /* Remove all items */ - splat_vprint(file, SPLAT_LIST_TEST5_NAME, - "Removing %d items from list tail\n", list_size); - while ((li_new = list_remove_tail(&list))) - kmem_free(li_new, sizeof(list_item_t)); - - splat_vprint(file, SPLAT_LIST_TEST5_NAME, "Destroying list\n%s", ""); - list_destroy(&list); - - return rc; -} - -static int -splat_list_test6(struct file *file, void *arg) -{ - list_t list; - list_item_t *li, *li_prev; - int i, list_size = 8, rc = 0; - - splat_vprint(file, SPLAT_LIST_TEST6_NAME, "Creating list\n%s", ""); - list_create(&list, sizeof(list_item_t), offsetof(list_item_t, li_node)); - - /* Insert all items at the list tail to form a queue */ - splat_vprint(file, SPLAT_LIST_TEST6_NAME, - "Adding %d items to list tail\n", list_size); - for (i = 0; i < list_size; i++) { - li = kmem_alloc(sizeof(list_item_t), KM_SLEEP); - if (li == NULL) { - rc = -ENOMEM; - goto out; - } - - list_link_init(&li->li_node); - li->li_data = i; - list_insert_tail(&list, li); - } - - /* Remove all odd items from the queue */ - splat_vprint(file, SPLAT_LIST_TEST6_NAME, - "Removing %d odd items from the list\n", list_size >> 1); - for (li = list_head(&list); li != NULL; li = list_next(&list, li)) { - if (li->li_data % 2 == 1) { - li_prev = list_prev(&list, li); - list_remove(&list, li); - kmem_free(li, sizeof(list_item_t)); - li = li_prev; - } - } - - splat_vprint(file, SPLAT_LIST_TEST6_NAME, "Validating %d item " - "list is a queue of only even elements\n", list_size / 2); - rc = splat_list_validate(&list, list_size / 2, LIST_ORDER_QUEUE, 2); - if (rc) - splat_vprint(file, SPLAT_LIST_TEST6_NAME, - "List validation failed, %d\n", rc); -out: - /* Remove all items */ - splat_vprint(file, SPLAT_LIST_TEST6_NAME, - "Removing %d items from list tail\n", list_size / 2); - while ((li = list_remove_tail(&list))) - kmem_free(li, sizeof(list_item_t)); - - splat_vprint(file, SPLAT_LIST_TEST6_NAME, "Destroying list\n%s", ""); - list_destroy(&list); - - return rc; -} - -static int -splat_list_test7(struct file *file, void *arg) -{ - list_t list; - list_item_t *li; - int rc = 0; - - splat_vprint(file, SPLAT_LIST_TEST7_NAME, "Creating list\n%s", ""); - list_create(&list, sizeof(list_item_t), offsetof(list_item_t, li_node)); - - li = kmem_alloc(sizeof(list_item_t), KM_SLEEP); - if (li == NULL) { - rc = -ENOMEM; - goto out; - } - - /* Validate newly initialized node is inactive */ - splat_vprint(file, SPLAT_LIST_TEST7_NAME, "Init list node\n%s", ""); - list_link_init(&li->li_node); - if (list_link_active(&li->li_node)) { - splat_vprint(file, SPLAT_LIST_TEST7_NAME, "Newly initialized " - "list node should inactive %p/%p\n", - li->li_node.prev, li->li_node.next); - rc = -EINVAL; - goto out_li; - } - - /* Validate node is active when linked in to a list */ - splat_vprint(file, SPLAT_LIST_TEST7_NAME, "Insert list node\n%s", ""); - list_insert_head(&list, li); - if (!list_link_active(&li->li_node)) { - splat_vprint(file, SPLAT_LIST_TEST7_NAME, "List node " - "inserted in list should be active %p/%p\n", - li->li_node.prev, li->li_node.next); - rc = -EINVAL; - goto out; - } - - /* Validate node is inactive when removed from list */ - splat_vprint(file, SPLAT_LIST_TEST7_NAME, "Remove list node\n%s", ""); - list_remove(&list, li); - if (list_link_active(&li->li_node)) { - splat_vprint(file, SPLAT_LIST_TEST7_NAME, "List node " - "removed from list should be inactive %p/%p\n", - li->li_node.prev, li->li_node.next); - rc = -EINVAL; - } -out_li: - kmem_free(li, sizeof(list_item_t)); -out: - /* Remove all items */ - while ((li = list_remove_head(&list))) - kmem_free(li, sizeof(list_item_t)); - - splat_vprint(file, SPLAT_LIST_TEST7_NAME, "Destroying list\n%s", ""); - list_destroy(&list); - - return rc; -} - -splat_subsystem_t * -splat_list_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_LIST_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_LIST_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_LIST; - - splat_test_init(sub, SPLAT_LIST_TEST1_NAME, SPLAT_LIST_TEST1_DESC, - SPLAT_LIST_TEST1_ID, splat_list_test1); - splat_test_init(sub, SPLAT_LIST_TEST2_NAME, SPLAT_LIST_TEST2_DESC, - SPLAT_LIST_TEST2_ID, splat_list_test2); - splat_test_init(sub, SPLAT_LIST_TEST3_NAME, SPLAT_LIST_TEST3_DESC, - SPLAT_LIST_TEST3_ID, splat_list_test3); - splat_test_init(sub, SPLAT_LIST_TEST4_NAME, SPLAT_LIST_TEST4_DESC, - SPLAT_LIST_TEST4_ID, splat_list_test4); - splat_test_init(sub, SPLAT_LIST_TEST5_NAME, SPLAT_LIST_TEST5_DESC, - SPLAT_LIST_TEST5_ID, splat_list_test5); - splat_test_init(sub, SPLAT_LIST_TEST6_NAME, SPLAT_LIST_TEST6_DESC, - SPLAT_LIST_TEST6_ID, splat_list_test6); - splat_test_init(sub, SPLAT_LIST_TEST7_NAME, SPLAT_LIST_TEST7_DESC, - SPLAT_LIST_TEST7_ID, splat_list_test7); - - return sub; -} - -void -splat_list_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - - splat_test_fini(sub, SPLAT_LIST_TEST7_ID); - splat_test_fini(sub, SPLAT_LIST_TEST6_ID); - splat_test_fini(sub, SPLAT_LIST_TEST5_ID); - splat_test_fini(sub, SPLAT_LIST_TEST4_ID); - splat_test_fini(sub, SPLAT_LIST_TEST3_ID); - splat_test_fini(sub, SPLAT_LIST_TEST2_ID); - splat_test_fini(sub, SPLAT_LIST_TEST1_ID); - - kfree(sub); -} - -int -splat_list_id(void) -{ - return SPLAT_SUBSYSTEM_LIST; -} diff --git a/module/splat/splat-mutex.c b/module/splat/splat-mutex.c deleted file mode 100644 index 202e6c0f6..000000000 --- a/module/splat/splat-mutex.c +++ /dev/null @@ -1,447 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Mutex Tests. - */ - -#include -#include -#include -#include -#include "splat-internal.h" - -#define SPLAT_MUTEX_NAME "mutex" -#define SPLAT_MUTEX_DESC "Kernel Mutex Tests" - -#define SPLAT_MUTEX_TEST1_ID 0x0401 -#define SPLAT_MUTEX_TEST1_NAME "tryenter" -#define SPLAT_MUTEX_TEST1_DESC "Validate mutex_tryenter() correctness" - -#define SPLAT_MUTEX_TEST2_ID 0x0402 -#define SPLAT_MUTEX_TEST2_NAME "race" -#define SPLAT_MUTEX_TEST2_DESC "Many threads entering/exiting the mutex" - -#define SPLAT_MUTEX_TEST3_ID 0x0403 -#define SPLAT_MUTEX_TEST3_NAME "owned" -#define SPLAT_MUTEX_TEST3_DESC "Validate mutex_owned() correctness" - -#define SPLAT_MUTEX_TEST4_ID 0x0404 -#define SPLAT_MUTEX_TEST4_NAME "owner" -#define SPLAT_MUTEX_TEST4_DESC "Validate mutex_owner() correctness" - -#define SPLAT_MUTEX_TEST_MAGIC 0x115599DDUL -#define SPLAT_MUTEX_TEST_NAME "mutex_test" -#define SPLAT_MUTEX_TEST_TASKQ "mutex_taskq" -#define SPLAT_MUTEX_TEST_COUNT 128 - -typedef struct mutex_priv { - unsigned long mp_magic; - struct file *mp_file; - kmutex_t mp_mtx; - int mp_rc; - int mp_rc2; -} mutex_priv_t; - -static void -splat_mutex_test1_func(void *arg) -{ - mutex_priv_t *mp = (mutex_priv_t *)arg; - ASSERT(mp->mp_magic == SPLAT_MUTEX_TEST_MAGIC); - - if (mutex_tryenter(&mp->mp_mtx)) { - mp->mp_rc = 0; - mutex_exit(&mp->mp_mtx); - } else { - mp->mp_rc = -EBUSY; - } -} - -static int -splat_mutex_test1(struct file *file, void *arg) -{ - mutex_priv_t *mp; - taskq_t *tq; - taskqid_t id; - int rc = 0; - - mp = (mutex_priv_t *)kmalloc(sizeof(*mp), GFP_KERNEL); - if (mp == NULL) - return -ENOMEM; - - tq = taskq_create(SPLAT_MUTEX_TEST_TASKQ, 1, defclsyspri, - 50, INT_MAX, TASKQ_PREPOPULATE); - if (tq == NULL) { - rc = -ENOMEM; - goto out2; - } - - mp->mp_magic = SPLAT_MUTEX_TEST_MAGIC; - mp->mp_file = file; - mutex_init(&mp->mp_mtx, SPLAT_MUTEX_TEST_NAME, MUTEX_DEFAULT, NULL); - mutex_enter(&mp->mp_mtx); - - /* - * Schedule a task function which will try and acquire the mutex via - * mutex_tryenter() while it's held. This should fail and the task - * function will indicate this status in the passed private data. - */ - mp->mp_rc = -EINVAL; - id = taskq_dispatch(tq, splat_mutex_test1_func, mp, TQ_SLEEP); - if (id == TASKQID_INVALID) { - mutex_exit(&mp->mp_mtx); - splat_vprint(file, SPLAT_MUTEX_TEST1_NAME, "%s", - "taskq_dispatch() failed\n"); - rc = -EINVAL; - goto out; - } - - taskq_wait_id(tq, id); - mutex_exit(&mp->mp_mtx); - - /* Task function successfully acquired mutex, very bad! */ - if (mp->mp_rc != -EBUSY) { - splat_vprint(file, SPLAT_MUTEX_TEST1_NAME, - "mutex_trylock() incorrectly succeeded when " - "the mutex was held, %d/%d\n", (int)id, mp->mp_rc); - rc = -EINVAL; - goto out; - } else { - splat_vprint(file, SPLAT_MUTEX_TEST1_NAME, "%s", - "mutex_trylock() correctly failed when " - "the mutex was held\n"); - } - - /* - * Schedule a task function which will try and acquire the mutex via - * mutex_tryenter() while it is not held. This should succeed and - * can be verified by checking the private data. - */ - mp->mp_rc = -EINVAL; - id = taskq_dispatch(tq, splat_mutex_test1_func, mp, TQ_SLEEP); - if (id == TASKQID_INVALID) { - splat_vprint(file, SPLAT_MUTEX_TEST1_NAME, "%s", - "taskq_dispatch() failed\n"); - rc = -EINVAL; - goto out; - } - - taskq_wait_id(tq, id); - - /* Task function failed to acquire mutex, very bad! */ - if (mp->mp_rc != 0) { - splat_vprint(file, SPLAT_MUTEX_TEST1_NAME, - "mutex_trylock() incorrectly failed when the mutex " - "was not held, %d/%d\n", (int)id, mp->mp_rc); - rc = -EINVAL; - } else { - splat_vprint(file, SPLAT_MUTEX_TEST1_NAME, "%s", - "mutex_trylock() correctly succeeded " - "when the mutex was not held\n"); - } -out: - taskq_destroy(tq); - mutex_destroy(&(mp->mp_mtx)); -out2: - kfree(mp); - return rc; -} - -static void -splat_mutex_test2_func(void *arg) -{ - mutex_priv_t *mp = (mutex_priv_t *)arg; - int rc; - ASSERT(mp->mp_magic == SPLAT_MUTEX_TEST_MAGIC); - - /* Read the value before sleeping and write it after we wake up to - * maximize the chance of a race if mutexs are not working properly */ - mutex_enter(&mp->mp_mtx); - rc = mp->mp_rc; - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(HZ / 100); /* 1/100 of a second */ - VERIFY(mp->mp_rc == rc); - mp->mp_rc = rc + 1; - mutex_exit(&mp->mp_mtx); -} - -static int -splat_mutex_test2(struct file *file, void *arg) -{ - mutex_priv_t *mp; - taskq_t *tq; - taskqid_t id; - int i, rc = 0; - - mp = (mutex_priv_t *)kmalloc(sizeof(*mp), GFP_KERNEL); - if (mp == NULL) - return -ENOMEM; - - /* Create several threads allowing tasks to race with each other */ - tq = taskq_create(SPLAT_MUTEX_TEST_TASKQ, num_online_cpus(), - defclsyspri, 50, INT_MAX, TASKQ_PREPOPULATE); - if (tq == NULL) { - rc = -ENOMEM; - goto out; - } - - mp->mp_magic = SPLAT_MUTEX_TEST_MAGIC; - mp->mp_file = file; - mutex_init(&(mp->mp_mtx), SPLAT_MUTEX_TEST_NAME, MUTEX_DEFAULT, NULL); - mp->mp_rc = 0; - - /* - * Schedule N work items to the work queue each of which enters the - * mutex, sleeps briefly, then exits the mutex. On a multiprocessor - * box these work items will be handled by all available CPUs. The - * task function checks to ensure the tracked shared variable is - * always only incremented by one. Additionally, the mutex itself - * is instrumented such that if any two processors are in the - * critical region at the same time the system will panic. If the - * mutex is implemented right this will never happy, that's a pass. - */ - for (i = 0; i < SPLAT_MUTEX_TEST_COUNT; i++) { - id = taskq_dispatch(tq, splat_mutex_test2_func, mp, TQ_SLEEP); - if (id == TASKQID_INVALID) { - splat_vprint(file, SPLAT_MUTEX_TEST2_NAME, - "Failed to queue task %d\n", i); - rc = -EINVAL; - } - } - - taskq_wait(tq); - - if (mp->mp_rc == SPLAT_MUTEX_TEST_COUNT) { - splat_vprint(file, SPLAT_MUTEX_TEST2_NAME, "%d racing threads " - "correctly entered/exited the mutex %d times\n", - num_online_cpus(), mp->mp_rc); - } else { - splat_vprint(file, SPLAT_MUTEX_TEST2_NAME, "%d racing threads " - "only processed %d/%d mutex work items\n", - num_online_cpus(),mp->mp_rc,SPLAT_MUTEX_TEST_COUNT); - rc = -EINVAL; - } - - taskq_destroy(tq); - mutex_destroy(&(mp->mp_mtx)); -out: - kfree(mp); - return rc; -} - -static void -splat_mutex_owned(void *priv) -{ - mutex_priv_t *mp = (mutex_priv_t *)priv; - - ASSERT(mp->mp_magic == SPLAT_MUTEX_TEST_MAGIC); - mp->mp_rc = mutex_owned(&mp->mp_mtx); - mp->mp_rc2 = MUTEX_HELD(&mp->mp_mtx); -} - -static int -splat_mutex_test3(struct file *file, void *arg) -{ - mutex_priv_t mp; - taskq_t *tq; - taskqid_t id; - int rc = 0; - - mp.mp_magic = SPLAT_MUTEX_TEST_MAGIC; - mp.mp_file = file; - mutex_init(&mp.mp_mtx, SPLAT_MUTEX_TEST_NAME, MUTEX_DEFAULT, NULL); - - if ((tq = taskq_create(SPLAT_MUTEX_TEST_NAME, 1, defclsyspri, - 50, INT_MAX, TASKQ_PREPOPULATE)) == NULL) { - splat_vprint(file, SPLAT_MUTEX_TEST3_NAME, "Taskq '%s' " - "create failed\n", SPLAT_MUTEX_TEST3_NAME); - return -EINVAL; - } - - mutex_enter(&mp.mp_mtx); - - /* Mutex should be owned by current */ - if (!mutex_owned(&mp.mp_mtx)) { - splat_vprint(file, SPLAT_MUTEX_TEST3_NAME, "Unowned mutex " - "should be owned by pid %d\n", current->pid); - rc = -EINVAL; - goto out_exit; - } - - id = taskq_dispatch(tq, splat_mutex_owned, &mp, TQ_SLEEP); - if (id == TASKQID_INVALID) { - splat_vprint(file, SPLAT_MUTEX_TEST3_NAME, "Failed to " - "dispatch function '%s' to taskq\n", - sym2str(splat_mutex_owned)); - rc = -EINVAL; - goto out_exit; - } - taskq_wait(tq); - - /* Mutex should not be owned which checked from a different thread */ - if (mp.mp_rc || mp.mp_rc2) { - splat_vprint(file, SPLAT_MUTEX_TEST3_NAME, "Mutex owned by " - "pid %d not by taskq\n", current->pid); - rc = -EINVAL; - goto out_exit; - } - - mutex_exit(&mp.mp_mtx); - - /* Mutex should not be owned by current */ - if (mutex_owned(&mp.mp_mtx)) { - splat_vprint(file, SPLAT_MUTEX_TEST3_NAME, "Mutex owned by " - "pid %d it should be unowned\b", current->pid); - rc = -EINVAL; - goto out; - } - - id = taskq_dispatch(tq, splat_mutex_owned, &mp, TQ_SLEEP); - if (id == TASKQID_INVALID) { - splat_vprint(file, SPLAT_MUTEX_TEST3_NAME, "Failed to " - "dispatch function '%s' to taskq\n", - sym2str(splat_mutex_owned)); - rc = -EINVAL; - goto out; - } - taskq_wait(tq); - - /* Mutex should be owned by no one */ - if (mp.mp_rc || mp.mp_rc2) { - splat_vprint(file, SPLAT_MUTEX_TEST3_NAME, "Mutex owned by " - "no one, %d/%d disagrees\n", mp.mp_rc, mp.mp_rc2); - rc = -EINVAL; - goto out; - } - - splat_vprint(file, SPLAT_MUTEX_TEST3_NAME, "%s", - "Correct mutex_owned() behavior\n"); - goto out; -out_exit: - mutex_exit(&mp.mp_mtx); -out: - mutex_destroy(&mp.mp_mtx); - taskq_destroy(tq); - - return rc; -} - -static int -splat_mutex_test4(struct file *file, void *arg) -{ - kmutex_t mtx; - kthread_t *owner; - int rc = 0; - - mutex_init(&mtx, SPLAT_MUTEX_TEST_NAME, MUTEX_DEFAULT, NULL); - - /* - * Verify mutex owner is cleared after being dropped. Depending - * on how you build your kernel this behavior changes, ensure the - * SPL mutex implementation is properly detecting this. - */ - mutex_enter(&mtx); - msleep(100); - mutex_exit(&mtx); - if (MUTEX_HELD(&mtx)) { - splat_vprint(file, SPLAT_MUTEX_TEST4_NAME, "Mutex should " - "not be held, bit is by %p\n", mutex_owner(&mtx)); - rc = -EINVAL; - goto out; - } - - mutex_enter(&mtx); - - /* Mutex should be owned by current */ - owner = mutex_owner(&mtx); - if (current != owner) { - splat_vprint(file, SPLAT_MUTEX_TEST4_NAME, "Mutex should " - "be owned by pid %d but is owned by pid %d\n", - current->pid, owner ? owner->pid : -1); - rc = -EINVAL; - goto out; - } - - mutex_exit(&mtx); - - /* Mutex should not be owned by any task */ - owner = mutex_owner(&mtx); - if (owner) { - splat_vprint(file, SPLAT_MUTEX_TEST4_NAME, "Mutex should not " - "be owned but is owned by pid %d\n", owner->pid); - rc = -EINVAL; - goto out; - } - - splat_vprint(file, SPLAT_MUTEX_TEST3_NAME, "%s", - "Correct mutex_owner() behavior\n"); -out: - mutex_destroy(&mtx); - - return rc; -} - -splat_subsystem_t * -splat_mutex_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_MUTEX_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_MUTEX_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_MUTEX; - - splat_test_init(sub, SPLAT_MUTEX_TEST1_NAME, SPLAT_MUTEX_TEST1_DESC, - SPLAT_MUTEX_TEST1_ID, splat_mutex_test1); - splat_test_init(sub, SPLAT_MUTEX_TEST2_NAME, SPLAT_MUTEX_TEST2_DESC, - SPLAT_MUTEX_TEST2_ID, splat_mutex_test2); - splat_test_init(sub, SPLAT_MUTEX_TEST3_NAME, SPLAT_MUTEX_TEST3_DESC, - SPLAT_MUTEX_TEST3_ID, splat_mutex_test3); - splat_test_init(sub, SPLAT_MUTEX_TEST4_NAME, SPLAT_MUTEX_TEST4_DESC, - SPLAT_MUTEX_TEST4_ID, splat_mutex_test4); - - return sub; -} - -void -splat_mutex_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - splat_test_fini(sub, SPLAT_MUTEX_TEST4_ID); - splat_test_fini(sub, SPLAT_MUTEX_TEST3_ID); - splat_test_fini(sub, SPLAT_MUTEX_TEST2_ID); - splat_test_fini(sub, SPLAT_MUTEX_TEST1_ID); - - kfree(sub); -} - -int -splat_mutex_id(void) { - return SPLAT_SUBSYSTEM_MUTEX; -} diff --git a/module/splat/splat-random.c b/module/splat/splat-random.c deleted file mode 100644 index 2ddb823fc..000000000 --- a/module/splat/splat-random.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Random Number Generator Tests. - */ - -#include -#include -#include "splat-internal.h" - -#define SPLAT_KRNG_NAME "krng" -#define SPLAT_KRNG_DESC "Kernel Random Number Generator Tests" - -#define SPLAT_KRNG_TEST1_ID 0x0301 -#define SPLAT_KRNG_TEST1_NAME "freq" -#define SPLAT_KRNG_TEST1_DESC "Frequency Test" - -#define KRNG_NUM_BITS 1048576 -#define KRNG_NUM_BYTES (KRNG_NUM_BITS >> 3) -#define KRNG_NUM_BITS_DIV2 (KRNG_NUM_BITS >> 1) -#define KRNG_ERROR_RANGE 2097 - -/* Random Number Generator Tests - There can be meny more tests on quality of the - random number generator. For now we are only - testing the frequency of particular bits. - We could also test consecutive sequences, - randomness within a particular block, etc. - but is probably not necessary for our purposes */ - -static int -splat_krng_test1(struct file *file, void *arg) -{ - uint8_t *buf; - int i, j, diff, num = 0, rc = 0; - - buf = kmalloc(sizeof(*buf) * KRNG_NUM_BYTES, GFP_KERNEL); - if (buf == NULL) { - rc = -ENOMEM; - goto out; - } - - memset(buf, 0, sizeof(*buf) * KRNG_NUM_BYTES); - - /* Always succeeds */ - random_get_pseudo_bytes(buf, sizeof(uint8_t) * KRNG_NUM_BYTES); - - for (i = 0; i < KRNG_NUM_BYTES; i++) { - uint8_t tmp = buf[i]; - for (j = 0; j < 8; j++) { - uint8_t tmp2 = ((tmp >> j) & 0x01); - if (tmp2 == 1) { - num++; - } - } - } - - kfree(buf); - - diff = KRNG_NUM_BITS_DIV2 - num; - if (diff < 0) - diff *= -1; - - splat_print(file, "Test 1 Number of ones: %d\n", num); - splat_print(file, "Test 1 Difference from expected: %d Allowed: %d\n", - diff, KRNG_ERROR_RANGE); - - if (diff > KRNG_ERROR_RANGE) - rc = -ERANGE; -out: - return rc; -} - -splat_subsystem_t * -splat_krng_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_KRNG_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_KRNG_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_KRNG; - - splat_test_init(sub, SPLAT_KRNG_TEST1_NAME, SPLAT_KRNG_TEST1_DESC, - SPLAT_KRNG_TEST1_ID, splat_krng_test1); - - return sub; -} - -void -splat_krng_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - - splat_test_fini(sub, SPLAT_KRNG_TEST1_ID); - - kfree(sub); -} - -int -splat_krng_id(void) { - return SPLAT_SUBSYSTEM_KRNG; -} diff --git a/module/splat/splat-rwlock.c b/module/splat/splat-rwlock.c deleted file mode 100644 index 562a5f047..000000000 --- a/module/splat/splat-rwlock.c +++ /dev/null @@ -1,747 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Read/Writer Lock Tests. - */ - -#include -#include -#include -#include -#include -#include "splat-internal.h" - -#define SPLAT_RWLOCK_NAME "rwlock" -#define SPLAT_RWLOCK_DESC "Kernel RW Lock Tests" - -#define SPLAT_RWLOCK_TEST1_ID 0x0701 -#define SPLAT_RWLOCK_TEST1_NAME "N-rd/1-wr" -#define SPLAT_RWLOCK_TEST1_DESC "Multiple readers one writer" - -#define SPLAT_RWLOCK_TEST2_ID 0x0702 -#define SPLAT_RWLOCK_TEST2_NAME "0-rd/N-wr" -#define SPLAT_RWLOCK_TEST2_DESC "Multiple writers" - -#define SPLAT_RWLOCK_TEST3_ID 0x0703 -#define SPLAT_RWLOCK_TEST3_NAME "held" -#define SPLAT_RWLOCK_TEST3_DESC "RW_{LOCK|READ|WRITE}_HELD" - -#define SPLAT_RWLOCK_TEST4_ID 0x0704 -#define SPLAT_RWLOCK_TEST4_NAME "tryenter" -#define SPLAT_RWLOCK_TEST4_DESC "Tryenter" - -#define SPLAT_RWLOCK_TEST5_ID 0x0705 -#define SPLAT_RWLOCK_TEST5_NAME "rw_downgrade" -#define SPLAT_RWLOCK_TEST5_DESC "Write downgrade" - -#define SPLAT_RWLOCK_TEST6_ID 0x0706 -#define SPLAT_RWLOCK_TEST6_NAME "rw_tryupgrade-1" -#define SPLAT_RWLOCK_TEST6_DESC "rwsem->count value" - -#define SPLAT_RWLOCK_TEST7_ID 0x0707 -#define SPLAT_RWLOCK_TEST7_NAME "rw_tryupgrade-2" -#define SPLAT_RWLOCK_TEST7_DESC "Read upgrade" - -#define SPLAT_RWLOCK_TEST_MAGIC 0x115599DDUL -#define SPLAT_RWLOCK_TEST_NAME "rwlock_test" -#define SPLAT_RWLOCK_TEST_TASKQ "rwlock_taskq" -#define SPLAT_RWLOCK_TEST_COUNT 8 - -#define SPLAT_RWLOCK_RELEASE_INIT 0 -#define SPLAT_RWLOCK_RELEASE_WR 1 -#define SPLAT_RWLOCK_RELEASE_RD 2 - -typedef struct rw_priv { - unsigned long rw_magic; - struct file *rw_file; - krwlock_t rw_rwlock; - spinlock_t rw_lock; - spl_wait_queue_head_t rw_waitq; - int rw_completed; - int rw_holders; - int rw_waiters; - int rw_release; - int rw_rc; - krw_t rw_type; -} rw_priv_t; - -typedef struct rw_thr { - const char *rwt_name; - rw_priv_t *rwt_rwp; - struct task_struct *rwt_thread; -} rw_thr_t; - -void splat_init_rw_priv(rw_priv_t *rwp, struct file *file) -{ - rwp->rw_magic = SPLAT_RWLOCK_TEST_MAGIC; - rwp->rw_file = file; - rw_init(&rwp->rw_rwlock, SPLAT_RWLOCK_TEST_NAME, RW_DEFAULT, NULL); - spin_lock_init(&rwp->rw_lock); - init_waitqueue_head(&rwp->rw_waitq); - rwp->rw_completed = 0; - rwp->rw_holders = 0; - rwp->rw_waiters = 0; - rwp->rw_release = SPLAT_RWLOCK_RELEASE_INIT; - rwp->rw_rc = 0; - rwp->rw_type = 0; -} - -#if defined(CONFIG_PREEMPT_RT_FULL) -static int -splat_rwlock_test1(struct file *file, void *arg) -{ - /* - * This test will never succeed on PREEMPT_RT_FULL because these - * kernels only allow a single thread to hold the lock. - */ - return 0; -} -#else -static int -splat_rwlock_wr_thr(void *arg) -{ - rw_thr_t *rwt = (rw_thr_t *)arg; - rw_priv_t *rwp = rwt->rwt_rwp; - uint8_t rnd; - - ASSERT(rwp->rw_magic == SPLAT_RWLOCK_TEST_MAGIC); - - get_random_bytes((void *)&rnd, 1); - msleep((unsigned int)rnd); - - splat_vprint(rwp->rw_file, rwt->rwt_name, - "%s trying to acquire rwlock (%d holding/%d waiting)\n", - rwt->rwt_thread->comm, rwp->rw_holders, rwp->rw_waiters); - spin_lock(&rwp->rw_lock); - rwp->rw_waiters++; - spin_unlock(&rwp->rw_lock); - rw_enter(&rwp->rw_rwlock, RW_WRITER); - - spin_lock(&rwp->rw_lock); - rwp->rw_waiters--; - rwp->rw_holders++; - spin_unlock(&rwp->rw_lock); - splat_vprint(rwp->rw_file, rwt->rwt_name, - "%s acquired rwlock (%d holding/%d waiting)\n", - rwt->rwt_thread->comm, rwp->rw_holders, rwp->rw_waiters); - - /* Wait for control thread to signal we can release the write lock */ - wait_event_interruptible(rwp->rw_waitq, splat_locked_test(&rwp->rw_lock, - rwp->rw_release == SPLAT_RWLOCK_RELEASE_WR)); - - spin_lock(&rwp->rw_lock); - rwp->rw_completed++; - rwp->rw_holders--; - spin_unlock(&rwp->rw_lock); - splat_vprint(rwp->rw_file, rwt->rwt_name, - "%s dropped rwlock (%d holding/%d waiting)\n", - rwt->rwt_thread->comm, rwp->rw_holders, rwp->rw_waiters); - - rw_exit(&rwp->rw_rwlock); - - return 0; -} - -static int -splat_rwlock_rd_thr(void *arg) -{ - rw_thr_t *rwt = (rw_thr_t *)arg; - rw_priv_t *rwp = rwt->rwt_rwp; - uint8_t rnd; - - ASSERT(rwp->rw_magic == SPLAT_RWLOCK_TEST_MAGIC); - - get_random_bytes((void *)&rnd, 1); - msleep((unsigned int)rnd); - - /* Don't try and take the semaphore until after someone has it */ - wait_event_interruptible(rwp->rw_waitq, - splat_locked_test(&rwp->rw_lock, rwp->rw_holders > 0)); - - splat_vprint(rwp->rw_file, rwt->rwt_name, - "%s trying to acquire rwlock (%d holding/%d waiting)\n", - rwt->rwt_thread->comm, rwp->rw_holders, rwp->rw_waiters); - spin_lock(&rwp->rw_lock); - rwp->rw_waiters++; - spin_unlock(&rwp->rw_lock); - rw_enter(&rwp->rw_rwlock, RW_READER); - - spin_lock(&rwp->rw_lock); - rwp->rw_waiters--; - rwp->rw_holders++; - spin_unlock(&rwp->rw_lock); - splat_vprint(rwp->rw_file, rwt->rwt_name, - "%s acquired rwlock (%d holding/%d waiting)\n", - rwt->rwt_thread->comm, rwp->rw_holders, rwp->rw_waiters); - - /* Wait for control thread to signal we can release the read lock */ - wait_event_interruptible(rwp->rw_waitq, splat_locked_test(&rwp->rw_lock, - rwp->rw_release == SPLAT_RWLOCK_RELEASE_RD)); - - spin_lock(&rwp->rw_lock); - rwp->rw_completed++; - rwp->rw_holders--; - spin_unlock(&rwp->rw_lock); - splat_vprint(rwp->rw_file, rwt->rwt_name, - "%s dropped rwlock (%d holding/%d waiting)\n", - rwt->rwt_thread->comm, rwp->rw_holders, rwp->rw_waiters); - - rw_exit(&rwp->rw_rwlock); - - return 0; -} - -static int -splat_rwlock_test1(struct file *file, void *arg) -{ - int i, count = 0, rc = 0; - rw_thr_t rwt[SPLAT_RWLOCK_TEST_COUNT]; - rw_priv_t *rwp; - - rwp = (rw_priv_t *)kmalloc(sizeof(*rwp), GFP_KERNEL); - if (rwp == NULL) - return -ENOMEM; - - splat_init_rw_priv(rwp, file); - - /* Create some threads, the exact number isn't important just as - * long as we know how many we managed to create and should expect. */ - for (i = 0; i < SPLAT_RWLOCK_TEST_COUNT; i++) { - rwt[i].rwt_rwp = rwp; - rwt[i].rwt_name = SPLAT_RWLOCK_TEST1_NAME; - - /* The first thread will be the writer */ - if (i == 0) - rwt[i].rwt_thread = spl_kthread_create(splat_rwlock_wr_thr, - &rwt[i], "%s/%d", SPLAT_RWLOCK_TEST_NAME, i); - else - rwt[i].rwt_thread = spl_kthread_create(splat_rwlock_rd_thr, - &rwt[i], "%s/%d", SPLAT_RWLOCK_TEST_NAME, i); - - if (!IS_ERR(rwt[i].rwt_thread)) { - wake_up_process(rwt[i].rwt_thread); - count++; - } - } - - /* Wait for the writer */ - while (splat_locked_test(&rwp->rw_lock, rwp->rw_holders == 0)) { - wake_up_interruptible(&rwp->rw_waitq); - msleep(100); - } - - /* Wait for 'count-1' readers */ - while (splat_locked_test(&rwp->rw_lock, rwp->rw_waiters < count - 1)) { - wake_up_interruptible(&rwp->rw_waitq); - msleep(100); - } - - /* Verify there is only one lock holder */ - if (splat_locked_test(&rwp->rw_lock, rwp->rw_holders) != 1) { - splat_vprint(file, SPLAT_RWLOCK_TEST1_NAME, "Only 1 holder " - "expected for rwlock (%d holding/%d waiting)\n", - rwp->rw_holders, rwp->rw_waiters); - rc = -EINVAL; - } - - /* Verify 'count-1' readers */ - if (splat_locked_test(&rwp->rw_lock, rwp->rw_waiters != count - 1)) { - splat_vprint(file, SPLAT_RWLOCK_TEST1_NAME, "Only %d waiters " - "expected for rwlock (%d holding/%d waiting)\n", - count - 1, rwp->rw_holders, rwp->rw_waiters); - rc = -EINVAL; - } - - /* Signal the writer to release, allows readers to acquire */ - spin_lock(&rwp->rw_lock); - rwp->rw_release = SPLAT_RWLOCK_RELEASE_WR; - wake_up_interruptible(&rwp->rw_waitq); - spin_unlock(&rwp->rw_lock); - - /* Wait for 'count-1' readers to hold the lock */ - while (splat_locked_test(&rwp->rw_lock, rwp->rw_holders < count - 1)) { - wake_up_interruptible(&rwp->rw_waitq); - msleep(100); - } - - /* Verify there are 'count-1' readers */ - if (splat_locked_test(&rwp->rw_lock, rwp->rw_holders != count - 1)) { - splat_vprint(file, SPLAT_RWLOCK_TEST1_NAME, "Only %d holders " - "expected for rwlock (%d holding/%d waiting)\n", - count - 1, rwp->rw_holders, rwp->rw_waiters); - rc = -EINVAL; - } - - /* Release 'count-1' readers */ - spin_lock(&rwp->rw_lock); - rwp->rw_release = SPLAT_RWLOCK_RELEASE_RD; - wake_up_interruptible(&rwp->rw_waitq); - spin_unlock(&rwp->rw_lock); - - /* Wait for the test to complete */ - while (splat_locked_test(&rwp->rw_lock, - rwp->rw_holders>0 || rwp->rw_waiters>0)) - msleep(100); - - rw_destroy(&(rwp->rw_rwlock)); - kfree(rwp); - - return rc; -} -#endif - -static void -splat_rwlock_test2_func(void *arg) -{ - rw_priv_t *rwp = (rw_priv_t *)arg; - int rc; - ASSERT(rwp->rw_magic == SPLAT_RWLOCK_TEST_MAGIC); - - /* Read the value before sleeping and write it after we wake up to - * maximize the chance of a race if rwlocks are not working properly */ - rw_enter(&rwp->rw_rwlock, RW_WRITER); - rc = rwp->rw_rc; - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(HZ / 100); /* 1/100 of a second */ - VERIFY(rwp->rw_rc == rc); - rwp->rw_rc = rc + 1; - rw_exit(&rwp->rw_rwlock); -} - -static int -splat_rwlock_test2(struct file *file, void *arg) -{ - rw_priv_t *rwp; - taskq_t *tq; - int i, rc = 0, tq_count = 256; - - rwp = (rw_priv_t *)kmalloc(sizeof(*rwp), GFP_KERNEL); - if (rwp == NULL) - return -ENOMEM; - - splat_init_rw_priv(rwp, file); - - /* Create several threads allowing tasks to race with each other */ - tq = taskq_create(SPLAT_RWLOCK_TEST_TASKQ, num_online_cpus(), - defclsyspri, 50, INT_MAX, TASKQ_PREPOPULATE); - if (tq == NULL) { - rc = -ENOMEM; - goto out; - } - - /* - * Schedule N work items to the work queue each of which enters the - * writer rwlock, sleeps briefly, then exits the writer rwlock. On a - * multiprocessor box these work items will be handled by all available - * CPUs. The task function checks to ensure the tracked shared variable - * is always only incremented by one. Additionally, the rwlock itself - * is instrumented such that if any two processors are in the - * critical region at the same time the system will panic. If the - * rwlock is implemented right this will never happy, that's a pass. - */ - for (i = 0; i < tq_count; i++) { - if (taskq_dispatch(tq, splat_rwlock_test2_func, rwp, - TQ_SLEEP) == TASKQID_INVALID) { - splat_vprint(file, SPLAT_RWLOCK_TEST2_NAME, - "Failed to queue task %d\n", i); - rc = -EINVAL; - } - } - - taskq_wait(tq); - - if (rwp->rw_rc == tq_count) { - splat_vprint(file, SPLAT_RWLOCK_TEST2_NAME, "%d racing threads " - "correctly entered/exited the rwlock %d times\n", - num_online_cpus(), rwp->rw_rc); - } else { - splat_vprint(file, SPLAT_RWLOCK_TEST2_NAME, "%d racing threads " - "only processed %d/%d w rwlock work items\n", - num_online_cpus(), rwp->rw_rc, tq_count); - rc = -EINVAL; - } - - taskq_destroy(tq); - rw_destroy(&(rwp->rw_rwlock)); -out: - kfree(rwp); - return rc; -} - -#define splat_rwlock_test3_helper(rwp,rex1,rex2,wex1,wex2,held_func,rc) \ -do { \ - int result, _rc1_, _rc2_, _rc3_, _rc4_; \ - \ - rc = 0; \ - rw_enter(&(rwp)->rw_rwlock, RW_READER); \ - _rc1_ = ((result = held_func(&(rwp)->rw_rwlock)) != rex1); \ - splat_vprint(file, SPLAT_RWLOCK_TEST3_NAME, "%s" #held_func \ - " returned %d (expected %d) when RW_READER\n", \ - _rc1_ ? "Fail " : "", result, rex1); \ - rw_exit(&(rwp)->rw_rwlock); \ - _rc2_ = ((result = held_func(&(rwp)->rw_rwlock)) != rex2); \ - splat_vprint(file, SPLAT_RWLOCK_TEST3_NAME, "%s" #held_func \ - " returned %d (expected %d) when !RW_READER\n", \ - _rc2_ ? "Fail " : "", result, rex2); \ - \ - rw_enter(&(rwp)->rw_rwlock, RW_WRITER); \ - _rc3_ = ((result = held_func(&(rwp)->rw_rwlock)) != wex1); \ - splat_vprint(file, SPLAT_RWLOCK_TEST3_NAME, "%s" #held_func \ - " returned %d (expected %d) when RW_WRITER\n", \ - _rc3_ ? "Fail " : "", result, wex1); \ - rw_exit(&(rwp)->rw_rwlock); \ - _rc4_ = ((result = held_func(&(rwp)->rw_rwlock)) != wex2); \ - splat_vprint(file, SPLAT_RWLOCK_TEST3_NAME, "%s" #held_func \ - " returned %d (expected %d) when !RW_WRITER\n", \ - _rc4_ ? "Fail " : "", result, wex2); \ - \ - rc = ((_rc1_ || _rc2_ || _rc3_ || _rc4_) ? -EINVAL : 0); \ -} while(0); - -static int -splat_rwlock_test3(struct file *file, void *arg) -{ - rw_priv_t *rwp; - int rc1, rc2, rc3; - - rwp = (rw_priv_t *)kmalloc(sizeof(*rwp), GFP_KERNEL); - if (rwp == NULL) - return -ENOMEM; - - splat_init_rw_priv(rwp, file); - - splat_rwlock_test3_helper(rwp, 1, 0, 1, 0, RW_LOCK_HELD, rc1); - splat_rwlock_test3_helper(rwp, 1, 0, 0, 0, RW_READ_HELD, rc2); - splat_rwlock_test3_helper(rwp, 0, 0, 1, 0, RW_WRITE_HELD, rc3); - - rw_destroy(&rwp->rw_rwlock); - kfree(rwp); - - return ((rc1 || rc2 || rc3) ? -EINVAL : 0); -} - -static void -splat_rwlock_test4_func(void *arg) -{ - rw_priv_t *rwp = (rw_priv_t *)arg; - ASSERT(rwp->rw_magic == SPLAT_RWLOCK_TEST_MAGIC); - - if (rw_tryenter(&rwp->rw_rwlock, rwp->rw_type)) { - rwp->rw_rc = 0; - rw_exit(&rwp->rw_rwlock); - } else { - rwp->rw_rc = -EBUSY; - } -} - -static char * -splat_rwlock_test4_name(krw_t type) -{ - switch (type) { - case RW_NONE: return "RW_NONE"; - case RW_WRITER: return "RW_WRITER"; - case RW_READER: return "RW_READER"; - } - - return NULL; -} - -static int -splat_rwlock_test4_type(taskq_t *tq, rw_priv_t *rwp, int expected_rc, - krw_t holder_type, krw_t try_type) -{ - int id, rc = 0; - - /* Schedule a task function which will try and acquire the rwlock - * using type try_type while the rwlock is being held as holder_type. - * The result must match expected_rc for the test to pass */ - rwp->rw_rc = -EINVAL; - rwp->rw_type = try_type; - - if (holder_type == RW_WRITER || holder_type == RW_READER) - rw_enter(&rwp->rw_rwlock, holder_type); - - id = taskq_dispatch(tq, splat_rwlock_test4_func, rwp, TQ_SLEEP); - if (id == TASKQID_INVALID) { - splat_vprint(rwp->rw_file, SPLAT_RWLOCK_TEST4_NAME, "%s", - "taskq_dispatch() failed\n"); - rc = -EINVAL; - goto out; - } - - taskq_wait_id(tq, id); - - if (rwp->rw_rc != expected_rc) - rc = -EINVAL; - - splat_vprint(rwp->rw_file, SPLAT_RWLOCK_TEST4_NAME, - "%srw_tryenter(%s) returned %d (expected %d) when %s\n", - rc ? "Fail " : "", splat_rwlock_test4_name(try_type), - rwp->rw_rc, expected_rc, - splat_rwlock_test4_name(holder_type)); -out: - if (holder_type == RW_WRITER || holder_type == RW_READER) - rw_exit(&rwp->rw_rwlock); - - return rc; -} - -static int -splat_rwlock_test4(struct file *file, void *arg) -{ - rw_priv_t *rwp; - taskq_t *tq; - int rc = 0, rc1, rc2, rc3, rc4, rc5, rc6; - - rwp = (rw_priv_t *)kmalloc(sizeof(*rwp), GFP_KERNEL); - if (rwp == NULL) - return -ENOMEM; - - tq = taskq_create(SPLAT_RWLOCK_TEST_TASKQ, 1, defclsyspri, - 50, INT_MAX, TASKQ_PREPOPULATE); - if (tq == NULL) { - rc = -ENOMEM; - goto out; - } - - splat_init_rw_priv(rwp, file); - - /* - * Validate all combinations of rw_tryenter() contention. - * - * The concurrent reader test is modified for PREEMPT_RT_FULL - * kernels which do not permit concurrent read locks to be taken - * from different threads. The same thread is allowed to take - * the read lock multiple times. - */ - rc1 = splat_rwlock_test4_type(tq, rwp, -EBUSY, RW_WRITER, RW_WRITER); - rc2 = splat_rwlock_test4_type(tq, rwp, -EBUSY, RW_WRITER, RW_READER); - rc3 = splat_rwlock_test4_type(tq, rwp, -EBUSY, RW_READER, RW_WRITER); -#if defined(CONFIG_PREEMPT_RT_FULL) - rc4 = splat_rwlock_test4_type(tq, rwp, -EBUSY, RW_READER, RW_READER); -#else - rc4 = splat_rwlock_test4_type(tq, rwp, 0, RW_READER, RW_READER); -#endif - rc5 = splat_rwlock_test4_type(tq, rwp, 0, RW_NONE, RW_WRITER); - rc6 = splat_rwlock_test4_type(tq, rwp, 0, RW_NONE, RW_READER); - - if (rc1 || rc2 || rc3 || rc4 || rc5 || rc6) - rc = -EINVAL; - - taskq_destroy(tq); -out: - rw_destroy(&(rwp->rw_rwlock)); - kfree(rwp); - - return rc; -} - -static int -splat_rwlock_test5(struct file *file, void *arg) -{ - rw_priv_t *rwp; - int rc = -EINVAL; - - rwp = (rw_priv_t *)kmalloc(sizeof(*rwp), GFP_KERNEL); - if (rwp == NULL) - return -ENOMEM; - - splat_init_rw_priv(rwp, file); - - rw_enter(&rwp->rw_rwlock, RW_WRITER); - if (!RW_WRITE_HELD(&rwp->rw_rwlock)) { - splat_vprint(file, SPLAT_RWLOCK_TEST5_NAME, - "rwlock should be write lock: %d\n", - RW_WRITE_HELD(&rwp->rw_rwlock)); - goto out; - } - - rw_downgrade(&rwp->rw_rwlock); - if (!RW_READ_HELD(&rwp->rw_rwlock)) { - splat_vprint(file, SPLAT_RWLOCK_TEST5_NAME, - "rwlock should be read lock: %d\n", - RW_READ_HELD(&rwp->rw_rwlock)); - goto out; - } - - rc = 0; - splat_vprint(file, SPLAT_RWLOCK_TEST5_NAME, "%s", - "rwlock properly downgraded\n"); -out: - rw_exit(&rwp->rw_rwlock); - rw_destroy(&rwp->rw_rwlock); - kfree(rwp); - - return rc; -} - -static int -splat_rwlock_test6(struct file *file, void *arg) -{ - rw_priv_t *rwp; - int rc; - - rwp = (rw_priv_t *)kmalloc(sizeof(*rwp), GFP_KERNEL); - if (rwp == NULL) - return -ENOMEM; - - splat_init_rw_priv(rwp, file); - - rw_enter(&rwp->rw_rwlock, RW_READER); - if (RWSEM_COUNT(SEM(&rwp->rw_rwlock)) != - SPL_RWSEM_SINGLE_READER_VALUE) { - splat_vprint(file, SPLAT_RWLOCK_TEST6_NAME, - "We assumed single reader rwsem->count " - "should be %ld, but is %ld\n", - (long int)SPL_RWSEM_SINGLE_READER_VALUE, - (long int)RWSEM_COUNT(SEM(&rwp->rw_rwlock))); - rc = -ENOLCK; - goto out; - } - rw_exit(&rwp->rw_rwlock); - - rw_enter(&rwp->rw_rwlock, RW_WRITER); - if (RWSEM_COUNT(SEM(&rwp->rw_rwlock)) != - SPL_RWSEM_SINGLE_WRITER_VALUE) { - splat_vprint(file, SPLAT_RWLOCK_TEST6_NAME, - "We assumed single writer rwsem->count " - "should be %ld, but is %ld\n", - (long int)SPL_RWSEM_SINGLE_WRITER_VALUE, - (long int)RWSEM_COUNT(SEM(&rwp->rw_rwlock))); - rc = -ENOLCK; - goto out; - } - rc = 0; - splat_vprint(file, SPLAT_RWLOCK_TEST6_NAME, "%s", - "rwsem->count same as we assumed\n"); -out: - rw_exit(&rwp->rw_rwlock); - rw_destroy(&rwp->rw_rwlock); - kfree(rwp); - - return rc; -} - -static int -splat_rwlock_test7(struct file *file, void *arg) -{ - rw_priv_t *rwp; - int rc; - - rwp = (rw_priv_t *)kmalloc(sizeof(*rwp), GFP_KERNEL); - if (rwp == NULL) - return -ENOMEM; - - splat_init_rw_priv(rwp, file); - - rw_enter(&rwp->rw_rwlock, RW_READER); - if (!RW_READ_HELD(&rwp->rw_rwlock)) { - splat_vprint(file, SPLAT_RWLOCK_TEST7_NAME, - "rwlock should be read lock: %d\n", - RW_READ_HELD(&rwp->rw_rwlock)); - rc = -ENOLCK; - goto out; - } - - /* With one reader upgrade should never fail. */ - rc = rw_tryupgrade(&rwp->rw_rwlock); - if (!rc) { - splat_vprint(file, SPLAT_RWLOCK_TEST7_NAME, - "rwlock failed upgrade from reader: %d\n", - RW_READ_HELD(&rwp->rw_rwlock)); - rc = -ENOLCK; - goto out; - } - - if (RW_READ_HELD(&rwp->rw_rwlock) || !RW_WRITE_HELD(&rwp->rw_rwlock)) { - splat_vprint(file, SPLAT_RWLOCK_TEST7_NAME, "rwlock should " - "have 0 (not %d) reader and 1 (not %d) writer\n", - RW_READ_HELD(&rwp->rw_rwlock), - RW_WRITE_HELD(&rwp->rw_rwlock)); - goto out; - } - - rc = 0; - splat_vprint(file, SPLAT_RWLOCK_TEST7_NAME, "%s", - "rwlock properly upgraded\n"); -out: - rw_exit(&rwp->rw_rwlock); - rw_destroy(&rwp->rw_rwlock); - kfree(rwp); - - return rc; -} - -splat_subsystem_t * -splat_rwlock_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_RWLOCK_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_RWLOCK_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_RWLOCK; - - splat_test_init(sub, SPLAT_RWLOCK_TEST1_NAME, SPLAT_RWLOCK_TEST1_DESC, - SPLAT_RWLOCK_TEST1_ID, splat_rwlock_test1); - splat_test_init(sub, SPLAT_RWLOCK_TEST2_NAME, SPLAT_RWLOCK_TEST2_DESC, - SPLAT_RWLOCK_TEST2_ID, splat_rwlock_test2); - splat_test_init(sub, SPLAT_RWLOCK_TEST3_NAME, SPLAT_RWLOCK_TEST3_DESC, - SPLAT_RWLOCK_TEST3_ID, splat_rwlock_test3); - splat_test_init(sub, SPLAT_RWLOCK_TEST4_NAME, SPLAT_RWLOCK_TEST4_DESC, - SPLAT_RWLOCK_TEST4_ID, splat_rwlock_test4); - splat_test_init(sub, SPLAT_RWLOCK_TEST5_NAME, SPLAT_RWLOCK_TEST5_DESC, - SPLAT_RWLOCK_TEST5_ID, splat_rwlock_test5); - splat_test_init(sub, SPLAT_RWLOCK_TEST6_NAME, SPLAT_RWLOCK_TEST6_DESC, - SPLAT_RWLOCK_TEST6_ID, splat_rwlock_test6); - splat_test_init(sub, SPLAT_RWLOCK_TEST7_NAME, SPLAT_RWLOCK_TEST7_DESC, - SPLAT_RWLOCK_TEST7_ID, splat_rwlock_test7); - - return sub; -} - -void -splat_rwlock_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - splat_test_fini(sub, SPLAT_RWLOCK_TEST7_ID); - splat_test_fini(sub, SPLAT_RWLOCK_TEST6_ID); - splat_test_fini(sub, SPLAT_RWLOCK_TEST5_ID); - splat_test_fini(sub, SPLAT_RWLOCK_TEST4_ID); - splat_test_fini(sub, SPLAT_RWLOCK_TEST3_ID); - splat_test_fini(sub, SPLAT_RWLOCK_TEST2_ID); - splat_test_fini(sub, SPLAT_RWLOCK_TEST1_ID); - kfree(sub); -} - -int -splat_rwlock_id(void) { - return SPLAT_SUBSYSTEM_RWLOCK; -} diff --git a/module/splat/splat-taskq.c b/module/splat/splat-taskq.c deleted file mode 100644 index ff73e103a..000000000 --- a/module/splat/splat-taskq.c +++ /dev/null @@ -1,1548 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Task Queue Tests. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "splat-internal.h" - -#define SPLAT_TASKQ_NAME "taskq" -#define SPLAT_TASKQ_DESC "Kernel Task Queue Tests" - -#define SPLAT_TASKQ_TEST1_ID 0x0201 -#define SPLAT_TASKQ_TEST1_NAME "single" -#define SPLAT_TASKQ_TEST1_DESC "Single task queue, single task" - -#define SPLAT_TASKQ_TEST2_ID 0x0202 -#define SPLAT_TASKQ_TEST2_NAME "multiple" -#define SPLAT_TASKQ_TEST2_DESC "Multiple task queues, multiple tasks" - -#define SPLAT_TASKQ_TEST3_ID 0x0203 -#define SPLAT_TASKQ_TEST3_NAME "system" -#define SPLAT_TASKQ_TEST3_DESC "System task queue, multiple tasks" - -#define SPLAT_TASKQ_TEST4_ID 0x0204 -#define SPLAT_TASKQ_TEST4_NAME "wait" -#define SPLAT_TASKQ_TEST4_DESC "Multiple task waiting" - -#define SPLAT_TASKQ_TEST5_ID 0x0205 -#define SPLAT_TASKQ_TEST5_NAME "order" -#define SPLAT_TASKQ_TEST5_DESC "Correct task ordering" - -#define SPLAT_TASKQ_TEST6_ID 0x0206 -#define SPLAT_TASKQ_TEST6_NAME "front" -#define SPLAT_TASKQ_TEST6_DESC "Correct ordering with TQ_FRONT flag" - -#define SPLAT_TASKQ_TEST7_ID 0x0207 -#define SPLAT_TASKQ_TEST7_NAME "recurse" -#define SPLAT_TASKQ_TEST7_DESC "Single task queue, recursive dispatch" - -#define SPLAT_TASKQ_TEST8_ID 0x0208 -#define SPLAT_TASKQ_TEST8_NAME "contention" -#define SPLAT_TASKQ_TEST8_DESC "1 queue, 100 threads, 131072 tasks" - -#define SPLAT_TASKQ_TEST9_ID 0x0209 -#define SPLAT_TASKQ_TEST9_NAME "delay" -#define SPLAT_TASKQ_TEST9_DESC "Delayed task execution" - -#define SPLAT_TASKQ_TEST10_ID 0x020a -#define SPLAT_TASKQ_TEST10_NAME "cancel" -#define SPLAT_TASKQ_TEST10_DESC "Cancel task execution" - -#define SPLAT_TASKQ_TEST11_ID 0x020b -#define SPLAT_TASKQ_TEST11_NAME "dynamic" -#define SPLAT_TASKQ_TEST11_DESC "Dynamic task queue thread creation" - -#define SPLAT_TASKQ_ORDER_MAX 8 -#define SPLAT_TASKQ_DEPTH_MAX 16 - - -typedef struct splat_taskq_arg { - int flag; - int id; - atomic_t *count; - int order[SPLAT_TASKQ_ORDER_MAX]; - unsigned int depth; - clock_t expire; - taskq_t *tq; - taskq_ent_t *tqe; - spinlock_t lock; - struct file *file; - const char *name; -} splat_taskq_arg_t; - -typedef struct splat_taskq_id { - int id; - splat_taskq_arg_t *arg; -} splat_taskq_id_t; - -/* - * Create a taskq, queue a task, wait until task completes, ensure - * task ran properly, cleanup taskq. - */ -static void -splat_taskq_test13_func(void *arg) -{ - splat_taskq_arg_t *tq_arg = (splat_taskq_arg_t *)arg; - - ASSERT(tq_arg); - splat_vprint(tq_arg->file, SPLAT_TASKQ_TEST1_NAME, - "Taskq '%s' function '%s' setting flag\n", - tq_arg->name, sym2str(splat_taskq_test13_func)); - tq_arg->flag = 1; -} - -static int -splat_taskq_test1_impl(struct file *file, void *arg, boolean_t prealloc) -{ - taskq_t *tq; - taskqid_t id; - splat_taskq_arg_t tq_arg; - taskq_ent_t *tqe; - - tqe = kmem_alloc(sizeof (taskq_ent_t), KM_SLEEP); - taskq_init_ent(tqe); - - splat_vprint(file, SPLAT_TASKQ_TEST1_NAME, - "Taskq '%s' creating (%s dispatch)\n", - SPLAT_TASKQ_TEST1_NAME, - prealloc ? "prealloc" : "dynamic"); - if ((tq = taskq_create(SPLAT_TASKQ_TEST1_NAME, 1, defclsyspri, - 50, INT_MAX, TASKQ_PREPOPULATE)) == NULL) { - splat_vprint(file, SPLAT_TASKQ_TEST1_NAME, - "Taskq '%s' create failed\n", - SPLAT_TASKQ_TEST1_NAME); - kmem_free(tqe, sizeof (taskq_ent_t)); - return -EINVAL; - } - - tq_arg.flag = 0; - tq_arg.id = 0; - tq_arg.file = file; - tq_arg.name = SPLAT_TASKQ_TEST1_NAME; - - splat_vprint(file, SPLAT_TASKQ_TEST1_NAME, - "Taskq '%s' function '%s' dispatching\n", - tq_arg.name, sym2str(splat_taskq_test13_func)); - if (prealloc) { - taskq_dispatch_ent(tq, splat_taskq_test13_func, - &tq_arg, TQ_SLEEP, tqe); - id = tqe->tqent_id; - } else { - id = taskq_dispatch(tq, splat_taskq_test13_func, - &tq_arg, TQ_SLEEP); - } - - if (id == TASKQID_INVALID) { - splat_vprint(file, SPLAT_TASKQ_TEST1_NAME, - "Taskq '%s' function '%s' dispatch failed\n", - tq_arg.name, sym2str(splat_taskq_test13_func)); - kmem_free(tqe, sizeof (taskq_ent_t)); - taskq_destroy(tq); - return -EINVAL; - } - - splat_vprint(file, SPLAT_TASKQ_TEST1_NAME, "Taskq '%s' waiting\n", - tq_arg.name); - taskq_wait(tq); - splat_vprint(file, SPLAT_TASKQ_TEST1_NAME, "Taskq '%s' destroying\n", - tq_arg.name); - - kmem_free(tqe, sizeof (taskq_ent_t)); - taskq_destroy(tq); - - return (tq_arg.flag) ? 0 : -EINVAL; -} - -static int -splat_taskq_test1(struct file *file, void *arg) -{ - int rc; - - rc = splat_taskq_test1_impl(file, arg, B_FALSE); - if (rc) - return rc; - - rc = splat_taskq_test1_impl(file, arg, B_TRUE); - - return rc; -} - -/* - * Create multiple taskq's, each with multiple tasks, wait until - * all tasks complete, ensure all tasks ran properly and in the - * correct order. Run order must be the same as the order submitted - * because we only have 1 thread per taskq. Finally cleanup the taskq. - */ -static void -splat_taskq_test2_func1(void *arg) -{ - splat_taskq_arg_t *tq_arg = (splat_taskq_arg_t *)arg; - - ASSERT(tq_arg); - splat_vprint(tq_arg->file, SPLAT_TASKQ_TEST2_NAME, - "Taskq '%s/%d' function '%s' flag = %d = %d * 2\n", - tq_arg->name, tq_arg->id, - sym2str(splat_taskq_test2_func1), - tq_arg->flag * 2, tq_arg->flag); - tq_arg->flag *= 2; -} - -static void -splat_taskq_test2_func2(void *arg) -{ - splat_taskq_arg_t *tq_arg = (splat_taskq_arg_t *)arg; - - ASSERT(tq_arg); - splat_vprint(tq_arg->file, SPLAT_TASKQ_TEST2_NAME, - "Taskq '%s/%d' function '%s' flag = %d = %d + 1\n", - tq_arg->name, tq_arg->id, - sym2str(splat_taskq_test2_func2), - tq_arg->flag + 1, tq_arg->flag); - tq_arg->flag += 1; -} - -#define TEST2_TASKQS 8 -#define TEST2_THREADS_PER_TASKQ 1 - -static int -splat_taskq_test2_impl(struct file *file, void *arg, boolean_t prealloc) { - taskq_t *tq[TEST2_TASKQS] = { NULL }; - taskqid_t id; - splat_taskq_arg_t *tq_args[TEST2_TASKQS] = { NULL }; - taskq_ent_t *func1_tqes = NULL; - taskq_ent_t *func2_tqes = NULL; - int i, rc = 0; - - func1_tqes = kmalloc(sizeof(*func1_tqes) * TEST2_TASKQS, GFP_KERNEL); - if (func1_tqes == NULL) { - rc = -ENOMEM; - goto out; - } - - func2_tqes = kmalloc(sizeof(*func2_tqes) * TEST2_TASKQS, GFP_KERNEL); - if (func2_tqes == NULL) { - rc = -ENOMEM; - goto out; - } - - for (i = 0; i < TEST2_TASKQS; i++) { - taskq_init_ent(&func1_tqes[i]); - taskq_init_ent(&func2_tqes[i]); - - tq_args[i] = kmalloc(sizeof (splat_taskq_arg_t), GFP_KERNEL); - if (tq_args[i] == NULL) { - rc = -ENOMEM; - break; - } - - splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, - "Taskq '%s/%d' creating (%s dispatch)\n", - SPLAT_TASKQ_TEST2_NAME, i, - prealloc ? "prealloc" : "dynamic"); - if ((tq[i] = taskq_create(SPLAT_TASKQ_TEST2_NAME, - TEST2_THREADS_PER_TASKQ, - defclsyspri, 50, INT_MAX, - TASKQ_PREPOPULATE)) == NULL) { - splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, - "Taskq '%s/%d' create failed\n", - SPLAT_TASKQ_TEST2_NAME, i); - rc = -EINVAL; - break; - } - - tq_args[i]->flag = i; - tq_args[i]->id = i; - tq_args[i]->file = file; - tq_args[i]->name = SPLAT_TASKQ_TEST2_NAME; - - splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, - "Taskq '%s/%d' function '%s' dispatching\n", - tq_args[i]->name, tq_args[i]->id, - sym2str(splat_taskq_test2_func1)); - if (prealloc) { - taskq_dispatch_ent(tq[i], splat_taskq_test2_func1, - tq_args[i], TQ_SLEEP, &func1_tqes[i]); - id = func1_tqes[i].tqent_id; - } else { - id = taskq_dispatch(tq[i], splat_taskq_test2_func1, - tq_args[i], TQ_SLEEP); - } - - if (id == TASKQID_INVALID) { - splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, - "Taskq '%s/%d' function '%s' dispatch " - "failed\n", tq_args[i]->name, tq_args[i]->id, - sym2str(splat_taskq_test2_func1)); - rc = -EINVAL; - break; - } - - splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, - "Taskq '%s/%d' function '%s' dispatching\n", - tq_args[i]->name, tq_args[i]->id, - sym2str(splat_taskq_test2_func2)); - if (prealloc) { - taskq_dispatch_ent(tq[i], splat_taskq_test2_func2, - tq_args[i], TQ_SLEEP, &func2_tqes[i]); - id = func2_tqes[i].tqent_id; - } else { - id = taskq_dispatch(tq[i], splat_taskq_test2_func2, - tq_args[i], TQ_SLEEP); - } - - if (id == TASKQID_INVALID) { - splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, "Taskq " - "'%s/%d' function '%s' dispatch failed\n", - tq_args[i]->name, tq_args[i]->id, - sym2str(splat_taskq_test2_func2)); - rc = -EINVAL; - break; - } - } - - /* When rc is set we're effectively just doing cleanup here, so - * ignore new errors in that case. They just cause noise. */ - for (i = 0; i < TEST2_TASKQS; i++) { - if (tq_args[i] == NULL) - continue; - - if (tq[i] != NULL) { - splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, - "Taskq '%s/%d' waiting\n", - tq_args[i]->name, tq_args[i]->id); - taskq_wait(tq[i]); - splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, - "Taskq '%s/%d; destroying\n", - tq_args[i]->name, tq_args[i]->id); - - taskq_destroy(tq[i]); - - if (!rc && tq_args[i]->flag != ((i * 2) + 1)) { - splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, - "Taskq '%s/%d' processed tasks " - "out of order; %d != %d\n", - tq_args[i]->name, tq_args[i]->id, - tq_args[i]->flag, i * 2 + 1); - rc = -EINVAL; - } else { - splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, - "Taskq '%s/%d' processed tasks " - "in the correct order; %d == %d\n", - tq_args[i]->name, tq_args[i]->id, - tq_args[i]->flag, i * 2 + 1); - } - - kfree(tq_args[i]); - } - } -out: - if (func1_tqes) - kfree(func1_tqes); - - if (func2_tqes) - kfree(func2_tqes); - - return rc; -} - -static int -splat_taskq_test2(struct file *file, void *arg) { - int rc; - - rc = splat_taskq_test2_impl(file, arg, B_FALSE); - if (rc) - return rc; - - rc = splat_taskq_test2_impl(file, arg, B_TRUE); - - return rc; -} - -/* - * Use the global system task queue with a single task, wait until task - * completes, ensure task ran properly. - */ -static int -splat_taskq_test3_impl(struct file *file, void *arg, boolean_t prealloc) -{ - taskqid_t id; - splat_taskq_arg_t *tq_arg; - taskq_ent_t *tqe; - int error; - - tq_arg = kmem_alloc(sizeof (splat_taskq_arg_t), KM_SLEEP); - tqe = kmem_alloc(sizeof (taskq_ent_t), KM_SLEEP); - taskq_init_ent(tqe); - - tq_arg->flag = 0; - tq_arg->id = 0; - tq_arg->file = file; - tq_arg->name = SPLAT_TASKQ_TEST3_NAME; - - splat_vprint(file, SPLAT_TASKQ_TEST3_NAME, - "Taskq '%s' function '%s' %s dispatch\n", - tq_arg->name, sym2str(splat_taskq_test13_func), - prealloc ? "prealloc" : "dynamic"); - if (prealloc) { - taskq_dispatch_ent(system_taskq, splat_taskq_test13_func, - tq_arg, TQ_SLEEP, tqe); - id = tqe->tqent_id; - } else { - id = taskq_dispatch(system_taskq, splat_taskq_test13_func, - tq_arg, TQ_SLEEP); - } - - if (id == TASKQID_INVALID) { - splat_vprint(file, SPLAT_TASKQ_TEST3_NAME, - "Taskq '%s' function '%s' dispatch failed\n", - tq_arg->name, sym2str(splat_taskq_test13_func)); - kmem_free(tqe, sizeof (taskq_ent_t)); - kmem_free(tq_arg, sizeof (splat_taskq_arg_t)); - return -EINVAL; - } - - splat_vprint(file, SPLAT_TASKQ_TEST3_NAME, "Taskq '%s' waiting\n", - tq_arg->name); - taskq_wait(system_taskq); - - error = (tq_arg->flag) ? 0 : -EINVAL; - - kmem_free(tqe, sizeof (taskq_ent_t)); - kmem_free(tq_arg, sizeof (splat_taskq_arg_t)); - - return (error); -} - -static int -splat_taskq_test3(struct file *file, void *arg) -{ - int rc; - - rc = splat_taskq_test3_impl(file, arg, B_FALSE); - if (rc) - return rc; - - rc = splat_taskq_test3_impl(file, arg, B_TRUE); - - return rc; -} - -/* - * Create a taskq and dispatch a large number of tasks to the queue. - * Then use taskq_wait() to block until all the tasks complete, then - * cross check that all the tasks ran by checking the shared atomic - * counter which is incremented in the task function. - * - * First we try with a large 'maxalloc' value, then we try with a small one. - * We should not drop tasks when TQ_SLEEP is used in taskq_dispatch(), even - * if the number of pending tasks is above maxalloc. - */ -static void -splat_taskq_test4_func(void *arg) -{ - splat_taskq_arg_t *tq_arg = (splat_taskq_arg_t *)arg; - ASSERT(tq_arg); - - atomic_inc(tq_arg->count); -} - -static int -splat_taskq_test4_common(struct file *file, void *arg, int minalloc, - int maxalloc, int nr_tasks, boolean_t prealloc) -{ - taskq_t *tq; - taskqid_t id; - splat_taskq_arg_t tq_arg; - taskq_ent_t *tqes; - atomic_t count; - int i, j, rc = 0; - - tqes = kmalloc(sizeof(*tqes) * nr_tasks, GFP_KERNEL); - if (tqes == NULL) - return -ENOMEM; - - splat_vprint(file, SPLAT_TASKQ_TEST4_NAME, - "Taskq '%s' creating (%s dispatch) (%d/%d/%d)\n", - SPLAT_TASKQ_TEST4_NAME, - prealloc ? "prealloc" : "dynamic", - minalloc, maxalloc, nr_tasks); - if ((tq = taskq_create(SPLAT_TASKQ_TEST4_NAME, 1, defclsyspri, - minalloc, maxalloc, TASKQ_PREPOPULATE)) == NULL) { - splat_vprint(file, SPLAT_TASKQ_TEST4_NAME, - "Taskq '%s' create failed\n", - SPLAT_TASKQ_TEST4_NAME); - rc = -EINVAL; - goto out_free; - } - - tq_arg.file = file; - tq_arg.name = SPLAT_TASKQ_TEST4_NAME; - tq_arg.count = &count; - - for (i = 1; i <= nr_tasks; i *= 2) { - atomic_set(tq_arg.count, 0); - splat_vprint(file, SPLAT_TASKQ_TEST4_NAME, - "Taskq '%s' function '%s' dispatched %d times\n", - tq_arg.name, sym2str(splat_taskq_test4_func), i); - - for (j = 0; j < i; j++) { - taskq_init_ent(&tqes[j]); - - if (prealloc) { - taskq_dispatch_ent(tq, splat_taskq_test4_func, - &tq_arg, TQ_SLEEP, &tqes[j]); - id = tqes[j].tqent_id; - } else { - id = taskq_dispatch(tq, splat_taskq_test4_func, - &tq_arg, TQ_SLEEP); - } - - if (id == TASKQID_INVALID) { - splat_vprint(file, SPLAT_TASKQ_TEST4_NAME, - "Taskq '%s' function '%s' dispatch " - "%d failed\n", tq_arg.name, - sym2str(splat_taskq_test4_func), j); - rc = -EINVAL; - goto out; - } - } - - splat_vprint(file, SPLAT_TASKQ_TEST4_NAME, "Taskq '%s' " - "waiting for %d dispatches\n", tq_arg.name, i); - taskq_wait(tq); - splat_vprint(file, SPLAT_TASKQ_TEST4_NAME, "Taskq '%s' " - "%d/%d dispatches finished\n", tq_arg.name, - atomic_read(&count), i); - if (atomic_read(&count) != i) { - rc = -ERANGE; - goto out; - - } - } -out: - splat_vprint(file, SPLAT_TASKQ_TEST4_NAME, "Taskq '%s' destroying\n", - tq_arg.name); - taskq_destroy(tq); - -out_free: - kfree(tqes); - - return rc; -} - -static int -splat_taskq_test4_impl(struct file *file, void *arg, boolean_t prealloc) -{ - int rc; - - rc = splat_taskq_test4_common(file, arg, 50, INT_MAX, 1024, prealloc); - if (rc) - return rc; - - rc = splat_taskq_test4_common(file, arg, 1, 1, 32, prealloc); - - return rc; -} - -static int -splat_taskq_test4(struct file *file, void *arg) -{ - int rc; - - rc = splat_taskq_test4_impl(file, arg, B_FALSE); - if (rc) - return rc; - - rc = splat_taskq_test4_impl(file, arg, B_TRUE); - - return rc; -} - -/* - * Create a taskq and dispatch a specific sequence of tasks carefully - * crafted to validate the order in which tasks are processed. When - * there are multiple worker threads each thread will process the - * next pending task as soon as it completes its current task. This - * means that tasks do not strictly complete in order in which they - * were dispatched (increasing task id). This is fine but we need to - * verify taskq_wait_outstanding() blocks until the passed task id and - * all lower task ids complete. We do this by dispatching the following - * specific sequence of tasks each of which block for N time units. - * We then use taskq_wait_outstanding() to unblock at specific task id and - * verify the only the expected task ids have completed and in the - * correct order. The two cases of interest are: - * - * 1) Task ids larger than the waited for task id can run and - * complete as long as there is an available worker thread. - * 2) All task ids lower than the waited one must complete before - * unblocking even if the waited task id itself has completed. - * - * The following table shows each task id and how they will be - * scheduled. Each rows represent one time unit and each column - * one of the three worker threads. The places taskq_wait_outstanding() - * must unblock for a specific id are identified as well as the - * task ids which must have completed and their order. - * - * +-----+ <--- taskq_wait_outstanding(tq, 8) unblocks - * | | Required Completion Order: 1,2,4,5,3,8,6,7 - * +-----+ | - * | | | - * | | +-----+ - * | | | 8 | - * | | +-----+ <--- taskq_wait_outstanding(tq, 3) unblocks - * | | 7 | | Required Completion Order: 1,2,4,5,3 - * | +-----+ | - * | 6 | | | - * +-----+ | | - * | | 5 | | - * | +-----+ | - * | 4 | | | - * +-----+ | | - * | 1 | 2 | 3 | - * +-----+-----+-----+ - * - */ -static void -splat_taskq_test5_func(void *arg) -{ - splat_taskq_id_t *tq_id = (splat_taskq_id_t *)arg; - splat_taskq_arg_t *tq_arg = tq_id->arg; - int factor; - - /* Delays determined by above table */ - switch (tq_id->id) { - default: factor = 0; break; - case 1: case 8: factor = 1; break; - case 2: case 4: case 5: factor = 2; break; - case 6: case 7: factor = 4; break; - case 3: factor = 5; break; - } - - msleep(factor * 100); - splat_vprint(tq_arg->file, tq_arg->name, - "Taskqid %d complete for taskq '%s'\n", - tq_id->id, tq_arg->name); - - spin_lock(&tq_arg->lock); - tq_arg->order[tq_arg->flag] = tq_id->id; - tq_arg->flag++; - spin_unlock(&tq_arg->lock); -} - -static int -splat_taskq_test_order(splat_taskq_arg_t *tq_arg, int *order) -{ - int i, j; - - for (i = 0; i < SPLAT_TASKQ_ORDER_MAX; i++) { - if (tq_arg->order[i] != order[i]) { - splat_vprint(tq_arg->file, tq_arg->name, - "Taskq '%s' incorrect completion " - "order\n", tq_arg->name); - splat_vprint(tq_arg->file, tq_arg->name, - "%s", "Expected { "); - - for (j = 0; j < SPLAT_TASKQ_ORDER_MAX; j++) - splat_print(tq_arg->file, "%d ", order[j]); - - splat_print(tq_arg->file, "%s", "}\n"); - splat_vprint(tq_arg->file, tq_arg->name, - "%s", "Got { "); - - for (j = 0; j < SPLAT_TASKQ_ORDER_MAX; j++) - splat_print(tq_arg->file, "%d ", - tq_arg->order[j]); - - splat_print(tq_arg->file, "%s", "}\n"); - return -EILSEQ; - } - } - - splat_vprint(tq_arg->file, tq_arg->name, - "Taskq '%s' validated correct completion order\n", - tq_arg->name); - - return 0; -} - -static int -splat_taskq_test5_impl(struct file *file, void *arg, boolean_t prealloc) -{ - taskq_t *tq; - taskqid_t id; - splat_taskq_id_t tq_id[SPLAT_TASKQ_ORDER_MAX]; - splat_taskq_arg_t tq_arg; - int order1[SPLAT_TASKQ_ORDER_MAX] = { 1,2,4,5,3,0,0,0 }; - int order2[SPLAT_TASKQ_ORDER_MAX] = { 1,2,4,5,3,8,6,7 }; - taskq_ent_t *tqes; - int i, rc = 0; - - tqes = kmem_alloc(sizeof(*tqes) * SPLAT_TASKQ_ORDER_MAX, KM_SLEEP); - memset(tqes, 0, sizeof(*tqes) * SPLAT_TASKQ_ORDER_MAX); - - splat_vprint(file, SPLAT_TASKQ_TEST5_NAME, - "Taskq '%s' creating (%s dispatch)\n", - SPLAT_TASKQ_TEST5_NAME, - prealloc ? "prealloc" : "dynamic"); - if ((tq = taskq_create(SPLAT_TASKQ_TEST5_NAME, 3, defclsyspri, - 50, INT_MAX, TASKQ_PREPOPULATE)) == NULL) { - splat_vprint(file, SPLAT_TASKQ_TEST5_NAME, - "Taskq '%s' create failed\n", - SPLAT_TASKQ_TEST5_NAME); - return -EINVAL; - } - - tq_arg.flag = 0; - memset(&tq_arg.order, 0, sizeof(int) * SPLAT_TASKQ_ORDER_MAX); - spin_lock_init(&tq_arg.lock); - tq_arg.file = file; - tq_arg.name = SPLAT_TASKQ_TEST5_NAME; - - for (i = 0; i < SPLAT_TASKQ_ORDER_MAX; i++) { - taskq_init_ent(&tqes[i]); - - tq_id[i].id = i + 1; - tq_id[i].arg = &tq_arg; - - if (prealloc) { - taskq_dispatch_ent(tq, splat_taskq_test5_func, - &tq_id[i], TQ_SLEEP, &tqes[i]); - id = tqes[i].tqent_id; - } else { - id = taskq_dispatch(tq, splat_taskq_test5_func, - &tq_id[i], TQ_SLEEP); - } - - if (id == TASKQID_INVALID) { - splat_vprint(file, SPLAT_TASKQ_TEST5_NAME, - "Taskq '%s' function '%s' dispatch failed\n", - tq_arg.name, sym2str(splat_taskq_test5_func)); - rc = -EINVAL; - goto out; - } - - if (tq_id[i].id != id) { - splat_vprint(file, SPLAT_TASKQ_TEST5_NAME, - "Taskq '%s' expected taskqid %d got %d\n", - tq_arg.name, (int)tq_id[i].id, (int)id); - rc = -EINVAL; - goto out; - } - } - - splat_vprint(file, SPLAT_TASKQ_TEST5_NAME, "Taskq '%s' " - "waiting for taskqid %d completion\n", tq_arg.name, 3); - taskq_wait_outstanding(tq, 3); - if ((rc = splat_taskq_test_order(&tq_arg, order1))) - goto out; - - splat_vprint(file, SPLAT_TASKQ_TEST5_NAME, "Taskq '%s' " - "waiting for taskqid %d completion\n", tq_arg.name, 8); - taskq_wait_outstanding(tq, 8); - rc = splat_taskq_test_order(&tq_arg, order2); - -out: - splat_vprint(file, SPLAT_TASKQ_TEST5_NAME, - "Taskq '%s' destroying\n", tq_arg.name); - taskq_destroy(tq); - - kmem_free(tqes, sizeof(*tqes) * SPLAT_TASKQ_ORDER_MAX); - - return rc; -} - -static int -splat_taskq_test5(struct file *file, void *arg) -{ - int rc; - - rc = splat_taskq_test5_impl(file, arg, B_FALSE); - if (rc) - return rc; - - rc = splat_taskq_test5_impl(file, arg, B_TRUE); - - return rc; -} - -/* - * Create a single task queue with three threads. Dispatch 8 tasks, - * setting TQ_FRONT on only the last three. Sleep after - * dispatching tasks 1-3 to ensure they will run and hold the threads - * busy while we dispatch the remaining tasks. Verify that tasks 6-8 - * run before task 4-5. - * - * The following table shows each task id and how they will be - * scheduled. Each rows represent one time unit and each column - * one of the three worker threads. - * - * NB: The Horizontal Line is the LAST Time unit consumed by the Task, - * and must be included in the factor calculation. - * T - * 17-> +-----+ - * 16 | T6 | - * 15-> +-----+ | - * 14 | T6 | | - * 13-> | | 5 +-----+ - * 12 | | | T6 | - * 11-> | +-----| | - * 10 | 4 | T6 | | - * 9-> +-----+ | 8 | - * 8 | T5 | | | - * 7-> | | 7 +-----+ - * 6 | | | T7 | - * 5-> | +-----+ | - * 4 | 6 | T5 | | - * 3-> +-----+ | | - * 2 | T3 | | | - * 1 | 1 | 2 | 3 | - * 0 +-----+-----+-----+ - * - */ -static void -splat_taskq_test6_func(void *arg) -{ - /* Delays determined by above table */ - static const int factor[SPLAT_TASKQ_ORDER_MAX+1] = {0,3,5,7,6,6,5,6,6}; - - splat_taskq_id_t *tq_id = (splat_taskq_id_t *)arg; - splat_taskq_arg_t *tq_arg = tq_id->arg; - - splat_vprint(tq_arg->file, tq_arg->name, - "Taskqid %d starting for taskq '%s'\n", - tq_id->id, tq_arg->name); - - if (tq_id->id < SPLAT_TASKQ_ORDER_MAX+1) { - msleep(factor[tq_id->id] * 50); - } - - spin_lock(&tq_arg->lock); - tq_arg->order[tq_arg->flag] = tq_id->id; - tq_arg->flag++; - spin_unlock(&tq_arg->lock); - - splat_vprint(tq_arg->file, tq_arg->name, - "Taskqid %d complete for taskq '%s'\n", - tq_id->id, tq_arg->name); -} - -static int -splat_taskq_test6_impl(struct file *file, void *arg, boolean_t prealloc) -{ - taskq_t *tq; - taskqid_t id; - splat_taskq_id_t tq_id[SPLAT_TASKQ_ORDER_MAX]; - splat_taskq_arg_t tq_arg; - int order[SPLAT_TASKQ_ORDER_MAX] = { 1,2,3,6,7,8,4,5 }; - taskq_ent_t *tqes; - int i, rc = 0; - uint_t tflags; - - tqes = kmem_alloc(sizeof(*tqes) * SPLAT_TASKQ_ORDER_MAX, KM_SLEEP); - memset(tqes, 0, sizeof(*tqes) * SPLAT_TASKQ_ORDER_MAX); - - splat_vprint(file, SPLAT_TASKQ_TEST6_NAME, - "Taskq '%s' creating (%s dispatch)\n", - SPLAT_TASKQ_TEST6_NAME, - prealloc ? "prealloc" : "dynamic"); - if ((tq = taskq_create(SPLAT_TASKQ_TEST6_NAME, 3, defclsyspri, - 50, INT_MAX, TASKQ_PREPOPULATE)) == NULL) { - splat_vprint(file, SPLAT_TASKQ_TEST6_NAME, - "Taskq '%s' create failed\n", - SPLAT_TASKQ_TEST6_NAME); - return -EINVAL; - } - - tq_arg.flag = 0; - memset(&tq_arg.order, 0, sizeof(int) * SPLAT_TASKQ_ORDER_MAX); - spin_lock_init(&tq_arg.lock); - tq_arg.file = file; - tq_arg.name = SPLAT_TASKQ_TEST6_NAME; - - for (i = 0; i < SPLAT_TASKQ_ORDER_MAX; i++) { - taskq_init_ent(&tqes[i]); - - tq_id[i].id = i + 1; - tq_id[i].arg = &tq_arg; - tflags = TQ_SLEEP; - if (i > 4) - tflags |= TQ_FRONT; - - if (prealloc) { - taskq_dispatch_ent(tq, splat_taskq_test6_func, - &tq_id[i], tflags, &tqes[i]); - id = tqes[i].tqent_id; - } else { - id = taskq_dispatch(tq, splat_taskq_test6_func, - &tq_id[i], tflags); - } - - if (id == TASKQID_INVALID) { - splat_vprint(file, SPLAT_TASKQ_TEST6_NAME, - "Taskq '%s' function '%s' dispatch failed\n", - tq_arg.name, sym2str(splat_taskq_test6_func)); - rc = -EINVAL; - goto out; - } - - if (tq_id[i].id != id) { - splat_vprint(file, SPLAT_TASKQ_TEST6_NAME, - "Taskq '%s' expected taskqid %d got %d\n", - tq_arg.name, (int)tq_id[i].id, (int)id); - rc = -EINVAL; - goto out; - } - /* Sleep to let tasks 1-3 start executing. */ - if ( i == 2 ) - msleep(100); - } - - splat_vprint(file, SPLAT_TASKQ_TEST6_NAME, "Taskq '%s' " - "waiting for taskqid %d completion\n", tq_arg.name, - SPLAT_TASKQ_ORDER_MAX); - taskq_wait_outstanding(tq, SPLAT_TASKQ_ORDER_MAX); - rc = splat_taskq_test_order(&tq_arg, order); - -out: - splat_vprint(file, SPLAT_TASKQ_TEST6_NAME, - "Taskq '%s' destroying\n", tq_arg.name); - taskq_destroy(tq); - - kmem_free(tqes, sizeof(*tqes) * SPLAT_TASKQ_ORDER_MAX); - - return rc; -} - -static int -splat_taskq_test6(struct file *file, void *arg) -{ - int rc; - - rc = splat_taskq_test6_impl(file, arg, B_FALSE); - if (rc) - return rc; - - rc = splat_taskq_test6_impl(file, arg, B_TRUE); - - return rc; -} - -static void -splat_taskq_test7_func(void *arg) -{ - splat_taskq_arg_t *tq_arg = (splat_taskq_arg_t *)arg; - taskqid_t id; - - ASSERT(tq_arg); - - if (tq_arg->depth >= SPLAT_TASKQ_DEPTH_MAX) - return; - - tq_arg->depth++; - - splat_vprint(tq_arg->file, SPLAT_TASKQ_TEST7_NAME, - "Taskq '%s' function '%s' dispatching (depth = %u)\n", - tq_arg->name, sym2str(splat_taskq_test7_func), - tq_arg->depth); - - if (tq_arg->tqe) { - VERIFY(taskq_empty_ent(tq_arg->tqe)); - taskq_dispatch_ent(tq_arg->tq, splat_taskq_test7_func, - tq_arg, TQ_SLEEP, tq_arg->tqe); - id = tq_arg->tqe->tqent_id; - } else { - id = taskq_dispatch(tq_arg->tq, splat_taskq_test7_func, - tq_arg, TQ_SLEEP); - } - - if (id == TASKQID_INVALID) { - splat_vprint(tq_arg->file, SPLAT_TASKQ_TEST7_NAME, - "Taskq '%s' function '%s' dispatch failed " - "(depth = %u)\n", tq_arg->name, - sym2str(splat_taskq_test7_func), tq_arg->depth); - tq_arg->flag = -EINVAL; - return; - } -} - -static int -splat_taskq_test7_impl(struct file *file, void *arg, boolean_t prealloc) -{ - taskq_t *tq; - splat_taskq_arg_t *tq_arg; - taskq_ent_t *tqe; - int error; - - splat_vprint(file, SPLAT_TASKQ_TEST7_NAME, - "Taskq '%s' creating (%s dispatch)\n", - SPLAT_TASKQ_TEST7_NAME, - prealloc ? "prealloc" : "dynamic"); - if ((tq = taskq_create(SPLAT_TASKQ_TEST7_NAME, 1, defclsyspri, - 50, INT_MAX, TASKQ_PREPOPULATE)) == NULL) { - splat_vprint(file, SPLAT_TASKQ_TEST7_NAME, - "Taskq '%s' create failed\n", - SPLAT_TASKQ_TEST7_NAME); - return -EINVAL; - } - - tq_arg = kmem_alloc(sizeof (splat_taskq_arg_t), KM_SLEEP); - tqe = kmem_alloc(sizeof (taskq_ent_t), KM_SLEEP); - - tq_arg->depth = 0; - tq_arg->flag = 0; - tq_arg->id = 0; - tq_arg->file = file; - tq_arg->name = SPLAT_TASKQ_TEST7_NAME; - tq_arg->tq = tq; - - if (prealloc) { - taskq_init_ent(tqe); - tq_arg->tqe = tqe; - } else { - tq_arg->tqe = NULL; - } - - splat_taskq_test7_func(tq_arg); - - if (tq_arg->flag == 0) { - splat_vprint(file, SPLAT_TASKQ_TEST7_NAME, - "Taskq '%s' waiting\n", tq_arg->name); - taskq_wait_outstanding(tq, SPLAT_TASKQ_DEPTH_MAX); - } - - error = (tq_arg->depth == SPLAT_TASKQ_DEPTH_MAX ? 0 : -EINVAL); - - splat_vprint(file, SPLAT_TASKQ_TEST7_NAME, - "Taskq '%s' destroying\n", tq_arg->name); - - kmem_free(tqe, sizeof (taskq_ent_t)); - kmem_free(tq_arg, sizeof (splat_taskq_arg_t)); - - taskq_destroy(tq); - - return (error); -} - -static int -splat_taskq_test7(struct file *file, void *arg) -{ - int rc; - - rc = splat_taskq_test7_impl(file, arg, B_FALSE); - if (rc) - return (rc); - - rc = splat_taskq_test7_impl(file, arg, B_TRUE); - - return (rc); -} - -static void -splat_taskq_throughput_func(void *arg) -{ - splat_taskq_arg_t *tq_arg = (splat_taskq_arg_t *)arg; - ASSERT(tq_arg); - - atomic_inc(tq_arg->count); -} - -static int -splat_taskq_throughput(struct file *file, void *arg, const char *name, - int nthreads, int minalloc, int maxalloc, int flags, int tasks, - struct timespec *delta) -{ - taskq_t *tq; - taskqid_t id; - splat_taskq_arg_t tq_arg; - taskq_ent_t **tqes; - atomic_t count; - struct timespec start, stop; - int i, j, rc = 0; - - tqes = vmalloc(sizeof (*tqes) * tasks); - if (tqes == NULL) - return (-ENOMEM); - - memset(tqes, 0, sizeof (*tqes) * tasks); - - splat_vprint(file, name, "Taskq '%s' creating (%d/%d/%d/%d)\n", - name, nthreads, minalloc, maxalloc, tasks); - if ((tq = taskq_create(name, nthreads, defclsyspri, - minalloc, maxalloc, flags)) == NULL) { - splat_vprint(file, name, "Taskq '%s' create failed\n", name); - rc = -EINVAL; - goto out_free; - } - - tq_arg.file = file; - tq_arg.name = name; - tq_arg.count = &count; - atomic_set(tq_arg.count, 0); - - getnstimeofday(&start); - - for (i = 0; i < tasks; i++) { - tqes[i] = kmalloc(sizeof (taskq_ent_t), GFP_KERNEL); - if (tqes[i] == NULL) { - rc = -ENOMEM; - goto out; - } - - taskq_init_ent(tqes[i]); - taskq_dispatch_ent(tq, splat_taskq_throughput_func, - &tq_arg, TQ_SLEEP, tqes[i]); - id = tqes[i]->tqent_id; - - if (id == TASKQID_INVALID) { - splat_vprint(file, name, "Taskq '%s' function '%s' " - "dispatch %d failed\n", tq_arg.name, - sym2str(splat_taskq_throughput_func), i); - rc = -EINVAL; - goto out; - } - } - - splat_vprint(file, name, "Taskq '%s' waiting for %d dispatches\n", - tq_arg.name, tasks); - - taskq_wait(tq); - - if (delta != NULL) { - getnstimeofday(&stop); - *delta = timespec_sub(stop, start); - } - - splat_vprint(file, name, "Taskq '%s' %d/%d dispatches finished\n", - tq_arg.name, atomic_read(tq_arg.count), tasks); - - if (atomic_read(tq_arg.count) != tasks) - rc = -ERANGE; - -out: - splat_vprint(file, name, "Taskq '%s' destroying\n", tq_arg.name); - taskq_destroy(tq); -out_free: - for (j = 0; j < tasks && tqes[j] != NULL; j++) - kfree(tqes[j]); - - vfree(tqes); - - return (rc); -} - -/* - * Create a taskq with 100 threads and dispatch a huge number of trivial - * tasks to generate contention on tq->tq_lock. This test should always - * pass. The purpose is to provide a benchmark for measuring the - * effectiveness of taskq optimizations. - */ -#define TEST8_NUM_TASKS 0x20000 -#define TEST8_THREADS_PER_TASKQ 100 - -static int -splat_taskq_test8(struct file *file, void *arg) -{ - return (splat_taskq_throughput(file, arg, - SPLAT_TASKQ_TEST8_NAME, TEST8_THREADS_PER_TASKQ, - 1, INT_MAX, TASKQ_PREPOPULATE, TEST8_NUM_TASKS, NULL)); -} - -/* - * Create a taskq and dispatch a number of delayed tasks to the queue. - * For each task verify that it was run no early than requested. - */ -static void -splat_taskq_test9_func(void *arg) -{ - splat_taskq_arg_t *tq_arg = (splat_taskq_arg_t *)arg; - ASSERT(tq_arg); - - if (ddi_time_after_eq(ddi_get_lbolt(), tq_arg->expire)) - atomic_inc(tq_arg->count); - - kmem_free(tq_arg, sizeof(splat_taskq_arg_t)); -} - -static int -splat_taskq_test9(struct file *file, void *arg) -{ - taskq_t *tq; - atomic_t count; - int i, rc = 0; - int minalloc = 1; - int maxalloc = 10; - int nr_tasks = 100; - - splat_vprint(file, SPLAT_TASKQ_TEST9_NAME, - "Taskq '%s' creating (%s dispatch) (%d/%d/%d)\n", - SPLAT_TASKQ_TEST9_NAME, "delay", minalloc, maxalloc, nr_tasks); - if ((tq = taskq_create(SPLAT_TASKQ_TEST9_NAME, 3, defclsyspri, - minalloc, maxalloc, TASKQ_PREPOPULATE)) == NULL) { - splat_vprint(file, SPLAT_TASKQ_TEST9_NAME, - "Taskq '%s' create failed\n", SPLAT_TASKQ_TEST9_NAME); - return -EINVAL; - } - - atomic_set(&count, 0); - - for (i = 1; i <= nr_tasks; i++) { - splat_taskq_arg_t *tq_arg; - taskqid_t id; - uint32_t rnd; - - /* A random timeout in jiffies of at most 5 seconds */ - get_random_bytes((void *)&rnd, 4); - rnd = rnd % (5 * HZ); - - tq_arg = kmem_alloc(sizeof(splat_taskq_arg_t), KM_SLEEP); - tq_arg->file = file; - tq_arg->name = SPLAT_TASKQ_TEST9_NAME; - tq_arg->expire = ddi_get_lbolt() + rnd; - tq_arg->count = &count; - - splat_vprint(file, SPLAT_TASKQ_TEST9_NAME, - "Taskq '%s' delay dispatch %u jiffies\n", - SPLAT_TASKQ_TEST9_NAME, rnd); - - id = taskq_dispatch_delay(tq, splat_taskq_test9_func, - tq_arg, TQ_SLEEP, ddi_get_lbolt() + rnd); - - if (id == TASKQID_INVALID) { - splat_vprint(file, SPLAT_TASKQ_TEST9_NAME, - "Taskq '%s' delay dispatch failed\n", - SPLAT_TASKQ_TEST9_NAME); - kmem_free(tq_arg, sizeof(splat_taskq_arg_t)); - taskq_wait(tq); - rc = -EINVAL; - goto out; - } - } - - splat_vprint(file, SPLAT_TASKQ_TEST9_NAME, "Taskq '%s' waiting for " - "%d delay dispatches\n", SPLAT_TASKQ_TEST9_NAME, nr_tasks); - - taskq_wait(tq); - if (atomic_read(&count) != nr_tasks) - rc = -ERANGE; - - splat_vprint(file, SPLAT_TASKQ_TEST9_NAME, "Taskq '%s' %d/%d delay " - "dispatches finished on time\n", SPLAT_TASKQ_TEST9_NAME, - atomic_read(&count), nr_tasks); - splat_vprint(file, SPLAT_TASKQ_TEST9_NAME, "Taskq '%s' destroying\n", - SPLAT_TASKQ_TEST9_NAME); -out: - taskq_destroy(tq); - - return rc; -} - -/* - * Create a taskq and dispatch then cancel tasks in the queue. - */ -static void -splat_taskq_test10_func(void *arg) -{ - splat_taskq_arg_t *tq_arg = (splat_taskq_arg_t *)arg; - uint8_t rnd; - - if (ddi_time_after_eq(ddi_get_lbolt(), tq_arg->expire)) - atomic_inc(tq_arg->count); - - /* Randomly sleep to further perturb the system */ - get_random_bytes((void *)&rnd, 1); - msleep(1 + (rnd % 9)); -} - -static int -splat_taskq_test10(struct file *file, void *arg) -{ - taskq_t *tq; - splat_taskq_arg_t **tqas; - atomic_t count; - int i, j, rc = 0; - int minalloc = 1; - int maxalloc = 10; - int nr_tasks = 100; - int canceled = 0; - int completed = 0; - int blocked = 0; - clock_t start, cancel; - - tqas = vmalloc(sizeof(*tqas) * nr_tasks); - if (tqas == NULL) - return -ENOMEM; - memset(tqas, 0, sizeof(*tqas) * nr_tasks); - - splat_vprint(file, SPLAT_TASKQ_TEST10_NAME, - "Taskq '%s' creating (%s dispatch) (%d/%d/%d)\n", - SPLAT_TASKQ_TEST10_NAME, "delay", minalloc, maxalloc, nr_tasks); - if ((tq = taskq_create(SPLAT_TASKQ_TEST10_NAME, 3, defclsyspri, - minalloc, maxalloc, TASKQ_PREPOPULATE)) == NULL) { - splat_vprint(file, SPLAT_TASKQ_TEST10_NAME, - "Taskq '%s' create failed\n", SPLAT_TASKQ_TEST10_NAME); - rc = -EINVAL; - goto out_free; - } - - atomic_set(&count, 0); - - for (i = 0; i < nr_tasks; i++) { - splat_taskq_arg_t *tq_arg; - uint32_t rnd; - - /* A random timeout in jiffies of at most 5 seconds */ - get_random_bytes((void *)&rnd, 4); - rnd = rnd % (5 * HZ); - - tq_arg = kmem_alloc(sizeof(splat_taskq_arg_t), KM_SLEEP); - tq_arg->file = file; - tq_arg->name = SPLAT_TASKQ_TEST10_NAME; - tq_arg->count = &count; - tqas[i] = tq_arg; - - /* - * Dispatch every 1/3 one immediately to mix it up, the cancel - * code is inherently racy and we want to try and provoke any - * subtle concurrently issues. - */ - if ((i % 3) == 0) { - tq_arg->expire = ddi_get_lbolt(); - tq_arg->id = taskq_dispatch(tq, splat_taskq_test10_func, - tq_arg, TQ_SLEEP); - } else { - tq_arg->expire = ddi_get_lbolt() + rnd; - tq_arg->id = taskq_dispatch_delay(tq, - splat_taskq_test10_func, - tq_arg, TQ_SLEEP, ddi_get_lbolt() + rnd); - } - - if (tq_arg->id == TASKQID_INVALID) { - splat_vprint(file, SPLAT_TASKQ_TEST10_NAME, - "Taskq '%s' dispatch failed\n", - SPLAT_TASKQ_TEST10_NAME); - kmem_free(tq_arg, sizeof(splat_taskq_arg_t)); - taskq_wait(tq); - rc = -EINVAL; - goto out; - } else { - splat_vprint(file, SPLAT_TASKQ_TEST10_NAME, - "Taskq '%s' dispatch %lu in %lu jiffies\n", - SPLAT_TASKQ_TEST10_NAME, (unsigned long)tq_arg->id, - !(i % 3) ? 0 : tq_arg->expire - ddi_get_lbolt()); - } - } - - /* - * Start randomly canceling tasks for the duration of the test. We - * happen to know the valid task id's will be in the range 1..nr_tasks - * because the taskq is private and was just created. However, we - * have no idea of a particular task has already executed or not. - */ - splat_vprint(file, SPLAT_TASKQ_TEST10_NAME, "Taskq '%s' randomly " - "canceling task ids\n", SPLAT_TASKQ_TEST10_NAME); - - start = ddi_get_lbolt(); - i = 0; - - while (ddi_time_before(ddi_get_lbolt(), start + 5 * HZ)) { - taskqid_t id; - uint32_t rnd; - - i++; - cancel = ddi_get_lbolt(); - get_random_bytes((void *)&rnd, 4); - id = 1 + (rnd % nr_tasks); - rc = taskq_cancel_id(tq, id); - - /* - * Keep track of the results of the random cancels. - */ - if (rc == 0) { - canceled++; - } else if (rc == ENOENT) { - completed++; - } else if (rc == EBUSY) { - blocked++; - } else { - rc = -EINVAL; - break; - } - - /* - * Verify we never get blocked to long in taskq_cancel_id(). - * The worst case is 10ms if we happen to cancel the task - * which is currently executing. We allow a factor of 2x. - */ - if (ddi_get_lbolt() - cancel > HZ / 50) { - splat_vprint(file, SPLAT_TASKQ_TEST10_NAME, - "Taskq '%s' cancel for %lu took %lu\n", - SPLAT_TASKQ_TEST10_NAME, (unsigned long)id, - ddi_get_lbolt() - cancel); - rc = -ETIMEDOUT; - break; - } - - get_random_bytes((void *)&rnd, 4); - msleep(1 + (rnd % 100)); - rc = 0; - } - - taskq_wait(tq); - - /* - * Cross check the results of taskq_cancel_id() with the number of - * times the dispatched function actually ran successfully. - */ - if ((rc == 0) && (nr_tasks - canceled != atomic_read(&count))) - rc = -EDOM; - - splat_vprint(file, SPLAT_TASKQ_TEST10_NAME, "Taskq '%s' %d attempts, " - "%d canceled, %d completed, %d blocked, %d/%d tasks run\n", - SPLAT_TASKQ_TEST10_NAME, i, canceled, completed, blocked, - atomic_read(&count), nr_tasks); - splat_vprint(file, SPLAT_TASKQ_TEST10_NAME, "Taskq '%s' destroying %d\n", - SPLAT_TASKQ_TEST10_NAME, rc); -out: - taskq_destroy(tq); -out_free: - for (j = 0; j < nr_tasks && tqas[j] != NULL; j++) - kmem_free(tqas[j], sizeof(splat_taskq_arg_t)); - vfree(tqas); - - return rc; -} - -/* - * Create a dynamic taskq with 100 threads and dispatch a huge number of - * trivial tasks. This will cause the taskq to grow quickly to its max - * thread count. This test should always pass. The purpose is to provide - * a benchmark for measuring the performance of dynamic taskqs. - */ -#define TEST11_NUM_TASKS 100000 -#define TEST11_THREADS_PER_TASKQ 100 - -static int -splat_taskq_test11(struct file *file, void *arg) -{ - struct timespec normal, dynamic; - int error; - - error = splat_taskq_throughput(file, arg, SPLAT_TASKQ_TEST11_NAME, - TEST11_THREADS_PER_TASKQ, 1, INT_MAX, - TASKQ_PREPOPULATE, TEST11_NUM_TASKS, &normal); - if (error) - return (error); - - error = splat_taskq_throughput(file, arg, SPLAT_TASKQ_TEST11_NAME, - TEST11_THREADS_PER_TASKQ, 1, INT_MAX, - TASKQ_PREPOPULATE | TASKQ_DYNAMIC, TEST11_NUM_TASKS, &dynamic); - if (error) - return (error); - - splat_vprint(file, SPLAT_TASKQ_TEST11_NAME, - "Timing taskq_wait(): normal=%ld.%09lds, dynamic=%ld.%09lds\n", - normal.tv_sec, normal.tv_nsec, - dynamic.tv_sec, dynamic.tv_nsec); - - /* A 10x increase in runtime is used to indicate a core problem. */ - if (((int64_t)dynamic.tv_sec * NANOSEC + (int64_t)dynamic.tv_nsec) > - (((int64_t)normal.tv_sec * NANOSEC + (int64_t)normal.tv_nsec) * 10)) - error = -ETIME; - - return (error); -} - -splat_subsystem_t * -splat_taskq_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_TASKQ_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_TASKQ_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_TASKQ; - - splat_test_init(sub, SPLAT_TASKQ_TEST1_NAME, SPLAT_TASKQ_TEST1_DESC, - SPLAT_TASKQ_TEST1_ID, splat_taskq_test1); - splat_test_init(sub, SPLAT_TASKQ_TEST2_NAME, SPLAT_TASKQ_TEST2_DESC, - SPLAT_TASKQ_TEST2_ID, splat_taskq_test2); - splat_test_init(sub, SPLAT_TASKQ_TEST3_NAME, SPLAT_TASKQ_TEST3_DESC, - SPLAT_TASKQ_TEST3_ID, splat_taskq_test3); - splat_test_init(sub, SPLAT_TASKQ_TEST4_NAME, SPLAT_TASKQ_TEST4_DESC, - SPLAT_TASKQ_TEST4_ID, splat_taskq_test4); - splat_test_init(sub, SPLAT_TASKQ_TEST5_NAME, SPLAT_TASKQ_TEST5_DESC, - SPLAT_TASKQ_TEST5_ID, splat_taskq_test5); - splat_test_init(sub, SPLAT_TASKQ_TEST6_NAME, SPLAT_TASKQ_TEST6_DESC, - SPLAT_TASKQ_TEST6_ID, splat_taskq_test6); - splat_test_init(sub, SPLAT_TASKQ_TEST7_NAME, SPLAT_TASKQ_TEST7_DESC, - SPLAT_TASKQ_TEST7_ID, splat_taskq_test7); - splat_test_init(sub, SPLAT_TASKQ_TEST8_NAME, SPLAT_TASKQ_TEST8_DESC, - SPLAT_TASKQ_TEST8_ID, splat_taskq_test8); - splat_test_init(sub, SPLAT_TASKQ_TEST9_NAME, SPLAT_TASKQ_TEST9_DESC, - SPLAT_TASKQ_TEST9_ID, splat_taskq_test9); - splat_test_init(sub, SPLAT_TASKQ_TEST10_NAME, SPLAT_TASKQ_TEST10_DESC, - SPLAT_TASKQ_TEST10_ID, splat_taskq_test10); - splat_test_init(sub, SPLAT_TASKQ_TEST11_NAME, SPLAT_TASKQ_TEST11_DESC, - SPLAT_TASKQ_TEST11_ID, splat_taskq_test11); - - return sub; -} - -void -splat_taskq_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - splat_test_fini(sub, SPLAT_TASKQ_TEST11_ID); - splat_test_fini(sub, SPLAT_TASKQ_TEST10_ID); - splat_test_fini(sub, SPLAT_TASKQ_TEST9_ID); - splat_test_fini(sub, SPLAT_TASKQ_TEST8_ID); - splat_test_fini(sub, SPLAT_TASKQ_TEST7_ID); - splat_test_fini(sub, SPLAT_TASKQ_TEST6_ID); - splat_test_fini(sub, SPLAT_TASKQ_TEST5_ID); - splat_test_fini(sub, SPLAT_TASKQ_TEST4_ID); - splat_test_fini(sub, SPLAT_TASKQ_TEST3_ID); - splat_test_fini(sub, SPLAT_TASKQ_TEST2_ID); - splat_test_fini(sub, SPLAT_TASKQ_TEST1_ID); - - kfree(sub); -} - -int -splat_taskq_id(void) { - return SPLAT_SUBSYSTEM_TASKQ; -} diff --git a/module/splat/splat-thread.c b/module/splat/splat-thread.c deleted file mode 100644 index f2e6bf15e..000000000 --- a/module/splat/splat-thread.c +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Thread Tests. - */ - -#include -#include -#include -#include -#include -#include -#include "splat-internal.h" - -#define SPLAT_THREAD_NAME "thread" -#define SPLAT_THREAD_DESC "Kernel Thread Tests" - -#define SPLAT_THREAD_TEST1_ID 0x0601 -#define SPLAT_THREAD_TEST1_NAME "create" -#define SPLAT_THREAD_TEST1_DESC "Validate thread creation" - -#define SPLAT_THREAD_TEST2_ID 0x0602 -#define SPLAT_THREAD_TEST2_NAME "exit" -#define SPLAT_THREAD_TEST2_DESC "Validate thread exit" - -#define SPLAT_THREAD_TEST3_ID 0x6003 -#define SPLAT_THREAD_TEST3_NAME "tsd" -#define SPLAT_THREAD_TEST3_DESC "Validate thread specific data" - -#define SPLAT_THREAD_TEST_MAGIC 0x4488CC00UL -#define SPLAT_THREAD_TEST_KEYS 32 -#define SPLAT_THREAD_TEST_THREADS 16 - -typedef struct thread_priv { - unsigned long tp_magic; - struct file *tp_file; - spinlock_t tp_lock; - spl_wait_queue_head_t tp_waitq; - uint_t tp_keys[SPLAT_THREAD_TEST_KEYS]; - int tp_rc; - int tp_count; - int tp_dtor_count; -} thread_priv_t; - -static int -splat_thread_rc(thread_priv_t *tp, int rc) -{ - int ret; - - spin_lock(&tp->tp_lock); - ret = (tp->tp_rc == rc); - spin_unlock(&tp->tp_lock); - - return ret; -} - -static int -splat_thread_count(thread_priv_t *tp, int count) -{ - int ret; - - spin_lock(&tp->tp_lock); - ret = (tp->tp_count == count); - spin_unlock(&tp->tp_lock); - - return ret; -} - -static void -splat_thread_work1(void *priv) -{ - thread_priv_t *tp = (thread_priv_t *)priv; - - spin_lock(&tp->tp_lock); - ASSERT(tp->tp_magic == SPLAT_THREAD_TEST_MAGIC); - tp->tp_rc = 1; - wake_up(&tp->tp_waitq); - spin_unlock(&tp->tp_lock); - - thread_exit(); -} - -static int -splat_thread_test1(struct file *file, void *arg) -{ - thread_priv_t tp; - kthread_t *thr; - - tp.tp_magic = SPLAT_THREAD_TEST_MAGIC; - tp.tp_file = file; - spin_lock_init(&tp.tp_lock); - init_waitqueue_head(&tp.tp_waitq); - tp.tp_rc = 0; - - thr = (kthread_t *)thread_create(NULL, 0, splat_thread_work1, &tp, 0, - &p0, TS_RUN, defclsyspri); - /* Must never fail under Solaris, but we check anyway since this - * can happen in the linux SPL, we may want to change this behavior */ - if (thr == NULL) - return -ESRCH; - - /* Sleep until the thread sets tp.tp_rc == 1 */ - wait_event(tp.tp_waitq, splat_thread_rc(&tp, 1)); - - splat_vprint(file, SPLAT_THREAD_TEST1_NAME, "%s", - "Thread successfully started properly\n"); - return 0; -} - -static void -splat_thread_work2(void *priv) -{ - thread_priv_t *tp = (thread_priv_t *)priv; - - spin_lock(&tp->tp_lock); - ASSERT(tp->tp_magic == SPLAT_THREAD_TEST_MAGIC); - tp->tp_rc = 1; - wake_up(&tp->tp_waitq); - spin_unlock(&tp->tp_lock); - - thread_exit(); - - /* The following code is unreachable when thread_exit() is - * working properly, which is exactly what we're testing */ - spin_lock(&tp->tp_lock); - tp->tp_rc = 2; - wake_up(&tp->tp_waitq); - spin_unlock(&tp->tp_lock); -} - -static int -splat_thread_test2(struct file *file, void *arg) -{ - thread_priv_t tp; - kthread_t *thr; - int rc = 0; - - tp.tp_magic = SPLAT_THREAD_TEST_MAGIC; - tp.tp_file = file; - spin_lock_init(&tp.tp_lock); - init_waitqueue_head(&tp.tp_waitq); - tp.tp_rc = 0; - - thr = (kthread_t *)thread_create(NULL, 0, splat_thread_work2, &tp, 0, - &p0, TS_RUN, defclsyspri); - /* Must never fail under Solaris, but we check anyway since this - * can happen in the linux SPL, we may want to change this behavior */ - if (thr == NULL) - return -ESRCH; - - /* Sleep until the thread sets tp.tp_rc == 1 */ - wait_event(tp.tp_waitq, splat_thread_rc(&tp, 1)); - - /* Sleep until the thread sets tp.tp_rc == 2, or until we hit - * the timeout. If thread exit is working properly we should - * hit the timeout and never see to.tp_rc == 2. */ - rc = wait_event_timeout(tp.tp_waitq, splat_thread_rc(&tp, 2), HZ / 10); - if (rc > 0) { - rc = -EINVAL; - splat_vprint(file, SPLAT_THREAD_TEST2_NAME, "%s", - "Thread did not exit properly at thread_exit()\n"); - } else { - splat_vprint(file, SPLAT_THREAD_TEST2_NAME, "%s", - "Thread successfully exited at thread_exit()\n"); - } - - return rc; -} - -static void -splat_thread_work3_common(thread_priv_t *tp) -{ - ulong_t rnd; - int i, rc = 0; - - /* set a unique value for each key using a random value */ - get_random_bytes((void *)&rnd, 4); - for (i = 0; i < SPLAT_THREAD_TEST_KEYS; i++) - tsd_set(tp->tp_keys[i], (void *)(i + rnd)); - - /* verify the unique value for each key */ - for (i = 0; i < SPLAT_THREAD_TEST_KEYS; i++) - if (tsd_get(tp->tp_keys[i]) != (void *)(i + rnd)) - rc = -EINVAL; - - /* set the value to thread_priv_t for use by the destructor */ - for (i = 0; i < SPLAT_THREAD_TEST_KEYS; i++) - tsd_set(tp->tp_keys[i], (void *)tp); - - spin_lock(&tp->tp_lock); - if (rc && !tp->tp_rc) - tp->tp_rc = rc; - - tp->tp_count++; - wake_up_all(&tp->tp_waitq); - spin_unlock(&tp->tp_lock); -} - -static void -splat_thread_work3_wait(void *priv) -{ - thread_priv_t *tp = (thread_priv_t *)priv; - - ASSERT(tp->tp_magic == SPLAT_THREAD_TEST_MAGIC); - splat_thread_work3_common(tp); - wait_event(tp->tp_waitq, splat_thread_count(tp, 0)); - thread_exit(); -} - -static void -splat_thread_work3_exit(void *priv) -{ - thread_priv_t *tp = (thread_priv_t *)priv; - - ASSERT(tp->tp_magic == SPLAT_THREAD_TEST_MAGIC); - splat_thread_work3_common(tp); - thread_exit(); -} - -static void -splat_thread_dtor3(void *priv) -{ - thread_priv_t *tp = (thread_priv_t *)priv; - - ASSERT(tp->tp_magic == SPLAT_THREAD_TEST_MAGIC); - spin_lock(&tp->tp_lock); - tp->tp_dtor_count++; - spin_unlock(&tp->tp_lock); -} - -/* - * Create threads which set and verify SPLAT_THREAD_TEST_KEYS number of - * keys. These threads may then exit by calling thread_exit() which calls - * tsd_exit() resulting in all their thread specific data being reclaimed. - * Alternately, the thread may block in which case the thread specific - * data will be reclaimed as part of tsd_destroy(). In either case all - * thread specific data must be reclaimed, this is verified by ensuring - * the registered destructor is called the correct number of times. - */ -static int -splat_thread_test3(struct file *file, void *arg) -{ - int i, rc = 0, expected, wait_count = 0, exit_count = 0; - thread_priv_t tp; - - tp.tp_magic = SPLAT_THREAD_TEST_MAGIC; - tp.tp_file = file; - spin_lock_init(&tp.tp_lock); - init_waitqueue_head(&tp.tp_waitq); - tp.tp_rc = 0; - tp.tp_count = 0; - tp.tp_dtor_count = 0; - - for (i = 0; i < SPLAT_THREAD_TEST_KEYS; i++) { - tp.tp_keys[i] = 0; - tsd_create(&tp.tp_keys[i], splat_thread_dtor3); - } - - /* Start tsd wait threads */ - for (i = 0; i < SPLAT_THREAD_TEST_THREADS; i++) { - if (thread_create(NULL, 0, splat_thread_work3_wait, - &tp, 0, &p0, TS_RUN, defclsyspri)) - wait_count++; - } - - /* All wait threads have setup their tsd and are blocking. */ - wait_event(tp.tp_waitq, splat_thread_count(&tp, wait_count)); - - if (tp.tp_dtor_count != 0) { - splat_vprint(file, SPLAT_THREAD_TEST3_NAME, - "Prematurely ran %d tsd destructors\n", tp.tp_dtor_count); - if (!rc) - rc = -ERANGE; - } - - /* Start tsd exit threads */ - for (i = 0; i < SPLAT_THREAD_TEST_THREADS; i++) { - if (thread_create(NULL, 0, splat_thread_work3_exit, - &tp, 0, &p0, TS_RUN, defclsyspri)) - exit_count++; - } - - /* All exit threads verified tsd and are in the process of exiting */ - wait_event(tp.tp_waitq,splat_thread_count(&tp, wait_count+exit_count)); - msleep(500); - - expected = (SPLAT_THREAD_TEST_KEYS * exit_count); - if (tp.tp_dtor_count != expected) { - splat_vprint(file, SPLAT_THREAD_TEST3_NAME, - "Expected %d exit tsd destructors but saw %d\n", - expected, tp.tp_dtor_count); - if (!rc) - rc = -ERANGE; - } - - /* Destroy all keys and associated tsd in blocked threads */ - for (i = 0; i < SPLAT_THREAD_TEST_KEYS; i++) - tsd_destroy(&tp.tp_keys[i]); - - expected = (SPLAT_THREAD_TEST_KEYS * (exit_count + wait_count)); - if (tp.tp_dtor_count != expected) { - splat_vprint(file, SPLAT_THREAD_TEST3_NAME, - "Expected %d wait+exit tsd destructors but saw %d\n", - expected, tp.tp_dtor_count); - if (!rc) - rc = -ERANGE; - } - - /* Release the remaining wait threads, sleep briefly while they exit */ - spin_lock(&tp.tp_lock); - tp.tp_count = 0; - wake_up_all(&tp.tp_waitq); - spin_unlock(&tp.tp_lock); - msleep(500); - - if (tp.tp_rc) { - splat_vprint(file, SPLAT_THREAD_TEST3_NAME, - "Thread tsd_get()/tsd_set() error %d\n", tp.tp_rc); - if (!rc) - rc = tp.tp_rc; - } else if (!rc) { - splat_vprint(file, SPLAT_THREAD_TEST3_NAME, "%s", - "Thread specific data verified\n"); - } - - return rc; -} - -splat_subsystem_t * -splat_thread_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_THREAD_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_THREAD_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_THREAD; - - splat_test_init(sub, SPLAT_THREAD_TEST1_NAME, SPLAT_THREAD_TEST1_DESC, - SPLAT_THREAD_TEST1_ID, splat_thread_test1); - splat_test_init(sub, SPLAT_THREAD_TEST2_NAME, SPLAT_THREAD_TEST2_DESC, - SPLAT_THREAD_TEST2_ID, splat_thread_test2); - splat_test_init(sub, SPLAT_THREAD_TEST3_NAME, SPLAT_THREAD_TEST3_DESC, - SPLAT_THREAD_TEST3_ID, splat_thread_test3); - - return sub; -} - -void -splat_thread_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - splat_test_fini(sub, SPLAT_THREAD_TEST3_ID); - splat_test_fini(sub, SPLAT_THREAD_TEST2_ID); - splat_test_fini(sub, SPLAT_THREAD_TEST1_ID); - - kfree(sub); -} - -int -splat_thread_id(void) { - return SPLAT_SUBSYSTEM_THREAD; -} diff --git a/module/splat/splat-time.c b/module/splat/splat-time.c deleted file mode 100644 index a0e261956..000000000 --- a/module/splat/splat-time.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Time Tests. - */ - -#include -#include -#include -#include "splat-internal.h" - -#define SPLAT_TIME_NAME "time" -#define SPLAT_TIME_DESC "Kernel Time Tests" - -#define SPLAT_TIME_TEST1_ID 0x0801 -#define SPLAT_TIME_TEST1_NAME "time1" -#define SPLAT_TIME_TEST1_DESC "HZ Test" - -#define SPLAT_TIME_TEST2_ID 0x0802 -#define SPLAT_TIME_TEST2_NAME "time2" -#define SPLAT_TIME_TEST2_DESC "Monotonic Test" - -static int -splat_time_test1(struct file *file, void *arg) -{ - int myhz = hz; - splat_vprint(file, SPLAT_TIME_TEST1_NAME, "hz is %d\n", myhz); - return 0; -} - -static int -splat_time_test2(struct file *file, void *arg) -{ - hrtime_t tm1, tm2; - int i; - - tm1 = gethrtime(); - splat_vprint(file, SPLAT_TIME_TEST2_NAME, "time is %lld\n", tm1); - - for(i = 0; i < 100; i++) { - tm2 = gethrtime(); - splat_vprint(file, SPLAT_TIME_TEST2_NAME, "time is %lld\n", tm2); - - if(tm1 > tm2) { - splat_print(file, "%s: gethrtime() is not giving " - "monotonically increasing values\n", - SPLAT_TIME_TEST2_NAME); - return 1; - } - tm1 = tm2; - - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(10); - } - - return 0; -} - -splat_subsystem_t * -splat_time_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_TIME_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_TIME_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_TIME; - - splat_test_init(sub, SPLAT_TIME_TEST1_NAME, SPLAT_TIME_TEST1_DESC, - SPLAT_TIME_TEST1_ID, splat_time_test1); - splat_test_init(sub, SPLAT_TIME_TEST2_NAME, SPLAT_TIME_TEST2_DESC, - SPLAT_TIME_TEST2_ID, splat_time_test2); - - return sub; -} - -void -splat_time_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - - splat_test_fini(sub, SPLAT_TIME_TEST2_ID); - splat_test_fini(sub, SPLAT_TIME_TEST1_ID); - - kfree(sub); -} - -int -splat_time_id(void) -{ - return SPLAT_SUBSYSTEM_TIME; -} diff --git a/module/splat/splat-vnode.c b/module/splat/splat-vnode.c deleted file mode 100644 index 4ccf24f1e..000000000 --- a/module/splat/splat-vnode.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Vnode Tests. - */ - -#include -#include "splat-internal.h" - -#define SPLAT_VNODE_NAME "vnode" -#define SPLAT_VNODE_DESC "Kernel Vnode Tests" - -#define SPLAT_VNODE_TEST1_ID 0x0901 -#define SPLAT_VNODE_TEST1_NAME "vn_open" -#define SPLAT_VNODE_TEST1_DESC "Vn_open Test" - -#define SPLAT_VNODE_TEST2_ID 0x0902 -#define SPLAT_VNODE_TEST2_NAME "vn_openat" -#define SPLAT_VNODE_TEST2_DESC "Vn_openat Test" - -#define SPLAT_VNODE_TEST3_ID 0x0903 -#define SPLAT_VNODE_TEST3_NAME "vn_rdwr" -#define SPLAT_VNODE_TEST3_DESC "Vn_rdwrt Test" - -#define SPLAT_VNODE_TEST5_ID 0x0905 -#define SPLAT_VNODE_TEST5_NAME "vn_getattr" -#define SPLAT_VNODE_TEST5_DESC "Vn_getattr Test" - -#define SPLAT_VNODE_TEST6_ID 0x0906 -#define SPLAT_VNODE_TEST6_NAME "vn_sync" -#define SPLAT_VNODE_TEST6_DESC "Vn_sync Test" - -#define SPLAT_VNODE_TEST_FILE "/etc/fstab" -#define SPLAT_VNODE_TEST_FILE_AT "etc/fstab" -#define SPLAT_VNODE_TEST_FILE_RW "/tmp/spl.vnode.tmp" -#define SPLAT_VNODE_TEST_FILE_RW1 "/tmp/spl.vnode.tmp.1" -#define SPLAT_VNODE_TEST_FILE_RW2 "/tmp/spl.vnode.tmp.2" - -static int -splat_vnode_user_cmd(struct file *file, void *arg, - char *name, char *cmd) -{ - char sh_path[] = "/bin/sh"; - char *argv[] = { sh_path, - "-c", - cmd, - NULL }; - char *envp[] = { "HOME=/", - "TERM=linux", - "PATH=/sbin:/usr/sbin:/bin:/usr/bin", - NULL }; - int rc; - - rc = call_usermodehelper(sh_path, argv, envp, UMH_WAIT_PROC); - if (rc) { - splat_vprint(file, name, - "Failed command: %s %s %s (%d)\n", - argv[0], argv[1], cmd, rc); - return -EPERM; - } - - return 0; -} - -static int -splat_vnode_unlink_all(struct file *file, void *arg, char *name) -{ - char *cmds[] = { "rm -f " SPLAT_VNODE_TEST_FILE_RW, - "rm -f " SPLAT_VNODE_TEST_FILE_RW1, - "rm -f " SPLAT_VNODE_TEST_FILE_RW2, - NULL }; - int i = 0, rc = 0; - - while (cmds[i] != NULL) { - if ((rc = splat_vnode_user_cmd(file, arg, name, cmds[i]))) - return rc; - - i++; - } - - return rc; -} - -static int -splat_vnode_test1(struct file *file, void *arg) -{ - vnode_t *vp; - int rc; - - if ((rc = vn_open(SPLAT_VNODE_TEST_FILE, UIO_SYSSPACE, - FREAD, 0644, &vp, 0, 0))) { - splat_vprint(file, SPLAT_VNODE_TEST1_NAME, - "Failed to vn_open test file: %s (%d)\n", - SPLAT_VNODE_TEST_FILE, rc); - return -rc; - } - - rc = VOP_CLOSE(vp, 0, 0, 0, 0, 0); - - if (rc) { - splat_vprint(file, SPLAT_VNODE_TEST1_NAME, - "Failed to vn_close test file: %s (%d)\n", - SPLAT_VNODE_TEST_FILE, rc); - return -rc; - } - - splat_vprint(file, SPLAT_VNODE_TEST1_NAME, "Successfully vn_open'ed " - "and vn_closed test file: %s\n", SPLAT_VNODE_TEST_FILE); - - return -rc; -} /* splat_vnode_test1() */ - -static int -splat_vnode_test2(struct file *file, void *arg) -{ - vnode_t *vp; - int rc; - - if ((rc = vn_openat(SPLAT_VNODE_TEST_FILE_AT, UIO_SYSSPACE, - FREAD, 0644, &vp, 0, 0, rootdir, 0))) { - splat_vprint(file, SPLAT_VNODE_TEST2_NAME, - "Failed to vn_openat test file: %s (%d)\n", - SPLAT_VNODE_TEST_FILE, rc); - return -rc; - } - - rc = VOP_CLOSE(vp, 0, 0, 0, 0, 0); - - if (rc) { - splat_vprint(file, SPLAT_VNODE_TEST2_NAME, - "Failed to vn_close test file: %s (%d)\n", - SPLAT_VNODE_TEST_FILE, rc); - return -rc; - } - - splat_vprint(file, SPLAT_VNODE_TEST2_NAME, "Successfully vn_openat'ed " - "and vn_closed test file: %s\n", SPLAT_VNODE_TEST_FILE); - - return -rc; -} /* splat_vnode_test2() */ - -static int -splat_vnode_test3(struct file *file, void *arg) -{ - vnode_t *vp; - char buf1[32] = "SPL VNode Interface Test File\n"; - char buf2[32] = ""; - int rc; - - if ((rc = splat_vnode_unlink_all(file, arg, SPLAT_VNODE_TEST3_NAME))) - return rc; - - if ((rc = vn_open(SPLAT_VNODE_TEST_FILE_RW, UIO_SYSSPACE, - FWRITE | FREAD | FCREAT | FEXCL, - 0644, &vp, 0, 0))) { - splat_vprint(file, SPLAT_VNODE_TEST3_NAME, - "Failed to vn_open test file: %s (%d)\n", - SPLAT_VNODE_TEST_FILE_RW, rc); - return -rc; - } - - rc = vn_rdwr(UIO_WRITE, vp, buf1, strlen(buf1), 0, - UIO_SYSSPACE, 0, RLIM64_INFINITY, 0, NULL); - if (rc) { - splat_vprint(file, SPLAT_VNODE_TEST3_NAME, - "Failed vn_rdwr write of test file: %s (%d)\n", - SPLAT_VNODE_TEST_FILE_RW, rc); - goto out; - } - - rc = vn_rdwr(UIO_READ, vp, buf2, strlen(buf1), 0, - UIO_SYSSPACE, 0, RLIM64_INFINITY, 0, NULL); - if (rc) { - splat_vprint(file, SPLAT_VNODE_TEST3_NAME, - "Failed vn_rdwr read of test file: %s (%d)\n", - SPLAT_VNODE_TEST_FILE_RW, rc); - goto out; - } - - if (strncmp(buf1, buf2, strlen(buf1))) { - rc = EINVAL; - splat_vprint(file, SPLAT_VNODE_TEST3_NAME, - "Failed strncmp data written does not match " - "data read\nWrote: %sRead: %s\n", buf1, buf2); - goto out; - } - - rc = 0; - splat_vprint(file, SPLAT_VNODE_TEST3_NAME, "Wrote: %s", buf1); - splat_vprint(file, SPLAT_VNODE_TEST3_NAME, "Read: %s", buf2); - splat_vprint(file, SPLAT_VNODE_TEST3_NAME, "Successfully wrote and " - "read expected data pattern to test file: %s\n", - SPLAT_VNODE_TEST_FILE_RW); - -out: - VOP_CLOSE(vp, 0, 0, 0, 0, 0); - - return -rc; -} /* splat_vnode_test3() */ - -static int -splat_vnode_test5(struct file *file, void *arg) -{ - vnode_t *vp; - vattr_t vap; - int rc; - - if ((rc = vn_open(SPLAT_VNODE_TEST_FILE, UIO_SYSSPACE, - FREAD, 0644, &vp, 0, 0))) { - splat_vprint(file, SPLAT_VNODE_TEST5_NAME, - "Failed to vn_open test file: %s (%d)\n", - SPLAT_VNODE_TEST_FILE, rc); - return -rc; - } - - rc = VOP_GETATTR(vp, &vap, 0, 0, NULL); - if (rc) { - splat_vprint(file, SPLAT_VNODE_TEST5_NAME, - "Failed to vn_getattr test file: %s (%d)\n", - SPLAT_VNODE_TEST_FILE, rc); - goto out; - } - - if (vap.va_type != VREG) { - rc = EINVAL; - splat_vprint(file, SPLAT_VNODE_TEST5_NAME, - "Failed expected regular file type " - "(%d != VREG): %s (%d)\n", vap.va_type, - SPLAT_VNODE_TEST_FILE, rc); - goto out; - } - - splat_vprint(file, SPLAT_VNODE_TEST1_NAME, "Successfully " - "vn_getattr'ed test file: %s\n", SPLAT_VNODE_TEST_FILE); - -out: - VOP_CLOSE(vp, 0, 0, 0, 0, 0); - - return -rc; -} /* splat_vnode_test5() */ - -static int -splat_vnode_test6(struct file *file, void *arg) -{ - vnode_t *vp; - char buf[32] = "SPL VNode Interface Test File\n"; - int rc; - - if ((rc = splat_vnode_unlink_all(file, arg, SPLAT_VNODE_TEST6_NAME))) - return rc; - - if ((rc = vn_open(SPLAT_VNODE_TEST_FILE_RW, UIO_SYSSPACE, - FWRITE | FCREAT | FEXCL, 0644, &vp, 0, 0))) { - splat_vprint(file, SPLAT_VNODE_TEST6_NAME, - "Failed to vn_open test file: %s (%d)\n", - SPLAT_VNODE_TEST_FILE_RW, rc); - return -rc; - } - - rc = vn_rdwr(UIO_WRITE, vp, buf, strlen(buf), 0, - UIO_SYSSPACE, 0, RLIM64_INFINITY, 0, NULL); - if (rc) { - splat_vprint(file, SPLAT_VNODE_TEST6_NAME, - "Failed vn_rdwr write of test file: %s (%d)\n", - SPLAT_VNODE_TEST_FILE_RW, rc); - goto out; - } - - rc = vn_fsync(vp, 0, 0, 0); - if (rc) { - splat_vprint(file, SPLAT_VNODE_TEST6_NAME, - "Failed vn_fsync of test file: %s (%d)\n", - SPLAT_VNODE_TEST_FILE_RW, rc); - goto out; - } - - rc = 0; - splat_vprint(file, SPLAT_VNODE_TEST6_NAME, "Successfully " - "fsync'ed test file %s\n", SPLAT_VNODE_TEST_FILE_RW); -out: - VOP_CLOSE(vp, 0, 0, 0, 0, 0); - - return -rc; -} /* splat_vnode_test6() */ - -splat_subsystem_t * -splat_vnode_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_VNODE_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_VNODE_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_VNODE; - - splat_test_init(sub, SPLAT_VNODE_TEST1_NAME, SPLAT_VNODE_TEST1_DESC, - SPLAT_VNODE_TEST1_ID, splat_vnode_test1); - splat_test_init(sub, SPLAT_VNODE_TEST2_NAME, SPLAT_VNODE_TEST2_DESC, - SPLAT_VNODE_TEST2_ID, splat_vnode_test2); - splat_test_init(sub, SPLAT_VNODE_TEST3_NAME, SPLAT_VNODE_TEST3_DESC, - SPLAT_VNODE_TEST3_ID, splat_vnode_test3); - splat_test_init(sub, SPLAT_VNODE_TEST5_NAME, SPLAT_VNODE_TEST5_DESC, - SPLAT_VNODE_TEST5_ID, splat_vnode_test5); - splat_test_init(sub, SPLAT_VNODE_TEST6_NAME, SPLAT_VNODE_TEST6_DESC, - SPLAT_VNODE_TEST6_ID, splat_vnode_test6); - - return sub; -} /* splat_vnode_init() */ - -void -splat_vnode_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - - splat_test_fini(sub, SPLAT_VNODE_TEST6_ID); - splat_test_fini(sub, SPLAT_VNODE_TEST5_ID); - splat_test_fini(sub, SPLAT_VNODE_TEST3_ID); - splat_test_fini(sub, SPLAT_VNODE_TEST2_ID); - splat_test_fini(sub, SPLAT_VNODE_TEST1_ID); - - kfree(sub); -} /* splat_vnode_fini() */ - -int -splat_vnode_id(void) -{ - return SPLAT_SUBSYSTEM_VNODE; -} /* splat_vnode_id() */ diff --git a/module/splat/splat-zlib.c b/module/splat/splat-zlib.c deleted file mode 100644 index 28e521c82..000000000 --- a/module/splat/splat-zlib.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. - * Copyright (C) 2007 The Regents of the University of California. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Brian Behlendorf . - * UCRL-CODE-235197 - * - * This file is part of the SPL, Solaris Porting Layer. - * For details, see . - * - * The SPL is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * The SPL is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with the SPL. If not, see . - ***************************************************************************** - * Solaris Porting LAyer Tests (SPLAT) Zlib Compression Tests. - */ - -#include -#include -#include -#include -#include "splat-internal.h" - -#define SPLAT_ZLIB_NAME "zlib" -#define SPLAT_ZLIB_DESC "Zlib Compression Tests" - -#define SPLAT_ZLIB_TEST1_ID 0x0f01 -#define SPLAT_ZLIB_TEST1_NAME "compress/uncompress" -#define SPLAT_ZLIB_TEST1_DESC "Compress/Uncompress Test" - -#define BUFFER_SIZE (128 * 1024) - -static int -splat_zlib_test1_check(struct file *file, void *src, void *dst, void *chk, - int level) -{ - size_t dst_len = BUFFER_SIZE; - size_t chk_len = BUFFER_SIZE; - int rc; - - memset(dst, 0, BUFFER_SIZE); - memset(chk, 0, BUFFER_SIZE); - - rc = z_compress_level(dst, &dst_len, src, BUFFER_SIZE, level); - if (rc != Z_OK) { - splat_vprint(file, SPLAT_ZLIB_TEST1_NAME, - "Failed level %d z_compress_level(), %d\n", level, rc); - return -EINVAL; - } - - rc = z_uncompress(chk, &chk_len, dst, dst_len); - if (rc != Z_OK) { - splat_vprint(file, SPLAT_ZLIB_TEST1_NAME, - "Failed level %d z_uncompress(), %d\n", level, rc); - return -EINVAL; - } - - rc = memcmp(src, chk, BUFFER_SIZE); - if (rc) { - splat_vprint(file, SPLAT_ZLIB_TEST1_NAME, - "Failed level %d memcmp()), %d\n", level, rc); - return -EINVAL; - } - - splat_vprint(file, SPLAT_ZLIB_TEST1_NAME, - "Passed level %d, compressed %d bytes to %d bytes\n", - level, BUFFER_SIZE, (int)dst_len); - - return 0; -} - -/* - * Compress a buffer, uncompress the newly compressed buffer, then - * compare it to the original. Do this for all 9 compression levels. - */ -static int -splat_zlib_test1(struct file *file, void *arg) -{ - void *src = NULL, *dst = NULL, *chk = NULL; - int i, rc, level; - - src = vmalloc(BUFFER_SIZE); - if (src == NULL) { - rc = -ENOMEM; - goto out; - } - - dst = vmalloc(BUFFER_SIZE); - if (dst == NULL) { - rc = -ENOMEM; - goto out; - } - - chk = vmalloc(BUFFER_SIZE); - if (chk == NULL) { - rc = -ENOMEM; - goto out; - } - - /* Source buffer is a repeating 1024 byte random pattern. */ - random_get_pseudo_bytes(src, sizeof(uint8_t) * 1024); - for (i = 1; i < 128; i++) - memcpy(src + (i * 1024), src, 1024); - - for (level = 1; level <= 9; level++) - if ((rc = splat_zlib_test1_check(file, src, dst, chk, level))) - break; -out: - if (src) - vfree(src); - - if (dst) - vfree(dst); - - if (chk) - vfree(chk); - - return rc; -} - -splat_subsystem_t * -splat_zlib_init(void) -{ - splat_subsystem_t *sub; - - sub = kmalloc(sizeof(*sub), GFP_KERNEL); - if (sub == NULL) - return NULL; - - memset(sub, 0, sizeof(*sub)); - strncpy(sub->desc.name, SPLAT_ZLIB_NAME, SPLAT_NAME_SIZE); - strncpy(sub->desc.desc, SPLAT_ZLIB_DESC, SPLAT_DESC_SIZE); - INIT_LIST_HEAD(&sub->subsystem_list); - INIT_LIST_HEAD(&sub->test_list); - spin_lock_init(&sub->test_lock); - sub->desc.id = SPLAT_SUBSYSTEM_ZLIB; - - splat_test_init(sub, SPLAT_ZLIB_TEST1_NAME, SPLAT_ZLIB_TEST1_DESC, - SPLAT_ZLIB_TEST1_ID, splat_zlib_test1); - - return sub; -} - -void -splat_zlib_fini(splat_subsystem_t *sub) -{ - ASSERT(sub); - - splat_test_fini(sub, SPLAT_ZLIB_TEST1_ID); - - kfree(sub); -} - -int -splat_zlib_id(void) { - return SPLAT_SUBSYSTEM_ZLIB; -} diff --git a/rpm/Makefile.am b/rpm/Makefile.am deleted file mode 100644 index f2cf72cef..000000000 --- a/rpm/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = generic redhat diff --git a/rpm/generic/.gitignore b/rpm/generic/.gitignore deleted file mode 100644 index 67129ff14..000000000 --- a/rpm/generic/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/spl-dkms.spec -/spl-kmod.spec -/spl.spec diff --git a/rpm/generic/Makefile.am b/rpm/generic/Makefile.am deleted file mode 100644 index da6c4abe2..000000000 --- a/rpm/generic/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST = spl.spec.in spl-kmod.spec.in spl-dkms.spec.in diff --git a/rpm/generic/spl-dkms.spec.in b/rpm/generic/spl-dkms.spec.in deleted file mode 100644 index a8691d229..000000000 --- a/rpm/generic/spl-dkms.spec.in +++ /dev/null @@ -1,94 +0,0 @@ -%{?!packager: %define packager Brian Behlendorf } - -%if ! 0%{?rhel}%{?fedora}%{?mageia}%{?suse_version} -%define not_rpm 1 -%endif - -%define module @PACKAGE@ -%define mkconf scripts/dkms.mkconf - -# Python permits the !/usr/bin/python shebang for scripts that are cross -# compatible between python2 and python3, but Fedora 28 does not. Fedora -# wants us to choose python3 for cross-compatible scripts. Since we want -# to support python2 and python3 users, exclude our scripts from Fedora 28's -# RPM build check, so that we don't get a bunch of build warnings. -# -# Details: https://github.com/zfsonlinux/zfs/issues/7360 -# -%global __brp_mangle_shebangs_exclude_from splslab.py - -Name: %{module}-dkms - -Version: @VERSION@ -Release: @RELEASE@%{?dist} -Summary: Kernel module(s) (dkms) - -Group: System Environment/Kernel -License: GPLv2+ -URL: http://zfsonlinux.org/ -Source0: %{module}-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildArch: noarch - -Requires: dkms >= 2.2.0.2 -Requires: gcc, make, perl -%if 0%{?rhel}%{?fedora}%{?mageia}%{?suse_version} -Requires: kernel-devel -%endif -Provides: %{module}-kmod = %{version} - -%description -This package contains the dkms kernel modules required to emulate -several interfaces provided by the Solaris kernel. - -%prep -%setup -q -n %{module}-%{version} - -%build -%{mkconf} -n %{module} -v %{version} -f dkms.conf - -%install -if [ "$RPM_BUILD_ROOT" != "/" ]; then - rm -rf $RPM_BUILD_ROOT -fi -mkdir -p $RPM_BUILD_ROOT/usr/src/ -cp -rf ${RPM_BUILD_DIR}/%{module}-%{version} $RPM_BUILD_ROOT/usr/src/ - -%clean -if [ "$RPM_BUILD_ROOT" != "/" ]; then - rm -rf $RPM_BUILD_ROOT -fi - -%files -%defattr(-,root,root) -/usr/src/%{module}-%{version} - -%post -for POSTINST in /usr/lib/dkms/common.postinst; do - if [ -f $POSTINST ]; then - $POSTINST %{module} %{version} - exit $? - fi - echo "WARNING: $POSTINST does not exist." -done -echo -e "ERROR: DKMS version is too old and %{module} was not" -echo -e "built with legacy DKMS support." -echo -e "You must either rebuild %{module} with legacy postinst" -echo -e "support or upgrade DKMS to a more current version." -exit 1 - -%preun -CONFIG_H="/var/lib/dkms/%{module}/%{version}/*/*/%{module}_config.h" -SPEC_META_ALIAS="@PACKAGE@-@VERSION@-@RELEASE@" -DKMS_META_ALIAS=`cat $CONFIG_H 2>/dev/null | - awk -F'"' '/META_ALIAS/ { print $2; exit 0 }'` -if [ "$SPEC_META_ALIAS" = "$DKMS_META_ALIAS" ]; then - echo -e - echo -e "Uninstall of %{module} module ($SPEC_META_ALIAS) beginning:" - dkms remove -m %{module} -v %{version} --all %{!?not_rpm:--rpm_safe_upgrade} -fi -exit 0 - -%changelog -* %(date "+%a %b %d %Y") %packager %{version}-%{release} -- Automatic build by DKMS diff --git a/rpm/generic/spl-kmod.spec.in b/rpm/generic/spl-kmod.spec.in deleted file mode 100644 index c33c25069..000000000 --- a/rpm/generic/spl-kmod.spec.in +++ /dev/null @@ -1,172 +0,0 @@ -%define module @PACKAGE@ -#define repo rpmfusion -#define repo chaos - -# (un)define the next line to either build for the newest or all current kernels -%define buildforkernels newest -#define buildforkernels current -#define buildforkernels akmod - -%bcond_with debug -%bcond_with debug_log -%bcond_with debug_kmem -%bcond_with debug_kmem_tracking -%bcond_with atomic_spinlocks - - -Name: %{module}-kmod - -Version: @VERSION@ -Release: @RELEASE@%{?dist} -Summary: Kernel module(s) - -Group: System Environment/Kernel -License: GPLv2+ -URL: http://zfsonlinux.org/ -Source0: %{module}-%{version}.tar.gz -Source10: kmodtool -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id} -u -n) - -# The developments headers will conflict with the dkms packages. -Conflicts: %{module}-dkms - -%if %{defined repo} - -# Building for a repository use the proper build-sysbuild package -# to determine which kernel-devel packages should be installed. -BuildRequires: %{_bindir}/kmodtool -%{!?kernels:BuildRequires: buildsys-build-%{repo}-kerneldevpkgs-%{?buildforkernels:%{buildforkernels}}%{!?buildforkernels:current}-%{_target_cpu}} - -%else - -# Building local packages attempt to to use the installed kernel. -%{?rhel:BuildRequires: kernel-devel} -%{?fedora:BuildRequires: kernel-devel} -%{?suse_version:BuildRequires: kernel-source} - -%if !%{defined kernels} && !%{defined build_src_rpm} - %if 0%{?rhel}%{?fedora}%{?suse_version} - %define kernels %(ls -1 /usr/src/kernels) - %else - %define kernels %(ls -1 /lib/modules) - %endif -%endif -%endif - -# LDFLAGS are not sanitized by arch/*/Makefile for these architectures. -%ifarch ppc ppc64 ppc64le aarch64 -%global __global_ldflags %{nil} -%endif - -%if 0%{?fedora} >= 17 -%define prefix /usr -%endif - -# Kmodtool does its magic here. A patched version of kmodtool is shipped -# because the latest versions may not be available for your distribution. -# https://bugzilla.rpmfusion.org/show_bug.cgi?id=2714 -%{expand:%(bash %{SOURCE10} --target %{_target_cpu} %{?repo:--repo %{?repo}} --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} --devel %{?prefix:--prefix "%{?prefix}"} %{?kernels:--for-kernels "%{?kernels}"} %{?kernelbuildroot:--buildroot "%{?kernelbuildroot}"} 2>/dev/null) } - - -%description -This package contains the kernel modules required to emulate -several interfaces provided by the Solaris kernel. - -%prep -# Error out if there was something wrong with kmodtool. -%{?kmodtool_check} - -# Print kmodtool output for debugging purposes: -bash %{SOURCE10} --target %{_target_cpu} %{?repo:--repo %{?repo}} --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} --devel %{?prefix:--prefix "%{?prefix}"} %{?kernels:--for-kernels "%{?kernels}"} %{?kernelbuildroot:--buildroot "%{?kernelbuildroot}"} 2>/dev/null - -%if %{with debug} - %define debug --enable-debug -%else - %define debug --disable-debug -%endif - -%if %{with debug_log} - %define debug_log --enable-debug-log -%else - %define debug_log --disable-debug-log -%endif - -%if %{with debug_kmem} - %define debug_kmem --enable-debug-kmem -%else - %define debug_kmem --disable-debug-kmem -%endif - -%if %{with debug_kmem_tracking} - %define debug_kmem_tracking --enable-debug-kmem-tracking -%else - %define debug_kmem_tracking --disable-debug-kmem-tracking -%endif - -%if %{with atomic_spinlocks} - %define atomic_spinlocks --enable-atomic-spinlocks -%else - %define atomic_spinlocks --disable-atomic-spinlocks -%endif - -# Leverage VPATH from configure to avoid making multiple copies. -%define _configure ../%{module}-%{version}/configure - -%setup -q -c -T -a 0 - -for kernel_version in %{?kernel_versions}; do - %{__mkdir} _kmod_build_${kernel_version%%___*} -done - -%build -for kernel_version in %{?kernel_versions}; do - cd _kmod_build_${kernel_version%%___*} - %configure \ - --with-config=kernel \ -%if 0%{?rhel}%{?fedora} - --with-linux="${kernel_version##*___}" \ - --with-linux-obj="${kernel_version##*___}" \ -%else - --with-linux="$( \ - if [ -e "/lib/modules/${kernel_version%%___*}/source" ]; then \ - echo "/lib/modules/${kernel_version%%___*}/source"; \ - else \ - echo "/lib/modules/${kernel_version%%___*}/build"; \ - fi)" \ - --with-linux-obj="/lib/modules/${kernel_version%%___*}/build" \ -%endif - %{debug} \ - %{debug_log} \ - %{debug_kmem} \ - %{debug_kmem_tracking} \ - %{atomic_spinlocks} - make %{?_smp_mflags} - cd .. -done - - -%install -rm -rf ${RPM_BUILD_ROOT} - -# Relies on the kernel 'modules_install' make target. -for kernel_version in %{?kernel_versions}; do - cd _kmod_build_${kernel_version%%___*} - make install \ - DESTDIR=${RPM_BUILD_ROOT} \ - %{?prefix:INSTALL_MOD_PATH=%{?prefix}} \ - INSTALL_MOD_DIR=%{kmodinstdir_postfix} - cd .. -done - -# find-debuginfo.sh only considers executables -chmod u+x ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/*/extra/*/*/* -%{?akmod_install} - - -%clean -rm -rf $RPM_BUILD_ROOT - -%changelog -* Wed Jul 26 2017 Brian Behlendorf - 0.7.0-1 -- Released 0.7.0-1, detailed release notes are available at: -- https://github.com/zfsonlinux/zfs/releases/tag/zfs-0.7.0 diff --git a/rpm/generic/spl.spec.in b/rpm/generic/spl.spec.in deleted file mode 100644 index 7ba71fd58..000000000 --- a/rpm/generic/spl.spec.in +++ /dev/null @@ -1,49 +0,0 @@ -# Python permits the !/usr/bin/python shebang for scripts that are cross -# compatible between python2 and python3, but Fedora 28 does not. Fedora -# wants us to choose python3 for cross-compatible scripts. Since we want -# to support python2 and python3 users, exclude our scripts from Fedora 28's -# RPM build check, so that we don't get a bunch of build warnings. -# -# Details: https://github.com/zfsonlinux/zfs/issues/7360 -# -%global __brp_mangle_shebangs_exclude_from splslab.py - -Name: @PACKAGE@ -Version: @VERSION@ -Release: @RELEASE@%{?dist} -Summary: Commands to control the kernel modules - -Group: System Environment/Kernel -License: GPLv2+ -URL: http://zfsonlinux.org/ -Source0: %{name}-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -Requires: %{name}-kmod = %{version} -Provides: %{name}-kmod-common = %{version} - -%description -This package contains the commands to verify the SPL -kernel modules are functioning properly. - -%prep -%setup -q - -%build -%configure --with-config=user -make %{?_smp_mflags} - -%install -%{__rm} -rf $RPM_BUILD_ROOT -make install DESTDIR=%{?buildroot} - -%files -%doc AUTHORS COPYING DISCLAIMER -%{_bindir}/* -%{_sbindir}/* -%{_mandir}/man1/* -%{_mandir}/man5/* - -%changelog -* Wed Jul 26 2017 Brian Behlendorf - 0.7.0-1 -- Released 0.7.0-1, detailed release notes are available at: -- https://github.com/zfsonlinux/zfs/releases/tag/zfs-0.7.0 diff --git a/rpm/redhat/.gitignore b/rpm/redhat/.gitignore deleted file mode 100644 index 67129ff14..000000000 --- a/rpm/redhat/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/spl-dkms.spec -/spl-kmod.spec -/spl.spec diff --git a/rpm/redhat/Makefile.am b/rpm/redhat/Makefile.am deleted file mode 100644 index da6c4abe2..000000000 --- a/rpm/redhat/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST = spl.spec.in spl-kmod.spec.in spl-dkms.spec.in diff --git a/rpm/redhat/spl-dkms.spec.in b/rpm/redhat/spl-dkms.spec.in deleted file mode 120000 index 900f524aa..000000000 --- a/rpm/redhat/spl-dkms.spec.in +++ /dev/null @@ -1 +0,0 @@ -../generic/spl-dkms.spec.in \ No newline at end of file diff --git a/rpm/redhat/spl-kmod.spec.in b/rpm/redhat/spl-kmod.spec.in deleted file mode 100644 index 4e2a9f955..000000000 --- a/rpm/redhat/spl-kmod.spec.in +++ /dev/null @@ -1,110 +0,0 @@ -%bcond_with debug -%bcond_with debug_log -%bcond_with debug_kmem -%bcond_with debug_kmem_tracking -%bcond_with atomic_spinlocks - -Name: @PACKAGE@-kmod -Version: @VERSION@ -Release: @RELEASE@%{?dist} - -Summary: Kernel module(s) -Group: System Environment/Kernel -License: GPLv2+ -URL: http://zfsonlinux.org/ -BuildRequires: %kernel_module_package_buildreqs -Source0: @PACKAGE@-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) - -# Additional dependency information for the kmod sub-package must be specified -# by generating a preamble text file which kmodtool can append to the spec file. -%(/bin/echo -e "\ -Requires: @PACKAGE@ = %{version}\n\ -Conflicts: @PACKAGE@-dkms\n\n" > %{_sourcedir}/kmod-preamble) - -# LDFLAGS are not sanitized by arch/*/Makefile for these architectures. -%ifarch ppc ppc64 ppc64le aarch64 -%global __global_ldflags %{nil} -%endif - -%description -This package contains the kernel modules required to emulate -several interfaces provided by the Solaris kernel. - -%define kmod_name spl - -%kernel_module_package -n %{kmod_name} -p %{_sourcedir}/kmod-preamble - -%define ksrc %{_usrsrc}/kernels/%{kverrel} -%define kobj %{ksrc} - -%package -n kmod-%{kmod_name}-devel -Summary: SPL kernel module(s) devel common -Group: System Environment/Kernel - -%description -n kmod-%{kmod_name}-devel -This package provides the header files and objects to build kernel modules -which depend on the SPL kernel module. - -%prep -if ! [ -d "%{ksrc}" ]; then - echo "Kernel build directory isn't set properly, cannot continue" - exit 1 -fi - -%if %{with debug} -%define debug --enable-debug -%else -%define debug --disable-debug -%endif - -%if %{with debug_log} -%define debug_log --enable-debug-log -%else -%define debug_log --disable-debug-log -%endif - -%if %{with debug_kmem} -%define debug_kmem --enable-debug-kmem -%else -%define debug_kmem --disable-debug-kmem -%endif - -%if %{with debug_kmem_tracking} -%define debug_kmem_tracking --enable-debug-kmem-tracking -%else -%define debug_kmem_tracking --disable-debug-kmem-tracking -%endif - -%if %{with atomic_spinlocks} -%define atomic_spinlocks --enable-atomic-spinlocks -%else -%define atomic_spinlocks --disable-atomic-spinlocks -%endif - -%setup -n %{kmod_name}-%{version} -%build -%configure \ - --with-config=kernel \ - --with-linux=%{ksrc} \ - --with-linux-obj=%{kobj} \ - %{debug} \ - %{debug_log} \ - %{debug_kmem} \ - %{debug_kmem_tracking} \ - %{atomic_spinlocks} -make %{?_smp_mflags} - -%install -make install \ - DESTDIR=${RPM_BUILD_ROOT} \ - INSTALL_MOD_DIR=extra/%{kmod_name} -%{__rm} -f %{buildroot}/lib/modules/%{kverrel}/modules.* -# find-debuginfo.sh only considers executables -%{__chmod} u+x %{buildroot}/lib/modules/%{kverrel}/extra/*/*/* - -%clean -rm -rf $RPM_BUILD_ROOT - -%files -n kmod-%{kmod_name}-devel -%{_usrsrc}/%{kmod_name}-%{version} diff --git a/rpm/redhat/spl.spec.in b/rpm/redhat/spl.spec.in deleted file mode 120000 index d3276f013..000000000 --- a/rpm/redhat/spl.spec.in +++ /dev/null @@ -1 +0,0 @@ -../generic/spl.spec.in \ No newline at end of file diff --git a/scripts/Makefile.am b/scripts/Makefile.am deleted file mode 100644 index a718c4b1a..000000000 --- a/scripts/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -EXTRA_DIST = check.sh dkms.mkconf dkms.postbuild kmodtool - -check: - scripts/check.sh diff --git a/scripts/check.sh b/scripts/check.sh deleted file mode 100755 index 5f5cb18e2..000000000 --- a/scripts/check.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -############################################################################### -# Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. -# Copyright (C) 2007 The Regents of the University of California. -# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). -# Written by Brian Behlendorf . -# UCRL-CODE-235197 -# -# This file is part of the SPL, Solaris Porting Layer. -# For details, see . -# -# The SPL is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# The SPL is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License along -# with the SPL. If not, see . -############################################################################### -# This script runs the full set of regression tests. -############################################################################### - -prog=check.sh -spl_module=../module/spl/spl.ko -splat_module=../module/splat/splat.ko -splat_cmd=../cmd/splat/splat -verbose= - -die() { - echo "${prog}: $1" >&2 - exit 1 -} - -warn() { - echo "${prog}: $1" >&2 -} - -if [ -n "$V" ]; then - verbose="-v" -fi - -if [ -n "$TESTS" ]; then - tests="$TESTS" -else - tests="-a" -fi - -if [ $(id -u) != 0 ]; then - die "Must run as root" -fi - -if /sbin/lsmod | egrep -q "^spl|^splat"; then - die "Must start with spl modules unloaded" -fi - -if [ ! -f ${spl_module} ] || [ ! -f ${splat_module} ]; then - die "Source tree must be built, run 'make'" -fi - -/sbin/modprobe zlib_inflate &>/dev/null -/sbin/modprobe zlib_deflate &>/dev/null - -echo "Loading ${spl_module}" -/sbin/insmod ${spl_module} || die "Failed to load ${spl_module}" - -echo "Loading ${splat_module}" -/sbin/insmod ${splat_module} || die "Unable to load ${splat_module}" - -# Wait a maximum of 3 seconds for udev to detect the new splatctl -# device, if we do not see the character device file created assume -# udev is not running and manually create the character device. -for i in `seq 1 50`; do - sleep 0.1 - - if [ -c /dev/splatctl ]; then - break - fi - - if [ $i -eq 50 ]; then - mknod /dev/splatctl c 229 0 - fi -done - -$splat_cmd $tests $verbose - -echo "Unloading ${splat_module}" -/sbin/rmmod ${splat_module} || die "Failed to unload ${splat_module}" - -echo "Unloading ${spl_module}" -/sbin/rmmod ${spl_module} || die "Unable to unload ${spl_module}" - -exit 0 diff --git a/scripts/dkms.mkconf b/scripts/dkms.mkconf deleted file mode 100755 index 67b9dad58..000000000 --- a/scripts/dkms.mkconf +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/sh - -PROG=$0 - -pkgcfg=/etc/sysconfig/spl - -while getopts "n:v:c:f:" opt; do - case $opt in - n) pkgname=$OPTARG ;; - v) pkgver=$OPTARG ;; - c) pkgcfg=$OPTARG ;; - f) filename=$OPTARG ;; - esac -done - -if [ -z "${pkgname}" -o -z "${pkgver}" -o -z "${filename}" ]; then - echo "Usage: $PROG -n -v -c -f " - exit 1 -fi - -cat >${filename} < -k -n " \ - "-t -v " - exit 1 -fi - -cp ${tree}/${pkgname}/${pkgver}/build/spl_config.h \ - ${tree}/${pkgname}/${pkgver}/build/module/Module.symvers \ - ${tree}/${pkgname}/${pkgver}/${kver}/${arch}/ diff --git a/scripts/kmodtool b/scripts/kmodtool deleted file mode 100644 index ce3f04294..000000000 --- a/scripts/kmodtool +++ /dev/null @@ -1,592 +0,0 @@ -#!/bin/bash - -# kmodtool - Helper script for building kernel module RPMs -# Copyright (c) 2003-2012 Ville Skyttä , -# Thorsten Leemhuis -# Nicolas Chauvet -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -shopt -s extglob - -myprog="kmodtool-${repo}" -myver="0.12.1" - -kmodname= -build_kernels="current" -kernels_known_variants= -kernel_versions= -kernel_versions_to_build_for= -prefix= -filterfile= -target= -buildroot= - -error_out() -{ - local errorlevel=${1} - shift - echo "Error: $@" >&2 - # the next line is not multi-line safe -- not needed *yet* - echo "%global kmodtool_check echo \"kmodtool error: $@\"; exit ${errorlevel};" - exit ${errorlevel} -} - -print_rpmtemplate_header() -{ - echo - echo '%global kmodinstdir_prefix '${prefix}/lib/modules/ - echo '%global kmodinstdir_postfix '/extra/${kmodname}/ - echo '%global kernel_versions '${kernel_versions} - echo -} - -print_akmodtemplate () -{ - echo - cat <= %{?epoch:%{epoch}:}%{version} -Provides: ${kmodname}-kmod = %{?epoch:%{epoch}:}%{version}-%{release} -EOF - - if [[ ${obsolete_name} ]]; then - echo "Provides: akmod-${obsolete_name} = ${obsolete_version}" - echo "Obsoletes: akmod-${obsolete_name} < ${obsolete_version}" - fi - - cat < /dev/null & - -%files -n akmod-${kmodname} -%defattr(-,root,root,-) -%{_usrsrc}/akmods/* - -EOF -} - -print_akmodmeta () -{ - cat <= %{?epoch:%{epoch}:}%{version} -Requires(post): ${prefix}/sbin/depmod -Requires(postun): ${prefix}/sbin/depmod -EOF - - if [[ ${obsolete_name} ]]; then - echo "Provides: kmod-${obsolete_name}-${kernel_uname_r} = ${obsolete_version}" - echo "Obsoletes: kmod-${obsolete_name}-${kernel_uname_r} < ${obsolete_version}" - fi - - # second part - if [[ ! "${customkernel}" ]]; then - cat < /dev/null || : -%postun -n kmod-${kmodname}-${kernel_uname_r} -${prefix}/sbin/depmod -aF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} &> /dev/null || : - -EOF - else - cat < /dev/null || : -%postun -n kmod-${kmodname}-${kernel_uname_r} -[[ "$(uname -r)" == "${kernel_uname_r}" ]] && ${prefix}/sbin/depmod -a > /dev/null || : - -EOF - fi - - # third part - cat <= %{?epoch:%{epoch}:}%{version}-%{release}" - fi - - if [[ ${obsolete_name} ]]; then - echo "Provides: kmod-${obsolete_name}-devel = ${obsolete_version}" - echo "Obsoletes: kmod-${obsolete_name}-devel < ${obsolete_version}" - fi - - cat < objects for the newest kernel. - -%files -n kmod-${kmodname}-devel -%defattr(644,root,root,755) -%{_usrsrc}/${kmodname}-%{version} -EOF - - for kernel in ${1}; do - local kernel_uname_r=${kernel} - echo "%exclude %{_usrsrc}/${kmodname}-%{version}/${kernel_uname_r}" - done - - echo - echo -} - -print_rpmtemplate_per_kmoddevelpkg () -{ - if [[ "${1}" == "--custom" ]]; then - shift - local customkernel=true - elif [[ "${1}" == "--redhat" ]]; then - # this is needed for akmods - shift - local redhatkernel=true - fi - - local kernel_uname_r=${1} - local kernel_variant="${2:+-${2}}" - - # first part - cat <= %{?epoch:%{epoch}:}%{version}-%{release} -%{?KmodsMetaRequires:Requires: %{?KmodsMetaRequires}} -EOF - - if [[ ${obsolete_name} ]]; then - echo "Provides: kmod-${obsolete_name}${kernel_variant} = ${obsolete_version}" - echo "Obsoletes: kmod-${obsolete_name}${kernel_variant} < ${obsolete_version}" - fi - - cat < -- filter the results with grep --file " - echo " --for-kernels -- created templates only for these kernels" - echo " --kmodname -- name of the kmod (required)" - echo " --devel -- make kmod-devel package" - echo " --noakmod -- no akmod package" - echo " --repo -- use buildsys-build--kerneldevpkgs" - echo " --target -- target-arch (required)" - echo " --buildroot -- Build root (place to look for build files)" -} - -while [ "${1}" ] ; do - case "${1}" in - --filterfile) - shift - if [[ ! "${1}" ]] ; then - error_out 2 "Please provide path to a filter-file together with --filterfile" >&2 - elif [[ ! -e "${1}" ]]; then - error_out 2 "Filterfile ${1} not found" >&2 - fi - filterfile="${1}" - shift - ;; - --kmodname) - shift - if [[ ! "${1}" ]] ; then - error_out 2 "Please provide the name of the kmod together with --kmodname" >&2 - fi - # strip pending -kmod - kmodname="${1%%-kmod}" - shift - ;; - --devel) - shift - devel="true" - ;; - --prefix) - shift - if [[ ! "${1}" ]] ; then - error_out 2 "Please provide a prefix with --prefix" >&2 - fi - prefix="${1}" - shift - ;; - --repo) - shift - if [[ ! "${1}" ]] ; then - error_out 2 "Please provide the name of the repo together with --repo" >&2 - fi - repo=${1} - shift - ;; - --for-kernels) - shift - if [[ ! "${1}" ]] ; then - error_out 2 "Please provide the name of the kmod together with --kmodname" >&2 - fi - for_kernels="${1}" - shift - ;; - --noakmod) - shift - noakmod="true" - ;; - --obsolete-name) - shift - if [[ ! "${1}" ]] ; then - error_out 2 "Please provide the name of the kmod to obsolte together with --obsolete-name" >&2 - fi - obsolete_name="${1}" - shift - ;; - --obsolete-version) - shift - if [[ ! "${1}" ]] ; then - error_out 2 "Please provide the version of the kmod to obsolte together with --obsolete-version" >&2 - fi - obsolete_version="${1}" - shift - ;; - --target) - shift - target="${1}" - shift - ;; - --akmod) - shift - build_kernels="akmod" - ;; - --newest) - shift - build_kernels="newest" - ;; - --current) - shift - build_kernels="current" - ;; - --buildroot) - shift - buildroot="${1}" - shift - ;; - --help) - myprog_help - exit 0 - ;; - --version) - echo "${myprog} ${myver}" - exit 0 - ;; - *) - echo "Error: Unknown option '${1}'." >&2 - usage >&2 - exit 2 - ;; - esac -done - -if [[ -e ./kmodtool-kernel-variants ]]; then - kernels_known_variants="$(cat ./kmodtool-kernel-variants)" -elif [[ -e /usr/share/kmodtool/kernel-variants ]] ; then - kernels_known_variants="$(cat /usr/share/kmodtool/kernel-variants)" -else - kernels_known_variants="@(smp?(-debug)|PAE?(-debug)|debug|kdump|xen|kirkwood|highbank|imx|omap|tegra)" -fi - -# general sanity checks -if [[ ! "${target}" ]]; then - error_out 2 "please pass target arch with --target" -elif [[ ! "${kmodname}" ]]; then - error_out 2 "please pass kmodname with --kmodname" -elif [[ ! "${kernels_known_variants}" ]] ; then - error_out 2 "could not determine known variants" -elif ( [[ "${obsolete_name}" ]] && [[ ! "${obsolete_version}" ]] ) || ( [[ ! "${obsolete_name}" ]] && [[ "${obsolete_version}" ]] ) ; then - error_out 2 "you need to provide both --obsolete-name and --obsolete-version" -fi - -# go -if [[ "${for_kernels}" ]]; then - # this is easy: - print_customrpmtemplate "${for_kernels}" -elif [[ "${build_kernels}" == "akmod" ]]; then - # do only a akmod package - print_akmodtemplate - print_akmodmeta -else - # seems we are on out own to decide for which kernels to build - - # we need more sanity checks in this case - if [[ ! "${repo}" ]]; then - error_out 2 "please provide repo name with --repo" - elif ! $(which buildsys-build-${repo}-kerneldevpkgs &> /dev/null) ; then - error_out 2 "buildsys-build-${repo}-kerneldevpkgs not found" - fi - - # call buildsys-build-${repo}-kerneldevpkgs to get the list of kernels - cmdoptions="--target ${target}" - - # filterfile to filter list of kernels? - if [[ "${filterfile}" ]] ; then - cmdoptions="${cmdoptions} --filterfile ${filterfile}" - fi - - kernel_versions_to_build_for="$(buildsys-build-${repo}-kerneldevpkgs --${build_kernels} ${cmdoptions})" - returncode=$? - if (( ${returncode} != 0 )); then - error_out 2 "buildsys-build-${repo}-kerneldevpkgs failed: $(buildsys-build-${repo}-kerneldevpkgs --${build_kernels} ${cmdoptions})" - fi - - if [[ "${build_kernels}" == "current" ]] && [[ ! "${noakmod}" ]]; then - print_akmodtemplate - fi - - print_rpmtemplate -fi diff --git a/spl.release.in b/spl.release.in deleted file mode 100644 index fd7c84c13..000000000 --- a/spl.release.in +++ /dev/null @@ -1 +0,0 @@ -@SPL_META_VERSION@-@SPL_META_RELEASE@