summaryrefslogtreecommitdiff
path: root/fs/cachefiles/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cachefiles/main.c')
-rw-r--r--fs/cachefiles/main.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/cachefiles/main.c b/fs/cachefiles/main.c
index 533e3067d80f..3f369c6f816d 100644
--- a/fs/cachefiles/main.c
+++ b/fs/cachefiles/main.c
@@ -31,6 +31,8 @@ MODULE_DESCRIPTION("Mounted-filesystem based cache");
MODULE_AUTHOR("Red Hat, Inc.");
MODULE_LICENSE("GPL");
+struct kmem_cache *cachefiles_object_jar;
+
static struct miscdevice cachefiles_dev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "cachefiles",
@@ -51,9 +53,22 @@ static int __init cachefiles_init(void)
if (ret < 0)
goto error_dev;
+ /* create an object jar */
+ ret = -ENOMEM;
+ cachefiles_object_jar =
+ kmem_cache_create("cachefiles_object_jar",
+ sizeof(struct cachefiles_object),
+ 0, SLAB_HWCACHE_ALIGN, NULL);
+ if (!cachefiles_object_jar) {
+ pr_notice("Failed to allocate an object jar\n");
+ goto error_object_jar;
+ }
+
pr_info("Loaded\n");
return 0;
+error_object_jar:
+ misc_deregister(&cachefiles_dev);
error_dev:
cachefiles_unregister_error_injection();
error_einj:
@@ -70,6 +85,7 @@ static void __exit cachefiles_exit(void)
{
pr_info("Unloading\n");
+ kmem_cache_destroy(cachefiles_object_jar);
misc_deregister(&cachefiles_dev);
cachefiles_unregister_error_injection();
}