]> git.proxmox.com Git - mirror_spl.git/log
mirror_spl.git
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

10 years agoReplace current_kernel_time() with getnstimeofday()
Richard Yao [Sun, 18 Aug 2013 14:51:06 +0000 (10:51 -0400)]
Replace current_kernel_time() with getnstimeofday()

current_kernel_time() is used by the SPLAT, but it is not meant for
performance measurement. We modify the SPLAT to use getnstimeofday(),
which is equivalent to the gethrestime() function on Solaris.
Additionally, we update gethrestime() to invoke getnstimeofday().

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

10 years agoTag spl-0.6.2
Brian Behlendorf [Fri, 16 Aug 2013 22:14:17 +0000 (15:14 -0700)]
Tag spl-0.6.2

META file and release log updated.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
10 years agoLinux 3.8 compat: Use kuid_t/kgid_t when required
Richard Yao [Sat, 13 Jul 2013 20:34:56 +0000 (16:34 -0400)]
Linux 3.8 compat: Use kuid_t/kgid_t when required

When CONFIG_UIDGID_STRICT_TYPE_CHECKS is enabled uid_t/git_t are
replaced by kuid_t/kgid_t, which are structures instead of integral
types. This causes any code that uses an integral type to fail to build.
The User Namespace functionality introduced in Linux 3.8 requires
CONFIG_UIDGID_STRICT_TYPE_CHECKS, so we could not build against any
kernel that supported it.

We resolve this by converting between the new kuid_t/kgid_t structures
and the original uid_t/gid_t types.

Original-patch-by: DHE
Rewrite-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #260

10 years agoPaX/GrSecurity Linux 3.8.y compat: Use __no_const on struct ctl_table
Richard Yao [Wed, 27 Mar 2013 15:33:14 +0000 (11:33 -0400)]
PaX/GrSecurity Linux 3.8.y compat: Use __no_const on struct ctl_table

The PaX team started constifying `struct ctl_table` as of their Linux
3.8.0 patchset. This lead to zfsonlinux/spl#225 and Gentoo bug #463012.

While investigating our options, I learned that there is a preprocessor
directive called CONSTIFY_PLUGIN that we can use to detect the presence
of the PaX changes and adjust the code accordingly.

The PaX Team had suggested adopting ctl_table_no_const, but supporting
older kernels required declaring that whenever the CONSTIFY_PLUGIN was
set. Future compiler changes could potentially cause that to break in
the presence of -Werror, so instead we define our own spl_ctl_table
typdef and use that. This should be compatible with all PaX kernels.

This introduces a Linux kernel version number check to prevent a build
failure on versions of the PaX GCC plugin that existed for kernels
before Linux 3.8.0. Affected versions of the PaX plugin will trigger a
compiler error when they see no_const cast on a non-constified
structure.  Ordinarily, we would need an autotools check to catch that.
However, it is safe to do a kernel version check instead of an autotools
check in this specific instance because the affected versions of the PaX
GCC plugin only exist for Linux kernels before 3.8.0 and the
constification of `struct ctl_table` by the PaX developers only occurs
in Linux 3.8.0 and later.

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

10 years agoFix race in spl_kmem_cache_reap_now()
Richard Yao [Sun, 4 Aug 2013 23:35:08 +0000 (19:35 -0400)]
Fix race in spl_kmem_cache_reap_now()

The current code contains a race condition that triggers when bit 2 in
spl.spl_kmem_cache_expire is set, spl_kmem_cache_reap_now() is invoked
and another thread is concurrently accessing its magazine.

spl_kmem_cache_reap_now() currently invokes spl_cache_flush() on each
magazine in the same thread when bit 2 in spl.spl_kmem_cache_expire is
set. This is unsafe because there is one magazine per CPU and the
magazines are lockless, so it is impossible to guarentee that another
CPU is not using its magazine when this function is called.

The solution is to only touch the local CPU's magazine and leave other
CPU's magazines to other CPUs.

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

10 years agoLinux 3.11 compat: Replace num_physpages with totalram_pages
Richard Yao [Wed, 7 Aug 2013 08:50:04 +0000 (04:50 -0400)]
Linux 3.11 compat: Replace num_physpages with totalram_pages

num_physpages was removed by
torvalds/linux@cfa11e08ed39eb28a9eff9a907b20913020c69b5, so lets replace
it with totalram_pages.

This is a bug fix as much as it is a compatibility fix because
num_physpages did not reflect the number of pages actually available to
the kernel:

http://lkml.indiana.edu/hypermail/linux/kernel/0908.2/01001.html

Also, there are known issues with memory calculations when ZFS is in a
Xen dom0. There is a chance that using totalram_pages could resolve
them. This conjecture is untested at the time of writing.

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

10 years agoAdd kmod repo integration
Brian Behlendorf [Sat, 27 Jul 2013 09:37:38 +0000 (02:37 -0700)]
Add kmod repo integration

When the kmod packaging infrastructure was originally added the
dependency on the rpmfusion yum repositories was disabled.  This
was done at the time in favour of getting local builds working.

Now the time has come to conditionally re-enable that functionality
so we can properly provide binary kmod packages.

  ./configure --with-config=srpm
  make SRPM_DEFINE_KMOD='--define="repo rpmfusion"' srpm-kmod
  mock rebuild spl-kmod-x.y.z-r.el6.src.rpm

One nice benefit of finishing this work is that the generic and
fedora spl-kmod spec files can be merged again.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
10 years agoFix KMC_OFFSLAB type caches
Brian Behlendorf [Fri, 19 Jul 2013 21:39:35 +0000 (14:39 -0700)]
Fix KMC_OFFSLAB type caches

Because spl_slab_size() was always returning -ENOSPC for caches of
type KMC_OFFSLAB the cache could never be created.  Additionally
the slab size is rounded up to a page which is what kv_alloc()
expects.  The kv_alloc() code will minimally allocate a page,
in the KMC_OFFSLAB case this could be reduced.

The basic regression tests kmem:slab_small, kmem:slab_large,
and kmem:slab_align regression were updated to test KMC_OFFSLAB.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ying Zhu <casualfisher@gmail.com>
Closes #266

10 years agoReturn -1 for generic kmem cache shrinker
Brian Behlendorf [Tue, 23 Jul 2013 22:52:11 +0000 (15:52 -0700)]
Return -1 for generic kmem cache shrinker

It has been observed that it's possible to get in a state where
shrink_slabs() will spin repeated invoking the generic kmem cache
shrinker.  It fails to detect it's not making forward progress
reclaiming from the cache and doesn't give up.  To ensure this
never occurs we unconditionally return -1 after reclaiming what
we can.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <ryao@gentoo.org>
Closes zfsonlinux/zfs#1276
Closes zfsonlinux/zfs#1598
Closes zfsonlinux/zfs#1432

10 years agoModify gethrestime to use current_kernel_time()
James H [Sat, 13 Jul 2013 20:25:04 +0000 (21:25 +0100)]
Modify gethrestime to use current_kernel_time()

This allows us to get nanosecond resolution. It also means
we use the same time source as utimensat(now) etc.

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

10 years agoImprove build instructions
Brian Behlendorf [Thu, 11 Jul 2013 23:07:15 +0000 (16:07 -0700)]
Improve build instructions

Make it clear that when building directly from the Git tree
the configure script must be manually generated by running the
autogen.sh script.  This requires that the GNU autotools packages
be installed for your distribution.

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

10 years agoFix bogus kmem leak warning
Brian Behlendorf [Wed, 10 Jul 2013 22:04:07 +0000 (15:04 -0700)]
Fix bogus kmem leak warning

Commit 5c7a036 correctly relocated the creation of a taskq
and the registraction of the kmem_cache_shrinker after the
initialization of the kmem tracking code.  However, the
cleanup of these structures was not done before the leak
checks in spl_kmem_fini().  This resulted in an incorrect
'kmem leaked' warning even though there was no actual leak.

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

10 years agoFix --enable-debug-kmem-tracking option
Brian Behlendorf [Wed, 3 Jul 2013 17:14:35 +0000 (10:14 -0700)]
Fix --enable-debug-kmem-tracking option

This code has gotten something stale and no longer builds cleanly
against modern kernels.  The two issues addressed here are as
follows:

* The hlist_*_rcu interfaces in the kernel have been relatively
  unstable.  Since this isn't performance critical code just use
  the long standing hlist_* variants.

* In older kernels the hash_ptr() function takes a 'void *' but
  in newer kernels it expects a 'const void *'.  To silence the
  compiler warnings about this explicitly cast it to a 'void *'.
  The memset function is a similar case but it always expects
  a 'void *'.

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

10 years agoMerge branch 'linux-3.10'
Brian Behlendorf [Mon, 8 Jul 2013 22:26:59 +0000 (15:26 -0700)]
Merge branch 'linux-3.10'

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

10 years agoLinux 3.10 compat: Do not rely on struct proc_dir_entry definition
Richard Yao [Wed, 3 Jul 2013 20:34:52 +0000 (16:34 -0400)]
Linux 3.10 compat: Do not rely on struct proc_dir_entry definition

Linux kernel commit torvalds/linux#59d8053f moved the definition of
struct proc_dir_entry from include/linux/proc_fs.h to the private
header fs/proc/internal.h. The SPL relied on that to map Solaris'
kstat to entries in /proc/spl/kstat.

Since the proc_dir_entry structure is now private the only safe
thing to do is wrap the opaque proc handle with our own structure.
This actually ends up simplify the code and is good because it
moves us away from depending on implementation details of /proc.

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