]> git.proxmox.com Git - mirror_spl.git/log
mirror_spl.git
9 years agoRefactor existing code
Brian Behlendorf [Mon, 8 Dec 2014 18:04:42 +0000 (13:04 -0500)]
Refactor existing code

This change introduces no functional changes to the memory management
interfaces.  It only restructures the existing codes by separating the
kmem, vmem, and kmem cache implementations in the separate source and
header files.

Splitting this functionality in to separate files required the addition
of spl_vmem_{init,fini}() and spl_kmem_cache_{initi,fini}() functions.

Additionally, several minor changes to the #include's were required to
accommodate the removal of extraneous header from kmem.h.

But again, while large this patch introduces no functional changes.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRevert "Add PF_NOFS debugging flag"
Richard Yao [Thu, 17 Apr 2014 14:59:00 +0000 (10:59 -0400)]
Revert "Add PF_NOFS debugging flag"

This reverts commit eb0f407a2b9089113ef6f2402ebd887511315b43 in
preperation for updating the kmem/vmem infrastructure to use the
PF_FSTRANS flag.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoUse current_kernel_time() in the time compatibility wrappers
Tim Chase [Sun, 11 Jan 2015 16:37:43 +0000 (10:37 -0600)]
Use current_kernel_time() in the time compatibility wrappers

Since the Linux kernel's utimens family of functions uses
current_kernel_time(), we need to do the same in the context of ZFS
or else there can be discrepencies in timestamps (they go backward)
if userland code does:

fd = creat(FNAME, 0600);
(void) futimens(fd, NULL);

The getnstimeofday() function generally returns a slightly lower time
value.

Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes zfsonlinux/zfs#3006

9 years agoFix debug object on stack warning
Brian Behlendorf [Thu, 20 Nov 2014 01:01:20 +0000 (20:01 -0500)]
Fix debug object on stack warning

When running the SPLAT tests on a kernel with CONFIG_DEBUG_OBJECTS=y
enabled the following warning is generated.

  ODEBUG: object is on stack, but not annotated
  WARNING: at lib/debugobjects.c:300 __debug_object_init+0x221/0x480()

This is caused by the test cases placing a debug object on the stack
rather than the heap.  This isn't harmful since they are small objects
but to make CONFIG_DEBUG_OBJECTS=y happy the objects have been relocated
to the heap.  This impacted taskq tests 1, 3, and 7.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #424

9 years agomutex: force serialization on mutex_exit() to fix races
Chunwei Chen [Fri, 19 Dec 2014 03:31:59 +0000 (11:31 +0800)]
mutex: force serialization on mutex_exit() to fix races

It is known that mutexes in Linux are not safe when using them to
synchronize the freeing of object in which the mutex is embedded:

http://lwn.net/Articles/575477/

The known places in ZFS which are suspected to suffer from the race
condition are zio->io_lock and dbuf->db_mtx.

* zio uses zio->io_lock and zio->io_cv to synchronize freeing
  between zio_wait() and zio_done().
* dbuf uses dbuf->db_mtx to protect reference counting.

This patch fixes this kind of race by forcing serialization on
mutex_exit() with a spin lock, making the mutex safe by sacrificing
a bit of performance and memory overhead.

This issue most commonly manifests itself as a deadlock in the zio
pipeline caused by a process spinning on the damaged mutex.  Similar
deadlocks have been reported for the dbuf->db_mtx mutex.  And it can
also cause a NULL dereference or bad paging request under the right
circumstances.

This issue any many like it are linked off the zfsonlinux/zfs#2523
issue.  Specifically this fix resolves at least the following
outstanding issues:

zfsonlinux/zfs#401
zfsonlinux/zfs#2523
zfsonlinux/zfs#2679
zfsonlinux/zfs#2684
zfsonlinux/zfs#2704
zfsonlinux/zfs#2708
zfsonlinux/zfs#2517
zfsonlinux/zfs#2827
zfsonlinux/zfs#2850
zfsonlinux/zfs#2891
zfsonlinux/zfs#2897
zfsonlinux/zfs#2247
zfsonlinux/zfs#2939

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <ryao@gentoo.org>
Closes #421

9 years agoRemove compat includes from sys/types.h
Ned Bass [Fri, 14 Nov 2014 18:18:05 +0000 (10:18 -0800)]
Remove compat includes from sys/types.h

Don't include the compatibility code in linux/*_compat.h in the public
header sys/types.h. This causes problems when an external code base
includes the ZFS headers and has its own conflicting compatibility code.
Lustre, in particular, defined SHRINK_STOP for compatibility with
pre-3.12 kernels in a way that conflicted with the SPL's definition.
Because Lustre ZFS OSD includes ZFS headers it fails to build due to a
'"SHRINK_STOP" redefined' compiler warning.  To avoid such conflicts
only include the compat headers from .c files or private headers.

Also, for consistency, include sys/*.h before linux/*.h then sort by
header name.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #411

9 years agoRetire legacy debugging infrastructure
Brian Behlendorf [Wed, 5 Nov 2014 22:30:35 +0000 (17:30 -0500)]
Retire legacy debugging infrastructure

When the SPL was originally written Linux tracepoints were still
in their infancy.  Therefore, an entire debugging subsystem was
added to facilite tracing which served us well for many years.

Now that Linux tracepoints have matured they provide all the
functionality of the previous tracing subsystem.  Rather than
maintain parallel functionality it makes sense to fully adopt
tracepoints.  Therefore, this patch retires the legacy debugging
infrastructure.

See zfsonlinux/zfs@bc9f413 for the tracepoint changes.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #408

9 years agoLower minimum objects/slab threshold
Brian Behlendorf [Mon, 3 Nov 2014 21:50:39 +0000 (13:50 -0800)]
Lower minimum objects/slab threshold

As long as we can fit a minimum of one object/slab there's no reason
to prevent the creation of the cache.  This effectively pushes the
maximum object size up to 32MB.  The splat cache tests were extended
accordingly to verify this functionality.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoAdd config/compile to config/.gitignore
Marcel Wysocki [Fri, 31 Oct 2014 23:26:29 +0000 (16:26 -0700)]
Add config/compile to config/.gitignore

This file may be added by automake and therefore should be added
to config/.gitignore.  For the full list of possible auxiliary
programs see the full automake documentation.

http://www.gnu.org/software/automake/manual/automake.html#Auxiliary-Programs

Signed-off-by: Marcel Wysocki <maci.stgn@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoFix modules installation directory
Alexander Pyhalov [Tue, 28 Oct 2014 16:48:50 +0000 (09:48 -0700)]
Fix modules installation directory

When building zfs modules with kernel, compiled from deb.src, the
packaging process ends up installing the modules in the wrong place.

Signed-off-by: Alexander Pyhalov <apyhalov@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes zfsonlinux/zfs#2822

9 years agoKernel header installation should respect --prefix
Richard Yao [Fri, 29 Aug 2014 15:12:47 +0000 (11:12 -0400)]
Kernel header installation should respect --prefix

This is the upstream component of work that enables preliminary support
for building Gentoo's ZFS packaging on other Linux systems via Gentoo
Prefix.

Signed-off-by: Richard Yao <richard.yao@clusterhq.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #384

9 years agokmem_cache: Call constructor/destructor on each alloc/free
Richard Yao [Tue, 17 Jun 2014 23:37:02 +0000 (19:37 -0400)]
kmem_cache: Call constructor/destructor on each alloc/free

This has a few benefits. First, it fixes a regression that "Rework
generic memory allocation interfaces" appears to have triggered in
splat's slab_reap and slab_age tests. Second, it makes porting code from
Illumos to ZFSOnLinux easier. Third, it has the side effect of making
reclaim from slab caches that specify reclaim functions an order of
magnitude faster. The splat slab_reap test usually took 30 to 40
seconds. With this change, it takes 3 to 4.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #369

9 years agoLinux 3.12 compat: shrinker semantics
Tim Chase [Thu, 2 Oct 2014 12:40:05 +0000 (07:40 -0500)]
Linux 3.12 compat: shrinker semantics

The new shrinker API as of Linux 3.12 modifies "struct shrinker" by
replacing the @shrink callback with the pair of @count_objects and
@scan_objects.  It also requires the return value of @count_objects to
return the number of objects actually freed whereas the previous @shrink
callback returned the number of remaining freeable objects.

This patch adds support for the new @scan_objects return value semantics
and updates the splat shrinker test case appropriately.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tim Chase <tim@chase2k.com>
Closes #403

9 years agoMerge branch 'cleanup'
Brian Behlendorf [Sun, 19 Oct 2014 21:42:10 +0000 (14:42 -0700)]
Merge branch 'cleanup'

Over the years the SPL code bases has accumulated compatibly code
to allow it to build against a wide range of Linux kernels. In
general this is desirable because it makes the code flexible.
However, once support for these old kernels is no longer needed
and is no longer being actively tested it should be removed. This
helps keep the code simple and understandable.

The spl-0.6.x releases have supported kernels all the way back to
2.6.26. This patch stack moves that cut off up to 2.6.32 and newer
kernels. This ensures we still support all the major enterprise
distributions which are largely locked in to 2.6.32 based kernels.
And at the same time we can shed a large amount of compatibility
code which simplifies maintenance and new development.

Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #395

9 years agoRemove vfs_fsync() wrapper
Brian Behlendorf [Thu, 2 Oct 2014 18:52:47 +0000 (14:52 -0400)]
Remove vfs_fsync() wrapper

The vfs_fsync() function has been available since Linux 2.6.29.
There is no longer a need to maintain this compatibility code.
However, the HAVE_2ARGS_VFS_FSYNC check was left in place
since that change occured after 2.6.32.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove kern_path() wrapper
Brian Behlendorf [Thu, 2 Oct 2014 18:48:23 +0000 (14:48 -0400)]
Remove kern_path() wrapper

The kern_path() function has been available since Linux 2.6.28.
There is no longer a need to maintain this compatibility code.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove kvasprintf() wrapper
Brian Behlendorf [Thu, 2 Oct 2014 18:42:26 +0000 (14:42 -0400)]
Remove kvasprintf() wrapper

The kvasprintf() function has been available since Linux 2.6.22.
There is no longer a need to maintain this compatibility code.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove proc_handler() wrapper
Brian Behlendorf [Thu, 2 Oct 2014 18:15:19 +0000 (14:15 -0400)]
Remove proc_handler() wrapper

As of Linux 2.6.32 the proc handlers where updated to expect only
five arguments.  Therefore there is no longer a need to maintain
this compatibility code and this infrastructure can be simplified.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoUpdate put_task_struct() comments
Brian Behlendorf [Thu, 2 Oct 2014 17:59:26 +0000 (13:59 -0400)]
Update put_task_struct() comments

Update the comments to correctly reflect when this interface was
added.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove credential configure checks.
Brian Behlendorf [Thu, 2 Oct 2014 17:41:09 +0000 (13:41 -0400)]
Remove credential configure checks.

The groups_search() function was never exported by a mainline kernel
therefore we drop this compatibility code and always provide our own
implementation.

Additionally, the cred_t structure has been available since 2.6.29
so there is no longer a need to maintain compatibility code.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoAdd vfs_unlink() and vfs_rename() comments
Brian Behlendorf [Thu, 2 Oct 2014 16:59:38 +0000 (12:59 -0400)]
Add vfs_unlink() and vfs_rename() comments

Just for consistency with the other autoconf checks a small comment
block was added before these checks.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove set_fs_pwd() configure check
Brian Behlendorf [Thu, 2 Oct 2014 16:47:09 +0000 (12:47 -0400)]
Remove set_fs_pwd() configure check

This function has never been exported by any mainline and was only
briefly available under RHEL5.  Therefore this check is being removed
and the code update to always use the wrapper function.

The next step will be to eliminate all this code.  If ZFS were updated
not to assume that it's pwd was / there would be no need for this.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove user_path_dir() wrapper
Brian Behlendorf [Thu, 2 Oct 2014 00:14:15 +0000 (20:14 -0400)]
Remove user_path_dir() wrapper

The user_path_dir() function has been available since Linux 2.6.27.
There is no longer a need to maintain this compatibility code.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove kallsyms_lookup_name() wrapper
Brian Behlendorf [Wed, 1 Oct 2014 23:58:11 +0000 (19:58 -0400)]
Remove kallsyms_lookup_name() wrapper

After the removable of get_vmalloc_info(), the unused global memory
variables, and the optional dcache/icache shrinkers there is no
longer a need for the kallsyms compatibility code.  This allows
us to eliminate another brittle area of the code by removing the
kernel upcall this functionality depended on for older kernels.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove shrink_{i,d}node_cache() wrappers
Brian Behlendorf [Wed, 1 Oct 2014 23:27:29 +0000 (19:27 -0400)]
Remove shrink_{i,d}node_cache() wrappers

This is optional functionality which may or may not be useful to
ZFS when using older kernels.  It is never a hard requirement.
Therefore this functionality is being removed from the SPL and
a simpler slimmed down version will be added to ZFS.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove global memory variables
Brian Behlendorf [Wed, 1 Oct 2014 22:34:41 +0000 (18:34 -0400)]
Remove global memory variables

Platforms such as Illumos and FreeBSD have historically provided
global variables which summerize the memory state of a system.
Linux on the otherhand doesn't expose any of this information
to kernel modules and uses entirely different mechanisms for
memory management.

In order to simplify the original ZFS port to Linux these global
variables were emulated by the SPL for the benefit of ZFS.  As ZoL
has matured over the years it has moved steadily away from these
interfaces and now no longer depends on them at all.

Therefore, this patch completely removes the global variables
availrmem, minfree, desfree, lotsfree, needfree, swapfs_minfree,
and swapfs_reserve.  This greatly simplifies the memory management
code and eliminates a common area of confusion.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove get_vmalloc_info() wrapper
Brian Behlendorf [Wed, 1 Oct 2014 22:05:39 +0000 (18:05 -0400)]
Remove get_vmalloc_info() wrapper

The get_vmalloc_info() function was used to back the vmem_size()
function.  This was always problematic and resulted in brittle
code because the kernel never provided a clean interface for
modules.

However, it turns out that the only caller of this function in
ZFS uses it to determine the total virtual address space size.
This can be determined easily without get_vmalloc_info() so
vmem_size() has been updated to take this approach which allows
us to shed the get_vmalloc_info() dependency.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove on_each_cpu() wrapper
Brian Behlendorf [Wed, 1 Oct 2014 21:35:41 +0000 (17:35 -0400)]
Remove on_each_cpu() wrapper

The on_each_cpu() function has been available since Linux 2.6.27.
There is no longer a need to maintain this compatibility code.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove mutex_lock_nested() wrapper
Brian Behlendorf [Wed, 1 Oct 2014 21:31:53 +0000 (17:31 -0400)]
Remove mutex_lock_nested() wrapper

The mutex_lock_nested() function has been available since Linux 2.6.18.
There is no longer a need to maintain this compatibility code.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove i_mutex() configure check
Brian Behlendorf [Wed, 1 Oct 2014 21:07:46 +0000 (17:07 -0400)]
Remove i_mutex() configure check

The inode structure has used i_mutex as its internal locking
primitive since 2.6.16.  The compatibility code to check for
the previous semaphore primitive has been removed.  However,
the wrapper function itself is being kept because it's entirely
possible this primitive will change again to allow finer grained
locking.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove kmalloc_node() compatibility code
Brian Behlendorf [Wed, 1 Oct 2014 20:58:57 +0000 (16:58 -0400)]
Remove kmalloc_node() compatibility code

The kmalloc_node() function has been available since Linux 2.6.12.
There is no longer a need to maintain this compatibility code.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove linux/uaccess.h header check
Brian Behlendorf [Wed, 1 Oct 2014 20:40:37 +0000 (16:40 -0400)]
Remove linux/uaccess.h header check

The uaccess header has been available in the same location since
Linux 2.6.18.  There is no longer a need to maintain this
compatibility code.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove uintptr_t typedef
Brian Behlendorf [Wed, 1 Oct 2014 20:35:11 +0000 (16:35 -0400)]
Remove uintptr_t typedef

The uintptr_t typedef has been available since Linux 2.6.24.
There is no longer a need to maintain this compatibility code.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove atomic64_xchg() wrappers
Brian Behlendorf [Wed, 1 Oct 2014 20:31:11 +0000 (16:31 -0400)]
Remove atomic64_xchg() wrappers

The atomic64_xchg() and atomic64_cmpxchg() functions have been
available since Linux 2.6.24.  There is no longer a need to
maintain this compatibility code.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoSimplify the time compatibility wrappers
Brian Behlendorf [Tue, 30 Sep 2014 22:48:25 +0000 (18:48 -0400)]
Simplify the time compatibility wrappers

Many of the time functions had grown overly complex in order to
handle kernel compatibility issues.  However, as of Linux 2.6.26
all the required functionality is available.  This allows us to
retire numerous configure checks and greatly simplify the time
compatibility wrappers.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoMap highbit64() to fls64()
Brian Behlendorf [Tue, 30 Sep 2014 22:07:07 +0000 (18:07 -0400)]
Map highbit64() to fls64()

The fls64() function has been available since Linux 2.6.16 and
it should be used to implemented highbit64().  This allows us
to provide an optimized implementation and simplify the code.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove CTL_UNNUMBERED sysctl interface
Brian Behlendorf [Tue, 30 Sep 2014 22:15:22 +0000 (18:15 -0400)]
Remove CTL_UNNUMBERED sysctl interface

Support for the CTL_UNNUMBERED sysctl interface was removed in
Linux 2.6.19.  There is no longer any reason to maintain this
compatibility code.  There also issue any reason to keep around
the CTL_NAME macro and helpers so they have been retired.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove register_sysctl() compatibility code
Brian Behlendorf [Tue, 30 Sep 2014 21:10:35 +0000 (17:10 -0400)]
Remove register_sysctl() compatibility code

The register_sysctl() interface has been stable since Linux 2.6.21.
There is no longer a need to maintain compatibility code.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove utsname() wrapper
Brian Behlendorf [Fri, 17 Oct 2014 22:10:19 +0000 (15:10 -0700)]
Remove utsname() wrapper

There is no longer a need to wrap this because utsname() is provided
by the kernel and can be called directly.  This will require a small
change in the ZFS code because utsname is expected to be a global
structure and not a function.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove sysctl_vfs_cache_pressure assumption
Brian Behlendorf [Tue, 30 Sep 2014 18:51:53 +0000 (14:51 -0400)]
Remove sysctl_vfs_cache_pressure assumption

The generic SPL cache shrinkers make the assumption that the
caches only contain VFS cache data and therefore should be scaled
based on vfs_cache_pressure.  This is not strictly true and it
should not be assumed.

Removing this tuning should not have any impact on the stock
behavior because vfs_cache_pressure=100 by default.  This means
that no scaling will take place.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove adaptive mutex implementation
Brian Behlendorf [Mon, 29 Sep 2014 20:48:35 +0000 (16:48 -0400)]
Remove adaptive mutex implementation

Since the Linux 2.6.29 kernel all mutexes have been adaptive mutexs.
There is no longer any point in keeping this code so it is being
removed to simplify the code.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRemove patches directory
Brian Behlendorf [Mon, 29 Sep 2014 20:34:45 +0000 (16:34 -0400)]
Remove patches directory

There is no longer a need to carry these stale patches in the
SPL source tree.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoUpdate code to use misc_register()/misc_deregister()
Brian Behlendorf [Mon, 29 Sep 2014 23:42:15 +0000 (19:42 -0400)]
Update code to use misc_register()/misc_deregister()

When the SPL was originally written it was designed to use the
device_create() and device_destroy() functions.  Unfortunately,
these functions changed considerably over the years making them
difficult to rely on.

As it turns out a better choice would have been to use the
misc_register()/misc_deregister() functions.  This interface
for registering character devices has remained stable, is simple,
and provides everything we need.

Therefore the code has been reworked to use this interface.  The
higher level ZFS code has always depended on these same interfaces
so this is also as a step towards minimizing our kernel dependencies.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoUpdate SPLAT to use kmutex_t for portability
Brian Behlendorf [Mon, 29 Sep 2014 22:00:46 +0000 (18:00 -0400)]
Update SPLAT to use kmutex_t for portability

For consistency throughout the code update the SPLAT infrastructure
to use the wrapped mutex interfaces.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoMake license compatibility checks consistent
Brian Behlendorf [Mon, 29 Sep 2014 20:01:22 +0000 (16:01 -0400)]
Make license compatibility checks consistent

Apply the license specified in the META file to ensure the
compatibility checks are all performed consistently.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoInstall header during post-build rather than post-install.
Tom Prince [Thu, 9 Oct 2014 17:08:00 +0000 (14:08 -0300)]
Install header during post-build rather than post-install.

New versions of dkms clean up the build directory after installing.

It appears that this was always intended, but had rm -rf "/path/to/build/*"
(note the quotes), which prevented it from working.

Also, the build step is already installing stuff into the directory where
these files go, so installing our stuff there as part of build rather than
install makes sense.

Signed-off-by: Tom Prince <tom.prince@clusterhq.com>
Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #399

9 years agoFix bug in SPLAT taskq:front
Brian Behlendorf [Tue, 30 Sep 2014 21:47:10 +0000 (17:47 -0400)]
Fix bug in SPLAT taskq:front

While running SPLAT on a kernel with CONFIG_DEBUG_ATOMIC_SLEEP
enabled the taskq:front was flagged as a test which might sleep
which in an unsafe context.  Specifically, the splat_vprint()
function which internally takes a mutex was being called under
a spin lock.  Moving the log function outside the spin lock
cleanly solves this issue.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoLinux 3.16 compat: smp_mb__after_clear_bit()
Turbo Fredriksson [Sun, 14 Sep 2014 15:47:22 +0000 (15:47 +0000)]
Linux 3.16 compat: smp_mb__after_clear_bit()

The smp_mb__{before,after}_clear_bit functions have been renamed
smp_mb__{before,after}_atomic.  Rather than adding a compatibility
function to handle this the code has been updated to use smp_wmb().

This has the advantage of being a stable functionally equivalent
interface.  On many architectures smp_mb__after_clear_bit() expands
to smp_wmb().  Others might be able to do something slightly more
efficient but this will be safe and correct on all of them.

Signed-off-by: Turbo Fredriksson <turbo@bayour.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #386

9 years agoAvoid PAGESIZE redefinition
stf [Sat, 16 Aug 2014 22:16:08 +0000 (00:16 +0200)]
Avoid PAGESIZE redefinition

Add #ifndef PAGESIZE to avoid redefinition warning on platforms
where this value is already provided.

Signed-off-by: stf <s@ctrlc.hu>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #382

9 years agoCleanup vn_rename() and vn_remove()
Richard Yao [Sun, 29 Jun 2014 05:00:02 +0000 (01:00 -0400)]
Cleanup vn_rename() and vn_remove()

zfsonlinux/spl#bcb15891ab394e11615eee08bba1fd85ac32e158 implemented
Linux 3.6+ support by adding duplicate vn_rename and vn_remove
functions. The new ones were cleaner, but the duplicate functions made
the codebase less maintainable. This adds some compatibility shims that
allow us to retire the older vn_rename and vn_remove in favor of the new
ones on old kernels. The result is a net 143 line reduction in lines of
code and a cleaner codebase.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #370

9 years agoLinux 3.17 compat: remove wait_on_bit action function
Ned Bass [Sat, 9 Aug 2014 00:41:22 +0000 (17:41 -0700)]
Linux 3.17 compat: remove wait_on_bit action function

Linux kernel 3.17 removes the action function argument from
wait_on_bit().  Add autoconf test and compatibility macro to support
the new interface.

The former "wait_on_bit" interface required an 'action' function to
be provided which does the actual waiting. There were over 20 such
functions in the kernel, many of them identical, though most cases
can be satisfied by one of just two functions: one which uses
io_schedule() and one which just uses schedule().  This API change
was made to consolidate all of those redundant wait functions.

References: torvalds/linux@7431620

Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #378

9 years agoSet spl_kmem_cache_slab_limit=16384 to default
Brian Behlendorf [Thu, 7 Aug 2014 23:23:04 +0000 (16:23 -0700)]
Set spl_kmem_cache_slab_limit=16384 to default

For small objects the Linux slab allocator should be used to make the most
efficient use of the memory.  However, large objects are not supported by
the Linux slab and therefore the SPL implementation is preferred.  A cutoff
of 16K was determined to be optimal for architectures using 4K pages.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: DHE <git@dehacked.net>
Issue #356
Closes #379

9 years agoSet spl_kmem_cache_reclaim=0 to default
Brian Behlendorf [Thu, 7 Aug 2014 23:14:41 +0000 (16:14 -0700)]
Set spl_kmem_cache_reclaim=0 to default

Reinstate the correct default behavior of returning the number of objects
in the cache for reclaim.  This behavior was disabled in recent releases
to do occasional reports of spinning in shrink_slabs().  Those issues have
been resolved and can no longer can be reproduced.  See commit 376dc35.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: DHE <git@dehacked.net>
Issue #358
Closes #379

9 years agoAdd atomic_swap_32() and atomic_swap_64()
Tim Chase [Sat, 26 Jul 2014 04:45:26 +0000 (23:45 -0500)]
Add atomic_swap_32() and atomic_swap_64()

The atomic_swap_32() function maps to atomic_xchg(), and
the atomic_swap_64() function maps to atomic64_xchg().

Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #377

9 years agoAdd functions and macros as used upstream.
Tim Chase [Sun, 27 Apr 2014 01:56:03 +0000 (20:56 -0500)]
Add functions and macros as used upstream.

Added highbit64() and howmany() which are used in recent upstream
code.  Both highbit() and highbit64() should at some point be
re-factored to use the optimized fls() and fls64() functions.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Tim Chase <tim@chase2k.com>
Closes #363

9 years agoRate limit debugging stack traces
Brian Behlendorf [Wed, 16 Jul 2014 21:00:57 +0000 (14:00 -0700)]
Rate limit debugging stack traces

There have been issues in the past where excessive debug logging
to the console has resulted in significant performance impacts.
In the vast majority of these cases only a few stack traces are
required to diagnose the issue.  Therefore, stack traces dumped to
the console will now we limited to 5 every 60s.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Closes #374

9 years agoSafer debugging and assertion macros.
Tim Chase [Wed, 18 Jun 2014 20:22:50 +0000 (15:22 -0500)]
Safer debugging and assertion macros.

Spl's debugging and assertion macros macro used the typical do/while(0)
form for if/else friendliness, however, this limits their use in contexts
where a do loop is not valid; such as within another multi-statement
style macro.

The following macros have been converted to not use do/while(0):
PANIC, ASSERT, ASSERTF, VERIFY, VERIFY3_IMPL

PANIC has been converted to a wrapper around the new spl_PANIC() function.

The other macros have been converted to use the "&&" operator for the
branch-predicition conditional and also to use spl_PANIC().

The __ASSERT() macro was not touched.  It is only used by the debugging
infrastructure and that code, including this macro, will be retired when
the tracepoint patches are merged.

Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #367

9 years agoTag spl-0.6.3
Brian Behlendorf [Thu, 12 Jun 2014 18:32:38 +0000 (11:32 -0700)]
Tag spl-0.6.3

META file and release log updated.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoSet LANG to a reasonable default (C)
Turbo Fredriksson [Mon, 9 Jun 2014 21:35:42 +0000 (23:35 +0200)]
Set LANG to a reasonable default (C)

Set LANG=C before calling 'rpmbuild' to avoid rpmbuild failing on
the translated date string in the changelog.

Signed-off-by: Turbo Fredriksson <turbo@bayour.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #306

9 years agoFix DKMS package upgrade and packager
Brian Behlendorf [Thu, 29 May 2014 21:06:32 +0000 (14:06 -0700)]
Fix DKMS package upgrade and packager

Running 'yum upgrade spl-dkms' package could appear to work properly
and still leave you with no spl modules installed.  This will occur
when only the spl release, and not the version, are incremented.
This may be the case for a fast moving spl-testing repository.

During the upgrade process DKMS will realize that spl-x.y.z is already
installed and remove it.  DKMS then correctly builds the new modules
for spl-x.y.z.  However, as a final step when the old spl-x.y.z-r is
removed the %preun script runs and removes the newly build modules.
To handle this case the %preun script has been updated to only run
when the installed version exactly matches the full spec file version.

This change also updated ChangeLog section based on the DKMS
reference spec file.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoRestrict release number to META version
Brian Behlendorf [Thu, 29 May 2014 21:55:40 +0000 (14:55 -0700)]
Restrict release number to META version

When creating packages in a git repository the release number
can be automatically set by 'git describe'.  This normally works
well but if your repository has newer tags which match the form
NAME-VERSION* the release may be incorrectly calculated.  To
prevent this the match patten has been restricted to NAME-VERSION.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
9 years agoAdd spl_kmem_cache_reclaim module option
Brian Behlendorf [Fri, 16 May 2014 16:29:21 +0000 (09:29 -0700)]
Add spl_kmem_cache_reclaim module option

The correct behavior for all registered shrinkers is to return the
number of objects in their cache.  In theory this allows the Linux
VM to balance memory reclaim across all registered caches.

In commit b9b3715 this behavior was disabled in favor of returning
-1 which notifies the VM that no additional objects are available
for reclaim.  This was done as a workaround to resolve thrashing
in shrink_slabs() which could occur when memory was low and numerous
core where in reclaim.  Unfortunately, this has been observed to
increase the likelihood of OOM events when SPL slab consumers are
responsible for consuming the majority of memory.

Therefore, this patch makes this behavior tunable.  Setting the
spl_kmem_cache_reclaim module option to 0x1 will result in the
shrinker only being called once.  This is the default behavior.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Closes #358

9 years agoAdd KMC_SLAB cache type
Brian Behlendorf [Sun, 8 Dec 2013 22:01:45 +0000 (17:01 -0500)]
Add KMC_SLAB cache type

For small objects the Linux slab allocator has several advantages
over its counterpart in the SPL.  These include:

1) It is more memory-efficient and packs objects more tightly.
2) It is continually tuned to maximize performance.

Therefore it makes sense to layer the SPLs slab allocator on top
of the Linux slab allocator.  This allows us to leverage the
advantages above while preserving the Illumos semantics we depend
on.  However, there are some things we need to be careful of:

1) The Linux slab allocator was never designed to work well with
   large objects.  Because the SPL slab must still handle this use
   case a cut off limit was added to transition from Linux slab
   backed objects to kmem or vmem backed slabs.

   spl_kmem_cache_slab_limit - Objects less than or equal to this
   size in bytes will be backed by the Linux slab.  By default
   this value is zero which disables the Linux slab functionality.
   Reasonable values for this cut off limit are in the range of
   4096-16386 bytes.

   spl_kmem_cache_kmem_limit - Objects less than or equal to this
   size in bytes will be backed by a kmem slab.  Objects over this
   size will be vmem backed instead.  This value defaults to
   1/8 a page, or 512 bytes on an x86_64 architecture.

2) Be aware that using the Linux slab may inadvertently introduce
   new deadlocks.  Care has been taken previously to ensure that
   all allocations which occur in the write path use GFP_NOIO.
   However, there may be internal allocations performed in the
   Linux slab which do not honor these flags.  If this is the case
   a deadlock may occur.

The path forward is definitely to start relying on the Linux slab.
But for that to happen we need to start building confidence that
there aren't any unexpected surprises lurking for us.  And ideally
need to move completely away from using the SPLs slab for large
memory allocations.  This patch is a first step.

NOTES:
1) The KMC_NOMAGAZINE flag was leveraged to support the Linux slab
   backed caches but it is not supported for kmem/vmem backed caches.

2) Regardless of the spl_kmem_cache_*_limit settings a cache may
   be explicitly set to a given type by passed the KMC_KMEM,
   KMC_VMEM, or KMC_SLAB flags during cache creation.

3) The constructors, destructors, and reclaim callbacks are all
   functional and will be called regardless of the cache type.

4) KMC_SLAB caches will not appear in /proc/spl/kmem/slab due to
   the issues involved in presenting correct object accounting.
   Instead they will appear in /proc/slabinfo under the same names.

5) Several kmem SPLAT tests needed to be fixed because they relied
   incorrectly on internal kmem slab accounting.  With the updated
   test cases all the SPLAT tests pass as expected.

6) An autoconf test was added to ensure that the __GFP_COMP flag
   was correctly added to the default flags used when allocating
   a slab.  This is required to ensure all pages in higher order
   slabs are properly refcounted, see ae16ed9.

7) When using the SLUB allocator there is no need to attempt to
   set the __GFP_COMP flag.  This has been the default behavior
   for the SLUB since Linux 2.6.25.

8) When using the SLUB it may be desirable to set the slub_nomerge
   kernel parameter to prevent caches from being merged.

Original-patch-by: DHE <git@dehacked.net>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: DHE <git@dehacked.net>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Closes #356

10 years agoLinux 3.15: vfs_rename() added a flags argument
Chunwei Chen [Wed, 7 May 2014 17:54:37 +0000 (10:54 -0700)]
Linux 3.15: vfs_rename() added a flags argument

Detect the updated vfs_rename() interface and call it with an
extra flags argument.

References:
  torvalds/linux@520c8b1

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #355

10 years agoLinux 3.15 compat: NICE_TO_PRIO and PRIO_TO_NICE
Chunwei Chen [Wed, 7 May 2014 17:57:19 +0000 (10:57 -0700)]
Linux 3.15 compat: NICE_TO_PRIO and PRIO_TO_NICE

These macro's were exposed to make them available to other
parts of the kernel and modules.

References:
  torvalds/linux@6b6350f

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #355

10 years agoEvenly distribute the taskq threads across available CPUs
Andrey Vesnovaty [Wed, 28 Aug 2013 02:09:25 +0000 (05:09 +0300)]
Evenly distribute the taskq threads across available CPUs

The problem is described in commit aeeb4e0c0ae75b99ebbaa3056f0afc8e12949532.
However, instead of disabling the binding to CPU altogether we just keep the
last CPU index across calls to taskq_create() and thus achieve even
distribution of the taskq threads across all available CPUs.

The implementation based on assumption that task queues initialization
performed in serial manner.

Signed-off-by: Andrey Vesnovaty <andrey.vesnovaty@gmail.com>
Signed-off-by: Andrey Vesnovaty <andreyv@infinidat.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #336

10 years agoFix crash when using ZFS on Ceph rbd
Chunwei Chen [Tue, 22 Apr 2014 08:45:36 +0000 (16:45 +0800)]
Fix crash when using ZFS on Ceph rbd

When using __get_free_pages to get high order memory, only the first page's
_count will set to 1, other's will be 0. When an internal page get passed into
rbd, it will eventully go into tcp_sendpage. There, it will be called with
get_page and put_page, and get freed erroneously when _count jump back to 0.

The solution to this problem is to use compound page. All pages in a
high order compound page share a single _count. So get_page and put_page in
tcp_sendpage will not cause _count jump to 0.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #251

10 years agoAdd support for aarch64 (ARMv8)
Jorgen Lundman [Wed, 16 Apr 2014 03:18:38 +0000 (12:18 +0900)]
Add support for aarch64 (ARMv8)

Using the ARM reference simulation (fast model foundation v8) I
cross compiled spl and zfs, to confirm it works on ARMv8 (64 bit
arm architecture, called aarch64 in Linux).

As it is based on previous ARM porting, the resulting patch is
disappointingly small, there was very little to do. The code fixes
the compile issues and has light testing done.

Signed-off-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #351

10 years agoChange spl_kmem_cache_expire default setting to 2
Richard Yao [Sun, 4 Aug 2013 23:48:24 +0000 (19:48 -0400)]
Change spl_kmem_cache_expire default setting to 2

This behavior is more consistent with the way memory reclaim
is expected to work under Linux.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #349

10 years agoExpose max/min objs per slab and max slab size
Andrey Vesnovaty [Thu, 6 Feb 2014 10:08:46 +0000 (12:08 +0200)]
Expose max/min objs per slab and max slab size

By default maximal number of objects in slab can't exceed (16*2 - 1) and slab
size can't exceed 32M.
Today's high end servers having couple hundreds of RAM available for ARC may
run into a trouble with virtual memory because of the restriction mentioned
above.

Problem:
Reasons for very high number of virtual memory allocations:
* Real slab size very small relative to the size of the entire RAM
* Slabs allocated on virtual memory and fill entire ARC

The result is very high number of allocated virtual memory ranges (hundreds of
ranges). When virtual memory subsystem manages high number of ranges its
performance become so poor that it freezes from time to time.

Solution:
Number of objects per slab should be increased taking into account maximal
slab size which can also be increased if needed.

Signed-off-by: Andrey Vesnovaty <andrey.vesnovaty@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #337

10 years agoAdd ddi_time_after and friends
Chunwei Chen [Tue, 25 Feb 2014 09:16:55 +0000 (17:16 +0800)]
Add ddi_time_after and friends

When comparing times gotten from ddi_get_lbolt, we have to take account of
wrap around of jiffies. Therefore, we cannot use 't1 < t2'. Instead we should
use 't1 - t2 < 0'.

This patch add ddi_time_after and friends to address this issue. They have
strict type restriction, clock_t for vanilla and int64_t for 64 version, to
prevent type conversion from screwing things.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #335

10 years agoThis patch add a CTASSERT macro for compile time assertion.
Yuxuan Shui [Fri, 1 Nov 2013 16:14:05 +0000 (00:14 +0800)]
This patch add a CTASSERT macro for compile time assertion.

This macro makes the compile to spit "mixed definition and code"
warning, I can't find a way to avoid it.

This patch lays some groundwork for the persistent l2arc feature.
See https://www.illumos.org/issues/3525.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #303

10 years agoSimplify hostid logic
Richard Yao [Tue, 12 Mar 2013 01:16:36 +0000 (21:16 -0400)]
Simplify hostid logic

There is plenty of compatibility code for a hw_hostid
that isn't used by anything. At the same time, there are apparently
issues with the current hostid logic. coredumb in #zfsonlinux on
freenode reported that Fedora 17 changes its hostid on every boot, which
required force importing his pool. A suggestion by wca was to adopt
FreeBSD's behavior, where it treats hostid as zero if /etc/hostid does
not exist

Adopting FreeBSD's behavior permits us to eliminate plenty of code,
including a userland helper that invokes the system's hostid as a
fallback.

Signed-off-by: Richard Yao <ryao@cs.stonybrook.edu>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #224

10 years agoCall kthread_create() correctly with fixed arguments.
Tim Chase [Fri, 11 Apr 2014 13:55:10 +0000 (08:55 -0500)]
Call kthread_create() correctly with fixed arguments.

The kernel's kthread_create() function is defined as "..." and there is
no va_list variant at the moment.  The task name is pre-formatted into
a local buffer and passed to kthread_create() with fixed arguments.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #347

10 years agoDe-inline spl_kthread_create().
Tim Chase [Wed, 9 Apr 2014 18:40:12 +0000 (13:40 -0500)]
De-inline spl_kthread_create().

The function was defined as a static inline with variable arguments
which causes gcc to generate errors on some distros.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tim Chase <tim@chase2k.com>
Closes #346

10 years agoSupport post-3.13 kthread_create() semantics.
Tim Chase [Wed, 26 Mar 2014 13:29:24 +0000 (08:29 -0500)]
Support post-3.13 kthread_create() semantics.

Provide spl_kthread_create() as a wrapper to the kernel's kthread_create()
to provide pre-3.13 semantics.  Re-try if the call is interrupted or if it
would have returned -ENOMEM.  Otherwise return NULL.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #339

10 years agosplat cred:groupmember: Fix false positives
Brian Behlendorf [Mon, 7 Apr 2014 21:31:21 +0000 (14:31 -0700)]
splat cred:groupmember: Fix false positives

Due to certain assumptions made in the the cred:groupmember test it
could result in false positives when run on specific distributions.
This was solely a bug in the test case and not in the groupmember()
function which the test case was validating.

To prevent future false positives the test case has been rewritten
to be both more rigerous and to make fewer assumptions about the
system.

Minor style cleanup was done to cr_groups_search() and groupmember()
functions.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
10 years agosplat kmem:slab_reclaim: Test cleanup
Brian Behlendorf [Mon, 7 Apr 2014 22:40:20 +0000 (15:40 -0700)]
splat kmem:slab_reclaim: Test cleanup

By setting __GFP_NORETRY the kernel memory reclaim logic was allowed to
abort early and dump a falled allocation stack to the console.  Since
this was done in a tight loop to fill memory it could result in a large
number of stacks being dumped to the console.  This in turn slowed down
the test sufficiently so it exceeded the time limit and failed.

To resolve this issue the __GFP_NORETRY flag is being removed.  This is
how it should have been called originally to ensure we're simulating
the behavior of most callers which will use the GFP_KERNEL flag.

In addition, the reclaim granularity of 1000 objects was far to coarse
for this to be a realistic test.  For kmem:slab_reclaim there might
only be a few thousand objects total in the cache.  Therefore, the
SPLAT_KMEM_OBJ_RECLAIM constant for these tests was lowered.  This
will cause the reclaim callback to run more frequently which makes
for a better test case.

The frequency of the cache reaping in kmem:slab_reap was increased
to accommodate the reduced number of objects released during the
reclaim.

These changes only impact the test cases and were done to remove
false positives caused by the test case itself.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
10 years agoRemove incorrect use of EXTRA_DIST for man pages
Brian Behlendorf [Fri, 17 Jan 2014 19:40:59 +0000 (11:40 -0800)]
Remove incorrect use of EXTRA_DIST for man pages

Setting the 'dist_' prefix is the correct way to instruct Automake
to include these files in the distribution.  The EXTRA_DIST variable
is reserved for files which are not covered by the automatic rules.

  http://www.gnu.org/software/automake/manual/automake.html#Basics

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
10 years agoDefine the needed ISA types for Sparc
marku89 [Tue, 7 Jan 2014 19:33:19 +0000 (20:33 +0100)]
Define the needed ISA types for Sparc

Add the minimum required ISA types to support the Sparc
architecture.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: marku89 <mar42@kola.li>
Closes #317

10 years agoRemove default taskq thread to CPU bindings
Brian Behlendorf [Tue, 7 Jan 2014 00:31:49 +0000 (16:31 -0800)]
Remove default taskq thread to CPU bindings

When this code was written it appears to have been assumed that
every taskq would have a large number of threads.  In this case
it would make sense to attempt to evenly bind the threads over
all available CPUs.  However, it failed to consider that creating
taskqs with a small number of threads will cause the CPUs with
lower ids become over-subscribed.

For this reason the kthread_bind() call is being removed and
we're leaving the kernel to schedule these threads as it sees fit.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #325

10 years agoInclude linux/vmalloc.h for ARM and Sparc
Brian Behlendorf [Mon, 6 Jan 2014 23:08:35 +0000 (15:08 -0800)]
Include linux/vmalloc.h for ARM and Sparc

Related to issue #257 which added Linux 3.10 compatibility.  For
ARM and Sparc architectures we must explicitly include the
<linux/vmalloc.h> header to ensure the vmalloc_info structure
is always defined when available.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #257
Closes #291

10 years agoAdd module versioning
Brian Behlendorf [Wed, 4 Dec 2013 18:14:14 +0000 (10:14 -0800)]
Add module versioning

Use the standard Linux MODULE_VERSION macro to expose the installed
spl and splat module versions.  This will also automatically add a
checksum of the .c files and headers in "srcversion".  See:

  /sys/module/spl/version
  /sys/module/spl/srcversion
  /sys/module/splat/version
  /sys/module/splat/srcversion

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes zfsonlinux/zfs#1923

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
10 years agoLinux 3.13 compat: Pass NULL for new delegated inode argument
Richard Yao [Mon, 25 Nov 2013 16:22:33 +0000 (11:22 -0500)]
Linux 3.13 compat: Pass NULL for new delegated inode argument

This check was originally added for SLES10, a093c6a, to check for
a 'struct vfsmount *' argument which they added.  However, since
SLES10 is based on a 2.6.16 kernel which is no longer supported
this functionality was dropped.  The checks were refactored to
support Linux 3.13 without concern for historical versions.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #312

10 years agoLinux 3.13 compat: Remove unused flags variable from __cv_init()
Richard Yao [Thu, 8 Aug 2013 08:30:55 +0000 (04:30 -0400)]
Linux 3.13 compat: Remove unused flags variable from __cv_init()

GCC 4.8.1 complained about an unused flags variable when building
against Linux 2.6.26.8:

/var/tmp/portage/sys-kernel/spl-9999/work/spl-9999/module/spl/../../module/spl/spl-condvar.c:
In function ‘__cv_init’:
/var/tmp/portage/sys-kernel/spl-9999/work/spl-9999/module/spl/../../module/spl/spl-condvar.c:39:6:
error: variable ‘flags’ set but not used
[-Werror=unused-but-set-variable]
  int flags = KM_SLEEP;
        ^
cc1: all warnings being treated as errors

Additionally, the superfluous code uses a preempt_count variable that is
no longer available on Linux 3.13. Deleting the unnecessary code fixes a
Linux 3.13 compatibility issue.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #312

10 years agoDocument SPL module parameters.
Turbo Fredriksson [Mon, 18 Nov 2013 13:46:10 +0000 (13:46 +0000)]
Document SPL module parameters.

This is a first draft of a spl-module-parameters(5) man page. I have
just extracted the parameter name and its description with modinfo,
then checked the source what type it is and its default value.

This will need more work, preferably someone that actually know these
values and what to use them for.  Similar to zfsonlinux/zfs#1856, but
for the spl.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes zfsonlinux/zfs#1856

10 years agoRetroactively fix bogus %changelog date
Brian Behlendorf [Thu, 14 Nov 2013 22:05:45 +0000 (14:05 -0800)]
Retroactively fix bogus %changelog date

New versions of rpmbuild detect the invalid date which was added
incorrectly to the changelog.  To silence this noise fix it.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #306

10 years agoTighten spl dependency on spl-kmod
Cyril Plisko [Thu, 14 Nov 2013 21:58:35 +0000 (13:58 -0800)]
Tighten spl dependency on spl-kmod

Make spl depend on the same version of spl-kmod, rather than on same or
better. When yum repository contains a number of versions the dependency
resolution breaks on trying to install non-latest version.

Signed-off-by: Cyril Plisko <cyril.plisko@mountall.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes zfsonlinux/zfs#1677

10 years agoLinux 3.12 compat: New shrinker API
Richard Yao [Tue, 5 Nov 2013 16:35:54 +0000 (11:35 -0500)]
Linux 3.12 compat: New shrinker API

torvalds/linux@24f7c6 introduced a new shrinker API while
torvalds/linux@a0b021 dropped support for the old shrinker API.
This patch adds support for the new shrinker API by wrapping
the old one with the new one.

This change also reorganizes the autotools checks on the shrinker
API such that the configure script will fail early if an unknown
API is encountered in the future.

Support for the set_shrinker() API which was used by Linux 2.6.22
and older has been dropped.  As a general rule compatibility is
only maintained back to Linux 2.6.26.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes zfsonlinux/zfs#1732
Closes zfsonlinux/zfs#1822
Closes #293
Closes #307

10 years agoEmulate illumos interface cv_timedwait_hires()
Ned Bass [Fri, 1 Nov 2013 20:37:58 +0000 (13:37 -0700)]
Emulate illumos interface cv_timedwait_hires()

Needed for Illumos #3582. This interface is supposed to support
a variable-resolution timeout with nanosecond granularity.  This
implementation rounds up to microsecond resolution, as nanosecond-
precision timing is rarely needed for real-world performance
tuning and may incur unnecessary busy-waiting.  usleep_range() is
used if available, otherwise udelay() or msleep() are used
depending on the length of the delay interval.

Add flags from sys/callo.h as these are used to control the behavior of
cv_timedwait_hires().  Specifically,

CALLOUT_FLAG_ABSOLUTE
    Normally, the expiration passed to the timeout API functions is
    an expiration interval. If this flag is specified, then it is
    interpreted as the expiration time itself.

CALLOUT_FLAG_ROUNDUP
    Roundup the expiration time to the next resolution boundary. If this
    flag is not specified, the expiration time is rounded down.

References:
    https://www.illumos.org/issues/3582
    illumos/illumos-gate@0689f76

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #304

10 years agoMerge branch 'kstat'
Brian Behlendorf [Fri, 25 Oct 2013 20:50:07 +0000 (13:50 -0700)]
Merge branch 'kstat'

This branch updates the existing kstat infrastructure to be
more flexible.  In particular, it extends the KSTAT_TYPE_RAW
type so it may be used to generate more dynamic kstats without
the need for additional custom types.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
10 years ago3537 add kstat_waitq_enter and friends
Ned Bass [Mon, 26 Aug 2013 23:42:11 +0000 (16:42 -0700)]
3537 add kstat_waitq_enter and friends

These kstat interfaces are required to port
"Illumos #3537 want pool io kstats" to ZFS on Linux.

kstat_waitq_enter()
kstat_waitq_exit()
kstat_runq_enter()
kstat_runq_exit()

Additionally, zero out the ks_data buffer in __kstat_create() so
that the kstat_io_t counters are initialized to zero.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
10 years agoKstat to use private lock by default
Cyril Plisko [Tue, 13 Aug 2013 12:15:36 +0000 (15:15 +0300)]
Kstat to use private lock by default

While porting Illumos #3537 I found that ks_lock member of kstat_t
structure is different between Illumos and SPL. It is a pointer to
the kmutex_t in Illumos, but the mutex lock itself in SPL.
Apparently Illumos kstat API allows consumer to override the lock
if required. With SPL implementation it is not possible anymore.

Things were alright until the first attempt to actually override
the lock. Porting of Illumos #3537 introduced such code for the
first time.

In order to provide the Solaris/Illumos like functionality we:
  1. convert ks_lock to "kmutex_t *ks_lock"
  2. create a new field "kmutex_t ks_private_lock"
  3. On kstat_create() ks_lock = &ks_private_lock

Thus if consumer doesn't care we still have our internal lock in use.
If, however, consumer does care she has a chance to set ks_lock to
anything else before calling kstat_install().

The rest of the code will use ks_lock regardless of its origin.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #286

10 years agoRevert "Add KSTAT_TYPE_TXG type"
Brian Behlendorf [Mon, 30 Sep 2013 18:32:42 +0000 (11:32 -0700)]
Revert "Add KSTAT_TYPE_TXG type"

This reverts commit dba79fcbf2cc50be5caef84ae01657e884ac5d89 in
favor of using the generic KSTAT_TYPE_RAW callbacks.  The advantage
of this approach is that arbitrary types can be added without the
need to add them to the SPL.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #296

10 years agoAdd wrappers for accessing PID and command info
Prakash Surya [Tue, 24 Sep 2013 23:11:56 +0000 (16:11 -0700)]
Add wrappers for accessing PID and command info

This change adds simple wrappers for accessing a thread's PID and
command character string.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #296

10 years agoAdd callbacks for displaying KSTAT_TYPE_RAW kstats
Prakash Surya [Thu, 12 Sep 2013 23:14:51 +0000 (16:14 -0700)]
Add callbacks for displaying KSTAT_TYPE_RAW kstats

The current implementation for displaying kstats of type KSTAT_TYPE_RAW
is rather crude. This patch attempts to enhance this handling by
allowing a kstat user to register formatting callbacks which can
optionally be used.

The callbacks allow the user to implement functions for interpreting
their data and transposing it into a character buffer. This buffer,
containing a string representation of the raw data, is then be displayed
through the current /proc textual interface.

Additionally the kstats are made writable because it's now possible
to provide a useful handler via the existing ks_update() interface.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #296

10 years agoDefine SET_ERROR()
Richard Yao [Sun, 6 Oct 2013 02:19:05 +0000 (22:19 -0400)]
Define SET_ERROR()

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
10 years agoConsistently use local_irq_disable/local_irq_enable
Brian Behlendorf [Wed, 25 Sep 2013 21:52:29 +0000 (14:52 -0700)]
Consistently use local_irq_disable/local_irq_enable

It was observed that spl_kmem_cache_alloc() uses local_irq_save()
and saves the interrupt state in a local variable.  This would
normally be fine except that spl_kmem_cache_alloc() calls
spl_cache_refill() which re-enables interrupts.  It is then
possible that while interrupts are enabled the process is
rescheduled to a different cpu before being disable again.
This could result in us restoring the saved interrupt state
from one cpu to another.

What the consequences of this are aren't perfectly clear, but
this is clearly a bug and it has the potential to cause issues.
The code has been updated to just use local_irq_enable() and
local_irq_disable() to avoid this.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
10 years agoDocument how to run SPLAT
Kohsuke Kawaguchi [Sun, 22 Sep 2013 16:45:54 +0000 (09:45 -0700)]
Document how to run SPLAT

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #294

10 years agoAdd kpreempt() compatibility macro
Ned Bass [Thu, 29 Aug 2013 03:08:03 +0000 (20:08 -0700)]
Add kpreempt() compatibility macro

This is needed for the Illumos #4045 write throttle patch.  It is used
in the arc eviction code to avoid blocking all arc activity by sitting on
arcs_mtx too long.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #286