]> git.proxmox.com Git - mirror_spl.git/log
mirror_spl.git
13 years agoLinux 2.6.35 compat: filp_fsync() dropped 'stuct dentry *'
Brian Behlendorf [Wed, 14 Jul 2010 18:26:54 +0000 (11:26 -0700)]
Linux 2.6.35 compat: filp_fsync() dropped 'stuct dentry *'

The prototype for filp_fsync() drop the unused argument 'stuct dentry *'.
I've fixed this by adding the needed autoconf check and moving all of
those filp related functions to file_compat.h.  This will simplify
handling any further API changes in the future.

13 years agoProposed fix for low memory ZFS deadlocks
Brian Behlendorf [Wed, 14 Jul 2010 04:30:56 +0000 (21:30 -0700)]
Proposed fix for low memory ZFS deadlocks

Deadlocks in the zvol were observed when one of the ZFS threads
performing IO trys to allocate memory while the system is low
on memory.  The low memory condition causes dirty pages to be
synced to the zvol but this can't progress because the original
thread is blocked waiting on a memory allocation.  Thus we end
up deadlocking.

A proper solution proposed by Wizeman is to change KM_SLEEP from
GFP_KERNEL top GFP_NOFS.  This will prevent the memory allocation
which is trying to allocate memory from forcing a sync to the
zvol in shrink_page_list()->pageout().

The down side to all of this is that we are using a pretty big
hammer by changing KM_SLEEP.  This change means ALL of the zfs
memory allocations will be until to trigger dirty data to be
synced.  The caller still should be able to reclaim memory from
the various slab caches.  We will be totally dependent of other
kernel processes which happen to be running and a small number
of asynchronous reclaim threads to trigger the reclaim of dirty
data pages.  This should be OK but I think we may see some
slightly longer allocation times when under memory pressure.

We shall see.

13 years agoAdd __divdi3(), remove __udivdi3() kernel dependency
Brian Behlendorf [Mon, 12 Jul 2010 19:38:34 +0000 (12:38 -0700)]
Add __divdi3(), remove __udivdi3() kernel dependency

Up until now no SPL consumer attempted to perform signed 64-bit
division so there was no need to support this.  That has now
changed so I adding 64-bit division support for 32-bit platforms.
The signed implementation is based on the unsigned version.

Since the have been several bug reports in the past concerning
correct 64-bit division on 32-bit platforms I added some long
over due regression tests.  Much to my surprise the unsigned
64-bit division regression tests failed.

This was surprising because __udivdi3() was implemented by simply
calling div64_u64() which is provided by the kernel.  This meant
that the linux kernels 64-bit division algorithm on 32-bit platforms
was flawed.  After some investigation this turned out to be exactly
the case.

Because of this I was forced to abandon the kernel helper and
instead to fully implement 64-bit division in the spl.  There are
several published implementation out there on how to do this
properly and I settled on one proposed in the book Hacker's Delight.
Their proposed algoritm is freely available without restriction
and I have just modified it to be linux kernel friendly.

The update implementation now passed all the unsigned and signed
regression tests.  This should be functional, but not fast, which is
good enough for out purposes.  If you want fast too I'd strongly
suggest you upgrade to a 64-bit platform.  I have also reported the
kernel bug and we'll see if we can't get it fixed up stream.

13 years agoUpdate config.guess to recognize additional distros
Brian Behlendorf [Fri, 2 Jul 2010 21:41:54 +0000 (14:41 -0700)]
Update config.guess to recognize additional distros

The following distros were added: redhat, fedora, debian,
ubuntu, sles, slackware, and gentoo.

13 years agoAllow config/build to work with autoconf-2.65
Lars Johannsen [Thu, 1 Jul 2010 08:39:32 +0000 (10:38 +0159)]
Allow config/build to work with autoconf-2.65

As of autoconf-2.65 the AC_LANG_SOURCE source macro no longer
includes the confdef.h results when expanded.  To handle this
simply explicitly include confdef.h in conftest.c.  This will
cause two copies to of confdef.h to be added to the test for
earlier autoconf versions but this is not harmful.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoRequire gawk the usermode helper fails with awk
Brian Behlendorf [Thu, 1 Jul 2010 23:20:11 +0000 (16:20 -0700)]
Require gawk the usermode helper fails with awk

For some reason when awk invoked by the usermode helper the command
always fails.  Interestingly gawk does not suffer from this problem
which is why I never observed this failure since the distro I tested
with all had gawk installed instead of awk.  Anyway, the simplest
thing to do here is to just make gawk mandatory.  I've added a
configure check for gawk specifically and have updated the command
to call gawk not awk.

13 years agoAdd configure check for user_path_dir()
Brian Behlendorf [Thu, 1 Jul 2010 20:37:43 +0000 (13:37 -0700)]
Add configure check for user_path_dir()

I didn't notice at the time but user_path_dir() was not introduced
at the same time as set_fs_pwd() change.  I had lumped the two
together but in fact user_path_dir() was introduced in 2.6.27 and
set_fs_pwd() taking 2 args was introduced in 2.6.25.  This means
builds against 2.6.25-2.6.26 kernels were broken.

To fix this I've added a check for user_path_dir() and no longer
assume that if set_fs_pwd() takes 2 args then user_path_dir() is
also available.

13 years agoUse $target_cpu instead of `arch`
Brian Behlendorf [Thu, 1 Jul 2010 20:27:30 +0000 (13:27 -0700)]
Use $target_cpu instead of `arch`

We should not be using arch for a few reasons.  First off it might
not be installed on their system, and secondly they may be trying
to cross-compile.

13 years agoCheck sourcelink is set before passing to readlink
Brian Behlendorf [Thu, 1 Jul 2010 20:25:34 +0000 (13:25 -0700)]
Check sourcelink is set before passing to readlink

When no source was found in any of the expected paths treat
this as fatal and provide the user with a hint as to what
they should do.

13 years agoImplementation of a regression test for TQ_FRONT.
Ned Bass [Thu, 1 Jul 2010 00:34:57 +0000 (17:34 -0700)]
Implementation of a regression test for TQ_FRONT.

Use 3 threads and 8 tasks.  Dispatch the final 3 tasks with TQ_FRONT.
The first three tasks keep the worker threads busy while we stuff the
queues.  Use msleep() to force a known execution order, assuming
TQ_FRONT is properly honored.  Verify that the expected completion
order occurs.

The splat_taskq_test5_order() function may be useful in more than
one test.  This commit generalizes it by renaming the function to
splat_taskq_test_order() and adding a name argument instead of
assuming SPLAT_TASKQ_TEST5_NAME as the test name.

The documentation for splat taskq regression test #5 swaps the two required
completion orders in the diagram.  This commit corrects the error.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoInitialize the /dev/splatctl device buffer
Ned Bass [Thu, 1 Jul 2010 17:12:57 +0000 (10:12 -0700)]
Initialize the /dev/splatctl device buffer

On open() and initialize the buffer with the SPL version string.  The
user space splat utility expects to find the SPL version string when
it opens and reads from /dev/splatctl.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoImplementation of the TQ_FRONT flag.
Ned Bass [Thu, 1 Jul 2010 17:07:51 +0000 (10:07 -0700)]
Implementation of the TQ_FRONT flag.

Adds a task queue to receive tasks dispatched with TQ_FRONT.  Worker
threads pull tasks from this high priority queue before the default
pending queue.

Executing tasks out of FIFO order potentially breaks taskq_lowest_id()
if we do not preserve the ordering of the work list by taskqid.
Therefore, instead of always appending to the work list, we search for
the appropriate place to insert a task.  The common case is to append
to the list, so we make this operation efficient by searching the work
list in reverse order.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13 years agoRemove AC_DEFINE for DEBUG/NDEBUG
Brian Behlendorf [Thu, 1 Jul 2010 16:40:29 +0000 (09:40 -0700)]
Remove AC_DEFINE for DEBUG/NDEBUG

Whoops, I momentarilly forgot I had explicitly set these as CC
options so dependent packages which need to include spl_config.h
would not end up having these defined which can result in
accidentally hanging debug enabled at best, or a build failure
at worst.

13 years agoOnly make compiler warnings fatal with --enable-debug
Brian Behlendorf [Thu, 1 Jul 2010 00:05:36 +0000 (17:05 -0700)]
Only make compiler warnings fatal with --enable-debug

While in theory I like the idea of compiler warnings always being
fatal.  In practice this causes problems when small harmless errors
cause build failures for end users.  To handle this I've updated
the build system such that -Werror is only used when --enable-debug
is passed to configure.  This is how I always build when developing
so I'll catch all build warnings and end users will not get stuck
by minor issues.

13 years agoLinux-2.6.33 compat, O_DSYNC flag added
Brian Behlendorf [Wed, 30 Jun 2010 17:47:36 +0000 (10:47 -0700)]
Linux-2.6.33 compat, O_DSYNC flag added

Prior to linux-2.6.33 only O_DSYNC semantics were implemented and
they used the O_SYNC flag.  As of linux-2.6.33 this behavior was
properly split in to O_SYNC and O_DSYNC respectively.

13 years agoLinux-2.6.33 compat, .ctl_name removed from struct ctl_table
Brian Behlendorf [Wed, 30 Jun 2010 17:36:20 +0000 (10:36 -0700)]
Linux-2.6.33 compat, .ctl_name removed from struct ctl_table

As of linux-2.6.33 the ctl_name member of the ctl_table struct
has been entirely removed.  The upstream code has been updated
to depend entirely on the the procname member.  To handle this
all references to ctl_name are wrapped in a CTL_NAME macro which
simply expands to nothing for newer kernels.  Older kernels are
supported by having it expand to .ctl_name = X just as before.

13 years agoLinux-2.6.33 compat, check <generated/utsrelease.h> for UTS_RELEASE
Brian Behlendorf [Wed, 30 Jun 2010 16:47:57 +0000 (09:47 -0700)]
Linux-2.6.33 compat, check <generated/utsrelease.h> for UTS_RELEASE

It seems the upstream community moved the definition of UTS_RELEASE
yet again as of linux-2.6.33.  Update the build system to check in
all three possible locations where your kernel version may be defined.

$kernelbuild/include/linux/version.h
$kernelbuild/include/linux/utsrelease.h
$kernelbuild/include/generated/utsrelease.h

13 years agoAdd basic README
Brian Behlendorf [Tue, 29 Jun 2010 21:13:07 +0000 (14:13 -0700)]
Add basic README

A simple README with a short summary of the project and a link
directing people to the online documentation.

13 years agoTreat mutex->owner as volatile
Brian Behlendorf [Mon, 28 Jun 2010 19:48:20 +0000 (12:48 -0700)]
Treat mutex->owner as volatile

When HAVE_MUTEX_OWNER is defined and we are directly accessing
mutex->owner treat is as volative with the ACCESS_ONCE() helper.
Without this you may get a stale cached value when accessing it
from different cpus.  This can result in incorrect behavior from
mutex_owned() and mutex_owner().  This is not a problem for the
!HAVE_MUTEX_OWNER case because in this case all the accesses
are covered by a spin lock which similarly gaurentees we will
not be accessing stale data.

Secondly, check CONFIG_SMP before allowing access to mutex->owner.
I see that for non-SMP setups the kernel does not track the owner
so we cannot rely on it.

Thirdly, check CONFIG_MUTEX_DEBUG when this is defined and the
HAVE_MUTEX_OWNER is defined surprisingly the mutex->owner will
not be cleared on mutex_exit().  When this is the case the SPL
needs to make sure to do it to ensure MUTEX_HELD() behaves as
expected or you will certainly assert in mutex_destroy().

Finally, improve the mutex regression tests.  For mutex_owned() we
now minimally check that it behaves correctly when checked from the
owner thread or the non-owner thread.  This subtle behaviour has bit
me before and I'd like to catch it early next time if it reappears.

As for mutex_owned() regression test additonally verify that
mutex->owner is always cleared on mutex_exit().

13 years agoFix subtle race in threads test case
Brian Behlendorf [Mon, 28 Jun 2010 19:34:20 +0000 (12:34 -0700)]
Fix subtle race in threads test case

The call to wake_up() must be moved under the spin lock because
once we drop the lock 'tp' may no longer be valid because the
creating thread has exited.  This basic thread implementation
was correct, this was simply a flaw in the test case.

13 years agoAccept but ignore TASKQ_DC_BATCH and TQ_FRONT
Brian Behlendorf [Mon, 28 Jun 2010 18:39:43 +0000 (11:39 -0700)]
Accept but ignore TASKQ_DC_BATCH and TQ_FRONT

For the moment the SPL accepts the TASKQ_DC_BATCH and TQ_FRONT
flags however they get silently ignored.  This is harmless for
the moment but it does need to be implemented at some point.

13 years agoAdd kmem_vasprintf function
Brian Behlendorf [Thu, 24 Jun 2010 16:41:59 +0000 (09:41 -0700)]
Add kmem_vasprintf function

We might as well have both asprintf() variants.  This allows us
to safely pass a va_list through several levels of the stack
using va_copy() instead of va_start().

13 years agoRevert "Support TQ_FRONT flag used by taskq_dispatch()"
Brian Behlendorf [Mon, 21 Jun 2010 17:19:44 +0000 (10:19 -0700)]
Revert "Support TQ_FRONT flag used by taskq_dispatch()"

This reverts commit eb12b3782c94113d2d40d2da22265dc4111a672b.

13 years agoUpdate warnings in kmem debug code
Brian Behlendorf [Wed, 16 Jun 2010 22:57:04 +0000 (15:57 -0700)]
Update warnings in kmem debug code

This fix was long overdue.  Most of the ground work was laid long
ago to include the exact function and line number in the error message
which there was an issue with a memory allocation call.  However,
probably due to lack of time at the moment that informatin never
made it in to the error message.  This patch fixes that and trys
to standardize the kmem debug messages as well.

13 years agoAdd missing header util/sscanf.h
Brian Behlendorf [Mon, 14 Jun 2010 21:20:31 +0000 (14:20 -0700)]
Add missing header util/sscanf.h

13 years agoInclude kstat.h from kmem.h
Brian Behlendorf [Mon, 14 Jun 2010 21:18:48 +0000 (14:18 -0700)]
Include kstat.h from kmem.h

It turns out Solaris incidentally includes kstat.h from kmem.h.  As
a side effect of this certain higher level .c files which should
explicitly include kstat.h don't because they happen to get it
via kmem.h.  To make like easier for everyone I do the same.

13 years agoSupport TQ_FRONT flag used by taskq_dispatch()
Brian Behlendorf [Fri, 11 Jun 2010 21:53:23 +0000 (14:53 -0700)]
Support TQ_FRONT flag used by taskq_dispatch()

Allow taskq_dispatch() to insert work items at the head of the
queue instead of just the tail by passing the TQ_FRONT flag.

13 years agoMinor cleanup and Solaris API additions.
Brian Behlendorf [Fri, 11 Jun 2010 21:57:49 +0000 (14:57 -0700)]
Minor cleanup and Solaris API additions.

Minor formatting cleanups.

API additions:
* {U}INT8_{MIN,MAX}, {U}INT16_{MIN,MAX} macros.
* id_t typedef
* ddi_get_lbolt(), ddi_get_lbolt64() functions.

13 years agoAdd kmem_asprintf(), strfree(), strdup(), and minor cleanup.
Brian Behlendorf [Fri, 11 Jun 2010 21:48:18 +0000 (14:48 -0700)]
Add kmem_asprintf(), strfree(), strdup(), and minor cleanup.

This patch adds three missing Solaris functions: kmem_asprintf(), strfree(),
and strdup().  They are all implemented as a thin layer which just calls
their Linux counterparts.  As part of this an autoconf check for kvasprintf
was added because it does not appear in older kernels.  If the kernel does
not provide it then spl-generic implements it.

Additionally the dead DEBUG_KMEM_UNIMPLEMENTED code was removed to clean
things up and make the kmem.h a little more readable.

13 years agoAdd xuio_* structures and typedefs.
Brian Behlendorf [Fri, 11 Jun 2010 22:02:24 +0000 (15:02 -0700)]
Add xuio_* structures and typedefs.

Add the basic xuio structure and typedefs for Solaris style zero copy.
There's a decent chance this will not be the way I handle this on Linux
but providing the basic types simplifies things for now.

13 years agoStub out additional missing headers
Brian Behlendorf [Fri, 11 Jun 2010 21:45:42 +0000 (14:45 -0700)]
Stub out additional missing headers

13 years agoCleanly split Linux proc.h (fs) from conflicting Solaris proc.h (process)
Brian Behlendorf [Fri, 11 Jun 2010 21:37:46 +0000 (14:37 -0700)]
Cleanly split Linux proc.h (fs) from conflicting Solaris proc.h (process)

Under linux the proc.h header is for the /proc filesystem, and under
Solaris the proc/h header if for processes.  This patch correctly
moves the Linux proc functionality in a linux/proc_compat.h header
and leaves the sys/proc.h for use by Solaris.  Minor updates were
required to all the call sites where it was included of course.

13 years agoUpdate META to version 0.5.0
Brian Behlendorf [Fri, 11 Jun 2010 21:42:16 +0000 (14:42 -0700)]
Update META to version 0.5.0

13 years agoStack overflow on 64-bit modulus operations on 32-bit architectures.
Alex Zhuravlev [Thu, 3 Jun 2010 05:01:14 +0000 (22:01 -0700)]
Stack overflow on 64-bit modulus operations on 32-bit architectures.

Running 'zpool create' on a 32-bit machine with an SPL compiled with
gcc 4.4.4 led to a stack overlow.  This turned out to be due to some
sort of 'optimization' by gcc:

uint64_t __umoddi3(uint64_t dividend, uint64_t divisor)
{
   return dividend - divisor * (dividend / divisor);
}

This code was supposed to be using __udivdi3 to implement /, but gcc
instead implemented it via __umoddi3 itself.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
14 years agoMinor 32-bit fix cast to hrtime_t before the mutliply.
Brian Behlendorf [Sun, 23 May 2010 16:51:17 +0000 (09:51 -0700)]
Minor 32-bit fix cast to hrtime_t before the mutliply.

It's important to cast to hrtime_t before doing the multiply because
the ts.tv_sec type is only 32-bits and we need to promote it to 64-bits.

14 years agoRefresh autogen.sh products with automake 1.11.1.
Brian Behlendorf [Fri, 21 May 2010 22:52:06 +0000 (15:52 -0700)]
Refresh autogen.sh products with automake 1.11.1.

14 years agoRe-Prep for 0.4.9 tag with a few more fixes and updated ChangeLog
Brian Behlendorf [Fri, 21 May 2010 21:17:44 +0000 (14:17 -0700)]
Re-Prep for 0.4.9 tag with a few more fixes and updated ChangeLog

14 years agoMinor spec file cleanup for RHEL6 package dependency.
Brian Behlendorf [Fri, 21 May 2010 18:53:49 +0000 (11:53 -0700)]
Minor spec file cleanup for RHEL6 package dependency.

14 years agoSimplify rwlock implementation.
Brian Behlendorf [Thu, 20 May 2010 21:20:34 +0000 (14:20 -0700)]
Simplify rwlock implementation.

Remove RW_COUNT() from the rwlock implementation.  The idea was that it
could be used as a generic wrapper for getting at the internal state
of a rwlock.  While a good idea it's proven problematic to keep it
correct for multiple archs and internal implementation changes.  In
short it hasn't been worth the trouble.

With that and simplicity in mind things have been updated to use the
rwsem_is_locked() function instead of RW_COUNT for the RW_*_HELD()
functions.  As for rw_upgrade() it remains only implemented for
the generic rwsem implemenation.  It remains to be determined if its
worth the effort of adding a custom implementation for each arch.

14 years agoUse KM_NODEBUG macro in preference to __GFP_NOWARN.
Brian Behlendorf [Thu, 20 May 2010 21:16:59 +0000 (14:16 -0700)]
Use KM_NODEBUG macro in preference to __GFP_NOWARN.

14 years agoDisable spl_debug_panic_on_bug by default.
Brian Behlendorf [Thu, 20 May 2010 17:15:51 +0000 (10:15 -0700)]
Disable spl_debug_panic_on_bug by default.

While I may prefer to have the system panic on an SBUG and to get
crash dump for analysis.  I suspect most peoples systems are not
configured from crash dump and the best thing to so is to simply
halt the thread and print an error to the console.  This way they
have a good chance of actually saving the stack trace and debug log.

14 years agoAdjust 'large' object sizes in kmem:slab_large test.
Brian Behlendorf [Thu, 20 May 2010 16:52:37 +0000 (09:52 -0700)]
Adjust 'large' object sizes in kmem:slab_large test.

64K objects are large for a kmem based slab (2M slabs)
1M objects are large for a vmem cased slab (32M slabs)

14 years agoRemove kmem_set_warning() interface replace with __GFP_NOWARN flag.
Brian Behlendorf [Wed, 19 May 2010 23:53:13 +0000 (16:53 -0700)]
Remove kmem_set_warning() interface replace with __GFP_NOWARN flag.

Remove the kmem_set_warning() hack used by the kmem-splat regression
tests with a per-allocation flag called __GFP_NOWARN.  This matches
the lower level linux flag of similar by slightly different function.
The idea is you can then explicitly set this flag on requests where
you know your breaking the max 8k rule but you need/want to do it
anyway.

This is currently used by the regression tests where we intentionally
push things to the limit but don't want the log noise.  Additionally,
we are forced to use it in spl_kmem_cache_create() because by default
NR_CPUS is very large and theres no easy way to handle that.

Finally, I've added a stack_dump() call to the warning when it is
trigger to make to clear exactly where the allocation is taking place.

14 years agoSet default debug log patch to /tmp/spl-log.
Brian Behlendorf [Wed, 19 May 2010 23:17:06 +0000 (16:17 -0700)]
Set default debug log patch to /tmp/spl-log.

Using /tmp/ is a preferable default, it can always be overriden
using the module option on a case-by-case basis.

Additionally standardize some log messages based on the same
default log level used by the kernel.

14 years agoMinor spec file cleanup for srpm case.
Brian Behlendorf [Tue, 18 May 2010 16:18:20 +0000 (09:18 -0700)]
Minor spec file cleanup for srpm case.

Ensure kdevpkg is defined is srpm case before using it to define
the devel_requires macro.  Interestingly this is not an issue for
rpm-4.7.1-4 but it is for rpm-4.4.2.3-18.

14 years agoPrep for 0.4.9 tag, updated META and ChangeLog
Brian Behlendorf [Mon, 17 May 2010 22:47:24 +0000 (15:47 -0700)]
Prep for 0.4.9 tag, updated META and ChangeLog

14 years agoPublic Release Prep
Brian Behlendorf [Mon, 17 May 2010 22:18:00 +0000 (15:18 -0700)]
Public Release Prep

Updated AUTHORS, COPYING, DISCLAIMER, and INSTALL files.  Added
standardized headers to all source file to clearly indicate the
copyright, license, and to give credit where credit is due.

14 years agoAdd 3 missing typedefs.
Brian Behlendorf [Fri, 14 May 2010 16:42:53 +0000 (09:42 -0700)]
Add 3 missing typedefs.

Add processorid_t, pc_t, index_t.

14 years agoAdd console_*printf() functions.
Brian Behlendorf [Fri, 14 May 2010 16:40:52 +0000 (09:40 -0700)]
Add console_*printf() functions.

Add support for the missing console_vprintf() and console_printf()
functions.

14 years agoUse do_posix_clock_monotonic_gettime() as described by comment.
Brian Behlendorf [Fri, 14 May 2010 16:31:22 +0000 (09:31 -0700)]
Use do_posix_clock_monotonic_gettime() as described by comment.

While this does incur slightly more overhead we should be using
do_posix_clock_monotonic_gettime() for gethrtime() as described
by the existing comment.

14 years agoAdd cv_wait_interruptible() function.
Brian Behlendorf [Fri, 14 May 2010 16:24:51 +0000 (09:24 -0700)]
Add cv_wait_interruptible() function.

This is a minor extension to the condition variable API to allow
for reasonable signal handling on Linux.  The cv_wait() function by
definition must wait unconditionally for cv_signal()/cv_broadcast()
before waking it.  This makes it impossible to woken by a signal
such as SIGTERM.  The cv_wait_interruptible() function was added
to handle this case.  It behaves identically to cv_wait() with the
exception that it waits interruptibly allowing a signal to wake it
up.  This means you do need to be careful and check issig() after
waking.

14 years agoDump log from current process when required
Brian Behlendorf [Fri, 23 Apr 2010 22:55:02 +0000 (15:55 -0700)]
Dump log from current process when required

When dumping a debug log first check that it is safe to create
a new thread and block waiting for it.  If we are in an atomic
context or irqs and disabled it is not safe to sleep and we
must write out of the debug log from the current process.

14 years agoAssume TQ_SLEEP when not explicitly specified.
Brian Behlendorf [Fri, 23 Apr 2010 21:39:47 +0000 (14:39 -0700)]
Assume TQ_SLEEP when not explicitly specified.

14 years agoHandle the FAPPEND option in vn_rdwr().
Ricardo Correia [Fri, 23 Apr 2010 19:19:10 +0000 (12:19 -0700)]
Handle the FAPPEND option in vn_rdwr().

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
14 years agoUpdate vn_set_pwd() to allow user|kernal address for filename
Brian Behlendorf [Thu, 22 Apr 2010 19:48:40 +0000 (12:48 -0700)]
Update vn_set_pwd() to allow user|kernal address for filename

During module init spl_setup()->The vn_set_pwd("/") was failing
with -EFAULT because user_path_dir() and __user_walk() both
expect 'filename' to be a user space address and it's not in
this case.  To handle this the data segment size is increased
to to ensure strncpy_from_user() does not fail with -EFAULT.

Additionally, I've added a printk() warning to catch this and
log it to the console if it ever reoccurs.  I thought everything
was working properly here because there consequences of this
failing are subtle and usually non-critical.

14 years agoDisable rw_tryupgrade() for newer kernels
Brian Behlendorf [Tue, 20 Apr 2010 22:16:27 +0000 (15:16 -0700)]
Disable rw_tryupgrade() for newer kernels

For kernels using the CONFIG_RWSEM_GENERIC_SPINLOCK implementation
nothing has changed.  But if your kernel is building with arch
specific rwsems rw_tryupgrade() has been disabled until it can
be implemented correctly.  In particular, the x86 implementation
now leverages atomic primatives for serialization rather than
spinlocks.  So to get this working again it will need to be
implemented as a cmpxchg for x86 and likely something similiar
for other arches we are interested in.  For now it's safest
to simply disable it.

14 years agoAdd support for 'make -s' silent builds
Brian Behlendorf [Fri, 26 Mar 2010 22:21:06 +0000 (15:21 -0700)]
Add support for 'make -s' silent builds

The cleanest way to do this is to set AM_LIBTOOLFLAGS = --silent.  However,
AM_LIBTOOLFLAGS is not honored by automake-1.9.6-2.1 which is what I have
been using.  To cleanly handle this I am updating to automake-1.11-3 which
is why it looks like there is a lot of churn in the Makefiles.

14 years agoAllow spl_config.h to be included by dependant packages (updated)
Brian Behlendorf [Mon, 22 Mar 2010 21:45:33 +0000 (14:45 -0700)]
Allow spl_config.h to be included by dependant packages (updated)

We need dependent packages to be able to include spl_config.h to
build properly.  This was partially solved in commit 0cbaeb1 by using
AH_BOTTOM to #undef common #defines (PACKAGE, VERSION, etc) which
autoconf always adds and cannot be easily removed.  This solution
works as long as the spl_config.h is included before your projects
config.h.  That turns out to be easier said than done.  In particular,
this is a problem when your package includes its config.h using the
-include gcc option which ensures the first thing included is your
config.h.

To handle all cases cleanly I have removed the AH_BOTTOM hack and
replaced it with an AC_CONFIG_HEADERS command.  This command runs
immediately after spl_config.h is written and with a little awk-foo
it strips the offending #defines from the file.  This eliminates
the problem entirely and makes header safe for inclusion.

Also in this change I have removed the few places in the code where
spl_config.h is included.  It is now added to the gcc compile line
to ensure the config results are always available.

Finally, I have also disabled the verbose kernel builds.  If you
want them back you can always build with 'make V=1'.  Since things
are working now they don't need to be on by default.

14 years agoReduce max kmem based slab size
Brian Behlendorf [Thu, 18 Mar 2010 20:39:51 +0000 (13:39 -0700)]
Reduce max kmem based slab size

Allowing MAX_ORDER-1 sized allocations for kmem based slabs have
been observed to result in deadlocks.  To help prvent this limit
max kmem based slab size to MAX_ORDER-3.  Just for the record
callers should not be creating slabs like this, but if they do
we should still handle it as safely as we can.

14 years agoPrep for 0.4.8 tag, updated META and ChangeLog
Brian Behlendorf [Thu, 11 Mar 2010 23:36:50 +0000 (15:36 -0800)]
Prep for 0.4.8 tag, updated META and ChangeLog

14 years agoIgnore unsigned module build products
Brian Behlendorf [Thu, 11 Mar 2010 22:29:17 +0000 (14:29 -0800)]
Ignore unsigned module build products

Along with the addition of signed kernel modules in newer kernel
we have a few new build products we need to ignore.   LKLM has the
whole thread for those interested: http://lkml.org/lkml/2007/2/14/164

14 years agoFix definitions for the unknown distro/installation
Brian J. Murrell [Mon, 8 Mar 2010 23:12:22 +0000 (15:12 -0800)]
Fix definitions for the unknown distro/installation

If the distro/installation really is unsupported (i.e. unknown) we should
not make it look like a known distribution (i.e. RHEL) complete with
dependencies on other RPMs and trying to find kenrel source in the RH
standard location.

Additionally add 'k' prefix for kernel requires for consistency.

14 years agoWhen no kernel source has been pointed to, first attempt to use
Brian J. Murrell [Mon, 8 Mar 2010 22:19:30 +0000 (14:19 -0800)]
When no kernel source has been pointed to, first attempt to use
/lib/modules/$(uname -r)/source.  This will likely fail when building
under a mock (http://fedoraproject.org/wiki/Projects/Mock) chroot
environment since `uname -r` will report the running kernel which
likely is not the kernel in your chroot.  To cleanly handle this
we fallback to using the first kernel in your chroot.

The kernel-devel package which contains all the kernel headers and
a few build products such as Module.symver{s} is all the is required.
Full source is not needed.

14 years agoRemove Module.markers and Module.symver{s} in clean target
Brian Behlendorf [Mon, 8 Mar 2010 21:08:09 +0000 (13:08 -0800)]
Remove Module.markers and Module.symver{s} in clean target

Split 'modules' and 'clean' Makefile targets to allow us to
cleanly remove the Module.* build products with a 'make clean'.

14 years agoLinux 2.6.32 compat, proc_handler() API change
Brian Behlendorf [Thu, 4 Mar 2010 20:14:56 +0000 (12:14 -0800)]
Linux 2.6.32 compat, proc_handler() API change

As of linux-2.6.32 the 'struct file *filp' argument was dropped from
the proc_handle() prototype.  It was apparently unused _almost_
everywhere in the kernel and this was simply cleanup.

I've added a new SPL_AC_5ARGS_PROC_HANDLER autoconf check for this and
the proper compat macros to correctly define the prototypes and some
helper functions.  It's not pretty but API compat changes rarely are.

14 years agosun-misc-gitignore
Ricardo M. Correia [Fri, 8 Jan 2010 01:19:49 +0000 (01:19 +0000)]
sun-misc-gitignore

Add .gitignore files.

Signed-off-by: Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
14 years agosun-fix-whitespace
Ricardo M. Correia [Thu, 7 Jan 2010 16:58:30 +0000 (16:58 +0000)]
sun-fix-whitespace

Whitespace fixes.

Signed-off-by: Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
14 years agosun-fix-panic-str
Ricardo M. Correia [Thu, 7 Jan 2010 16:58:29 +0000 (16:58 +0000)]
sun-fix-panic-str

Fix panic() string, which was being used as a format string, instead of an already-formatted string.

Signed-off-by: Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
14 years agoAdded splat taskq task ordering test case.
Brian Behlendorf [Tue, 5 Jan 2010 21:34:09 +0000 (13:34 -0800)]
Added splat taskq task ordering test case.

This test case verifies the correct behavior of taskq_wait_id().
In particular it ensure the the following two cases are handled
properly:

1) Task ids larger than the waited for task id can run and
   complete as long as there is an available worker thread.
2) All task ids lower than the waited one must complete before
   unblocking even if the waited task id itself has completed.

14 years agoOptimize lowest outstanding taskqid calculation in taskq_lowest_id()
Brian Behlendorf [Mon, 4 Jan 2010 23:52:26 +0000 (15:52 -0800)]
Optimize lowest outstanding taskqid calculation in taskq_lowest_id()

In the initial version of taskq_lowest_id() the entire pending and
work list was locked under the tq->tq_lock to determine the lowest
outstanding taskqid.  At the time this done because I was rushed
and wanted to make sure it was right... fast was secondary.  Well now
fast is important too so I carefully thought through the pending
and work list management and convinced myself it is safe and correct
to simply check the first entry.  I added a large comment to the source
to explain this.  But basically as long as we are careful to ensure the
pending and work list stay sorted this is safe and fast.

The motivation for this chance was that I was observing as much as
10% of the total CPU time go to waiting on the tq->tq_lock when the
pending list was long.  This resolves that problems and frees up
that CPU time for something useful.

14 years agoStrip __GFP_ZERO from kmalloc it is not available for older kernels.
Brian Behlendorf [Wed, 23 Dec 2009 20:57:10 +0000 (12:57 -0800)]
Strip __GFP_ZERO from kmalloc it is not available for older kernels.

This is needed to avoid a BUG_ON() on RHEL5.4 kernel 2.6.18-164.6.1,
since __GFP_ZERO is not a valid flag for kmalloc().

14 years agoFix kmem:slab_overcommit regression test locking
Brian Behlendorf [Wed, 23 Dec 2009 20:46:11 +0000 (12:46 -0800)]
Fix kmem:slab_overcommit regression test locking

This regression test could crash in splat_kmem_cache_test_reclaim()
due to a race between the slab relclaim and the normal exiting of
the thread.  Specifically, the kct structure could be free'd by
the thread performing the allocations while the reclaim function
was also working on that's threads kct structure.  The simplest
fix is to extend the kcp->kcp_lock over the reclaim to prevent
the kct from being freed.  A better fix would be to ref count
these structures, but since is just a regression this locking
change is enough.  Surprisingly this was only observed commonly
under RHEL5.4 but all platform could have hit this.

14 years agoCheck for changed gaurd macro in 2.6.28+ for rwsem implementation.
Brian Behlendorf [Thu, 17 Dec 2009 19:57:44 +0000 (11:57 -0800)]
Check for changed gaurd macro in 2.6.28+ for rwsem implementation.

As part of the 2.6.28 cleanup which moved all the linux/include/asm/
headers in to linux/arch, the guard headers for many header files
changed.  The i386 rwsem implementation keys off this header to
ensure the internal members of the rwsem structure are interpreted
correctly.  This change checks for the new guard macro in addition
to the only one, the implementation of the rwsem has not changed
for i386 so this is safe and correct.

14 years agoAdd skc_flags and full header to /proc/spl/kmem/slab.
Brian Behlendorf [Fri, 11 Dec 2009 19:20:08 +0000 (11:20 -0800)]
Add skc_flags and full header to /proc/spl/kmem/slab.

14 years agoSplat vnode tests must return negative error codes.
Brian Behlendorf [Thu, 10 Dec 2009 23:06:07 +0000 (15:06 -0800)]
Splat vnode tests must return negative error codes.

I must have been in a hurry when I wrote the vnode regression tests
because the error code handling is not correct.  The Solaris vnode
API returns positive errno's, these need to be converted to negative
errno's for Linux before being passed back to user space.  Otherwise
the test hardness with report the failure but errno will not be set
with the correct error code.

Additionally tests 3, 4, 6, and 7 may fail in the test file already
exists.  To avoid false positives a user mode helper has added to
remove the test files in /tmp/ before running the actual test.

14 years agoAtomic64 compatibility for 32-bit systems without kernel support.
Brian Behlendorf [Fri, 4 Dec 2009 23:54:12 +0000 (15:54 -0800)]
Atomic64 compatibility for 32-bit systems without kernel support.

This patch is another step towards updating the code to handle the
32-bit kernels which I have not been regularly testing.  This changes
do not really impact the common case I'm expected which is the latest
kernel running on an x86_64 arch.

Until the linux-2.6.31 kernel the x86 arch did not have support for
64-bit atomic operations.  Additionally, the new atomic_compat.h support
for this case was wrong because it embedded a spinlock in the atomic
variable which must always and only be 64-bits total.  To handle these
32-bit issues we now simply fall back to the --enable-atomic-spinlock
implementation if the kernel does not provide the 64-bit atomic funcs.

The second issue this patch addresses is the DEBUG_KMEM assumption that
there will always be atomic64 funcs available.  On 32-bit archs this may
not be true, and actually that's just fine.  In that case the kernel will
will never be able to allocate more the 32-bits worth anyway.  So just
check if atomic64 funcs are available, if they are not it means this
is a 32-bit machine and we can safely use atomic_t's instead.

14 years agoCorrectly handle division on 32-bit RHEL5 systems by returning dividend.
Brian Behlendorf [Tue, 1 Dec 2009 23:53:28 +0000 (15:53 -0800)]
Correctly handle division on 32-bit RHEL5 systems by returning dividend.

14 years agoWhen using x86 specific rwsem correctly intepret rwsem->count.
Brian Behlendorf [Tue, 1 Dec 2009 23:47:27 +0000 (15:47 -0800)]
When using x86 specific rwsem correctly intepret rwsem->count.

14 years agoOnly run the kmem overcommit test on 64-bit systems.
Brian Behlendorf [Tue, 1 Dec 2009 19:40:47 +0000 (11:40 -0800)]
Only run the kmem overcommit test on 64-bit systems.

14 years agoAdd missing atomic64 compat helpers for 32-bit systems.
Brian Behlendorf [Tue, 1 Dec 2009 18:15:27 +0000 (10:15 -0800)]
Add missing atomic64 compat helpers for 32-bit systems.

The use of these functions was added with the recent atomic work
and not tested on 32-bit systems.  Add the missing compat functions:
atomic64_inc, atomic64_dec, atomic64_add_return, atomic64_sub_return,
atomic64_inc_return, atomic64_dec_return.

14 years agoType long expected explicitly cast for 32-bit systems.
Brian Behlendorf [Tue, 1 Dec 2009 18:14:01 +0000 (10:14 -0800)]
Type long expected explicitly cast for 32-bit systems.

14 years agospl-modules-devel package must depend on the exact version of kernel
Brian Behlendorf [Tue, 24 Nov 2009 23:24:36 +0000 (15:24 -0800)]
spl-modules-devel package must depend on the exact version of kernel
devel package it was built against.

14 years agoAdd 'srpm' --with-config option for creation of spec files.
Brian Behlendorf [Tue, 24 Nov 2009 22:21:45 +0000 (14:21 -0800)]
Add 'srpm' --with-config option for creation of spec files.

14 years agoAdd chaos5 and rhel6 macro's to the spl-modules.spec.in
Brian Behlendorf [Tue, 24 Nov 2009 21:15:35 +0000 (13:15 -0800)]
Add chaos5 and rhel6 macro's to the spl-modules.spec.in

14 years agoPrep for 0.4.7 tag, updated META and ChangeLog.
Brian Behlendorf [Sat, 21 Nov 2009 00:52:29 +0000 (16:52 -0800)]
Prep for 0.4.7 tag, updated META and ChangeLog.

14 years agoEnsure *.order and *.markers build products are removed by distclean rule.
Brian Behlendorf [Sat, 21 Nov 2009 00:01:00 +0000 (16:01 -0800)]
Ensure *.order and *.markers build products are removed by distclean rule.

14 years agoEnsure spl_config.h is include in spl-generic.c
Brian Behlendorf [Sun, 15 Nov 2009 23:04:33 +0000 (15:04 -0800)]
Ensure spl_config.h is include in spl-generic.c

14 years agoAlways use the generic mutex_destroy().
Brian Behlendorf [Sun, 15 Nov 2009 23:04:02 +0000 (15:04 -0800)]
Always use the generic mutex_destroy().

14 years agoAdd mutex_enter_nested() as wrapper for mutex_lock_nested().
Brian Behlendorf [Sun, 15 Nov 2009 22:27:15 +0000 (14:27 -0800)]
Add mutex_enter_nested() as wrapper for mutex_lock_nested().

This symbol can be used by GPL modules which use the SPL to handle
cases where a call path takes a two different locks by the same
name.  This is needed to avoid a false positive in the lock checker.

14 years agoLinux 2.6.31 kmem cache alignment fixes and cleanup.
Brian Behlendorf [Fri, 13 Nov 2009 19:12:43 +0000 (11:12 -0800)]
Linux 2.6.31 kmem cache alignment fixes and cleanup.

The big fix here is the removal of kmalloc() in kv_alloc().  It used
to be true in previous kernels that kmallocs over PAGE_SIZE would
always be pages aligned.  This is no longer true atleast in 2.6.31
there are no longer any alignment expectations.  Since kv_alloc()
requires the resulting address to be page align we no only either
directly allocate pages in the KMC_KMEM case, or directly call
__vmalloc() both of which will always return a page aligned address.
Additionally, to avoid wasting memory size is always a power of two.

As for cleanup several helper functions were introduced to calculate
the aligned sizes of various data structures.  This helps ensure no
case is accidentally missed where the alignment needs to be taken in
to account.  The helpers now use P2ROUNDUP_TYPE instead of P2ROUNDUP
which is safer since the type will be explict and we no longer count
on the compiler to auto promote types hopefully as we expected.

Always wnforce minimum (SPL_KMEM_CACHE_ALIGN) and maximum (PAGE_SIZE)
alignment restrictions at cache creation time.

Use SPL_KMEM_CACHE_ALIGN in splat alignment test.

14 years agoRemove __GFP_NOFAIL in kmem and retry internally.
Brian Behlendorf [Thu, 12 Nov 2009 23:11:24 +0000 (15:11 -0800)]
Remove __GFP_NOFAIL in kmem and retry internally.

As of 2.6.31 it's clear __GFP_NOFAIL should no longer be used and it
may disappear from the kernel at any time.  To handle this I have simply
added *_nofail wrappers in the kmem implementation which perform the
retry for non-atomic allocations.

From linux-2.6.31 mm/page_alloc.c:1166
/*
 * __GFP_NOFAIL is not to be used in new code.
 *
 * All __GFP_NOFAIL callers should be fixed so that they
 * properly detect and handle allocation failures.
 *
 * We most definitely don't want callers attempting to
 * allocate greater than order-1 page units with
 * __GFP_NOFAIL.
 */
WARN_ON_ONCE(order > 1);

14 years agoLinux 2.6.31 Compatibility Updates
Brian Behlendorf [Tue, 10 Nov 2009 22:06:57 +0000 (14:06 -0800)]
Linux 2.6.31 Compatibility Updates

SPL_AC_2ARGS_SET_FS_PWD macro updated to explicitly include
linux/fs_struct.h which was dropped from linux/sched.h.

min_wmark_pages, low_wmark_pages, high_wmark_pages macros
introduced in newer kernels.  For older kernels mm_compat.h
was introduced to define them as needed as direct mappings
to per zone min_pages, low_pages, max_pages.

14 years agoPrep for 0.4.6 tag, updated META and ChangeLog.
Brian Behlendorf [Mon, 2 Nov 2009 18:24:12 +0000 (10:24 -0800)]
Prep for 0.4.6 tag, updated META and ChangeLog.

14 years agoAutoconf --enable-debug-* cleanup
Brian Behlendorf [Fri, 30 Oct 2009 20:58:51 +0000 (13:58 -0700)]
Autoconf --enable-debug-* cleanup

Cleanup the --enable-debug-* configure options, this has been pending
for quite some time and I am glad I finally got to it.  To summerize:

1) All SPL_AC_DEBUG_* macros were updated to be a more autoconf
friendly.  This mainly involved shift to the GNU approved usage of
AC_ARG_ENABLE and ensuring AS_IF is used rather than directly using
an if [ test ] construct.

2) --enable-debug-kmem=yes by default.  This simply enabled keeping
a running tally of total memory allocated and freed and reporting a
memory leak if there was one at module unload.  Additionally, it
ensure /proc/spl/kmem/slab will exist by default which is handy.
The overhead is low for this and it should not impact performance.

3) --enable-debug-kmem-tracking=no by default.  This option was added
to provide a configure option to enable to detailed memory allocation
tracking.  This support was always there but you had to know where to
turn it on.  By default this support is disabled because it is known
to badly hurt performence, however it is invaluable when chasing a
memory leak.

4) --enable-debug-kstat removed.  After further reflection I can't see
why you would ever really want to turn this support off.  It is now
always on which had the nice side effect of simplifying the proc handling
code in spl-proc.c.  We can now always assume the top level directory
will be there.

5) --enable-debug-callb removed.  This never really did anything, it was
put in provisionally because it might have been needed.  It turns out
it was not so I am just removing it to prevent confusion.

14 years agoAdd autoconf checks for atomic64_cmpxchg + atomic64_xchg
Brian Behlendorf [Fri, 30 Oct 2009 20:53:17 +0000 (13:53 -0700)]
Add autoconf checks for atomic64_cmpxchg + atomic64_xchg

These functions didn't exist for all archs prior to 2.6.24.  This
patch addes an autoconf test to detect this and add them when needed.
The autoconf check is needed instead of just an #ifndef because in
the most modern kernels atomic64_{cmp}xchg are implemented as in
inline function and not a #define.

14 years agoUse Linux atomic primitives by default.
Brian Behlendorf [Fri, 30 Oct 2009 17:55:25 +0000 (10:55 -0700)]
Use Linux atomic primitives by default.

Previously Solaris style atomic primitives were implemented simply by
wrapping the desired operation in a global spinlock.  This was easy to
implement at the time when I wasn't 100% sure I could safely layer the
Solaris atomic primatives on the Linux counterparts.  It however was
likely not good for performance.

After more investigation however it does appear the Solaris primitives
can be layered on Linux's fairly safely.  The Linux atomic_t type really
just wraps a long so we can simply cast the Solaris unsigned value to
either a atomic_t or atomic64_t.  The only lingering problem for both
implementations is that Solaris provides no atomic read function.  This
means reading a 64-bit value on a 32-bit arch can (and will) result in
word breaking.  I was very concerned about this initially, but upon
further reflection it is a limitation of the Solaris API.  So really
we are just being bug-for-bug compatible here.

With this change the default implementation is layered on top of Linux
atomic types.  However, because we're assuming a lot about the internal
implementation of those types I've made it easy to fall-back to the
generic approach.  Simply build with --enable-atomic_spinlocks if
issues are encountered with the new implementation.

14 years agoI should not have removed these, they are important.
Brian Behlendorf [Tue, 27 Oct 2009 23:17:06 +0000 (16:17 -0700)]
I should not have removed these, they are important.

14 years agoRebase cmn_err on vcmn_err and don't warn about missing \n
Brian Behlendorf [Tue, 27 Oct 2009 22:54:45 +0000 (15:54 -0700)]
Rebase cmn_err on vcmn_err and don't warn about missing \n

The cmn_err/vcmn_err functions are layered on top of the debug
system which usually expects a newline at the end.  However, there
really doesn't need to be a newline there and there in fact should
not be for the CE_CONT case so let's just drop the warning.

Also we make a half-hearted attempt to handle a leading ! which
means only send it to the syslog not the console.  In this case
we just send to the the debug logs and not the console.

14 years agoRemove usage of the __id_u macro for portability.
Brian Behlendorf [Mon, 5 Oct 2009 19:51:58 +0000 (12:51 -0700)]
Remove usage of the __id_u macro for portability.

This macro was removed from the default RPM macro file.  Interestly,
some of the arch specific macro's add it back it based on your distro
but it should not be counted on.  However, __id still exists and its
command line args have historically been fairly stable so we will
directly use %{__id} -un to get the user name.

14 years agoUse kobject_set_name() for increased portability.
Brian Behlendorf [Fri, 2 Oct 2009 23:21:59 +0000 (16:21 -0700)]
Use kobject_set_name() for increased portability.

As of 2.6.25 kobj->k_name was replaced with kobj->name.  Some distros
such as RHEL5 (2.6.18) add a patch to prevent this from being a problem
but other older distros such as SLES10 (2.6.16) have not.  To avoid
the whole issue I'm updating the code to use kobject_set_name() which
does what I want and has existed all the way back to 2.6.11.