Add ability to override kpkg and kdevpkg variables

This change adds the ability for a user to potentially pass in the
'require_kpkg' option and/or the 'require_kdevpkg' option to rpmbuild
and override the default values that would otherwise be assigned to kpkg
and kdevpkg. This is useful, for example, if one wants to build packages
based on a kernel other than the default (i.e. a debug kernel).

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Ignore slab cache age and delay in direct reclaim

When memory pressure triggers direct memory reclaim, a slab's age and
delay should not prevent it from being freed. This patch ensures these
values are ignored, allowing an empty slab to be freed in this code path
no matter the value of it's age and delay.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Throttle number of freed slabs based on nr_to_scan

Previously, the SPL tried to maintain Solaris semantics by freeing all
available (empty) slabs from its slab caches when the shrinker was
called. This is not desirable when running on Linux. To make the SPL
shrinker more Linux friendly, the actual number of freed slabs from
each of the slab caches is now derived from nr_to_scan and
skc_slab_objs.

Signed-off-by: Prakash Surya <surya1@llnl.gov>

Conflicts:

	module/spl/spl-kmem.c
Ensure a minimum of one slab is reclaimed

To minimize the chance of triggering an OOM during direct reclaim.
The kmem caches have been improved to make a best effort to reclaim
at least one slab when a reclaim function is registered.  This helps
avoid the case where objects are released but they are spread over
multiple slabs so no memory gets reclaimed.

Care has been taken to avoid deadlocking if the reclaim function
is unable to make forward progress.  Additionally, the reclaim
function may be skipped entirely if there are already free slabs
which can be safely reaped.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ensure direct reclaim forward progress

The Linux direct reclaim path uses this out of band value to
determine if forward progress is being made.  Normally this is
incremented by kmem_freepages() which is part of the various
Linux slab implementations.  However, we are using none of that
infrastructure we're responsible for incrementing this count.

If no forward progress is detected and a subsequent allocation
fails the OOM killer will be invoked.  If there was forward
progress additional reclaim will be attempted via the page
cache and registerd shrinker until the allocation succeeds.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Add SPLAT test to exercise slab direct reclaim

This change adds a test case to the SPLAT suite to test the direct
memory reclaim functionality of the SPL slab implementation. Ideally,
all empty slabs should be able to be reclaimed quickly if the system is
under memory pressure. The new tests attempts to create these empty
slabs, create memory pressure, and then checks to ensure the slabs are
being reclaimed.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Remove ddi_create_minor_node() and related functions

A build failure was observed on Gentoo Hardened with Linux 3.2.11. The failure
is triggered by the GCC PaX plugin upon seeing a const pointer point to a
structure that is modified through a non-const pointer in
ddi_create_minor_node(). In specific, ddi_create_minor_node() has `struct
file_operations *fops;` on the stack. It is assigned a pointer from an
allocaton. Next `cdev->ops = fops` is done, where cdev->ops is of type `const
struct file_operations *`. Finally, `fops->owner = mod` is done, which triggers
the build failure. Modifying the code to move the assignment after the writes
is insufficient to address this and upon inspection, nothing appears to rely on
this code, so this patch removes it.

This closes issue #109.

Signed-off-by: Richard Yao <ryao@cs.stonybrook.edu>
Modify KM_PUSHPAGE and KM_SLEEP to use GFP_NOIO

The resolution of issue #31 made KM_PUSHPAGE imply GFP_NOFS to avoid
situations where filesystem operations holding locks depending upon
additional filesystem operations that also held those locks. This works
for datasets, but unfortunately, swap on zvols encounters many of the
same deadlocks that filesystem operations encountered before this
change. As such, it is appropriate to modify KM_PUSHPAGE to use
GFP_NOIO.

In addition, KM_SLEEP used GFP_KERNEL, which is not intended for
filesystem code. This lead to the use of PF_MEMALLOC to solve a deadlock
in commit zfsonlinux/zfs@e3822ceb31dc0b5bdecd5a1b355c14860a3bca9e. This
has had the side effect of drawing pages from the ZONE_DMA, which
contribute to panics from the depletion of pages in ZONE_DMA. Further
deadlocks were observed in swap on zvols. It was observed that flipping
allocations from KM_SLEEP to KM_PUSHPAGE in the DMU enabled swap to
function properly, which suggests that the use of GFP_NOIO in KM_SLEEP
is necessary for swap on zvols to function properly.