aboutsummaryrefslogtreecommitdiffstats
path: root/module/spl/spl-generic.c
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2014-12-08 13:04:42 -0500
committerBrian Behlendorf <[email protected]>2015-01-16 13:55:08 -0800
commite5b9b344c728bb0d9304f1a143db9255901dc5fe (patch)
tree9c8fb75b9cfc7a6cef72b2c6a7cc08ef11b9a589 /module/spl/spl-generic.c
parent6ecf6d7228fbb29cfe6a335f5afc20f75493a791 (diff)
Refactor existing code
This change introduces no functional changes to the memory management interfaces. It only restructures the existing codes by separating the kmem, vmem, and kmem cache implementations in the separate source and header files. Splitting this functionality in to separate files required the addition of spl_vmem_{init,fini}() and spl_kmem_cache_{initi,fini}() functions. Additionally, several minor changes to the #include's were required to accommodate the removal of extraneous header from kmem.h. But again, while large this patch introduces no functional changes. Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'module/spl/spl-generic.c')
-rw-r--r--module/spl/spl-generic.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/module/spl/spl-generic.c b/module/spl/spl-generic.c
index 803f03a85..b706ccecd 100644
--- a/module/spl/spl-generic.c
+++ b/module/spl/spl-generic.c
@@ -29,6 +29,8 @@
#include <sys/vmsystm.h>
#include <sys/kobj.h>
#include <sys/kmem.h>
+#include <sys/kmem_cache.h>
+#include <sys/vmem.h>
#include <sys/mutex.h>
#include <sys/rwlock.h>
#include <sys/taskq.h>
@@ -38,6 +40,7 @@
#include <sys/proc.h>
#include <sys/kstat.h>
#include <sys/file.h>
+#include <linux/ctype.h>
#include <linux/kmod.h>
#include <linux/math64_compat.h>
#include <linux/proc_compat.h>
@@ -480,11 +483,45 @@ zone_get_hostid(void *zone)
EXPORT_SYMBOL(zone_get_hostid);
static int
+spl_kvmem_init(void)
+{
+ int rc = 0;
+
+ rc = spl_kmem_init();
+ if (rc)
+ goto out1;
+
+ rc = spl_vmem_init();
+ if (rc)
+ goto out2;
+
+ rc = spl_kmem_cache_init();
+ if (rc)
+ goto out3;
+
+ return (rc);
+out3:
+ spl_vmem_fini();
+out2:
+ spl_kmem_fini();
+out1:
+ return (rc);
+}
+
+static void
+spl_kvmem_fini(void)
+{
+ spl_kmem_cache_fini();
+ spl_vmem_fini();
+ spl_kmem_fini();
+}
+
+static int
__init spl_init(void)
{
int rc = 0;
- if ((rc = spl_kmem_init()))
+ if ((rc = spl_kvmem_init()))
goto out1;
if ((rc = spl_mutex_init()))
@@ -530,7 +567,7 @@ out4:
out3:
spl_mutex_fini();
out2:
- spl_kmem_fini();
+ spl_kvmem_fini();
out1:
printk(KERN_NOTICE "SPL: Failed to Load Solaris Porting Layer "
"v%s-%s%s, rc = %d\n", SPL_META_VERSION, SPL_META_RELEASE,
@@ -552,7 +589,7 @@ spl_fini(void)
spl_taskq_fini();
spl_rw_fini();
spl_mutex_fini();
- spl_kmem_fini();
+ spl_kvmem_fini();
}
/* Called when a dependent module is loaded */