summaryrefslogtreecommitdiffstats
path: root/fs/cachefiles/main.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2021-11-17 16:22:21 +0000
committerDavid Howells <dhowells@redhat.com>2022-01-07 13:42:08 +0000
commitdf98e87f2091774c377ddfaedfe64bd90ed4bdca (patch)
tree626bfd7ea0af245966ca301cc7b1c1f28c38f9de /fs/cachefiles/main.c
parent13871bad1ef7f41947c816a9e342aa9fa8643c5e (diff)
downloadlinux-df98e87f2091774c377ddfaedfe64bd90ed4bdca.tar.gz
linux-df98e87f2091774c377ddfaedfe64bd90ed4bdca.tar.bz2
linux-df98e87f2091774c377ddfaedfe64bd90ed4bdca.zip
cachefiles: Implement object lifecycle funcs
Implement allocate, get, see and put functions for the cachefiles_object struct. The members of the struct we're going to need are also added. Additionally, implement a lifecycle tracepoint. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> cc: linux-cachefs@redhat.com Link: https://lore.kernel.org/r/163819639457.215744.4600093239395728232.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/163906939569.143852.3594314410666551982.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/163967148857.1823006.6332962598220464364.stgit@warthog.procyon.org.uk/ # v3 Link: https://lore.kernel.org/r/164021547762.640689.8422781599594931000.stgit@warthog.procyon.org.uk/ # v4
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();
}