1 /* main.c: general filesystem caching manager
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/sched.h>
15 #include <linux/completion.h>
16 #include <linux/slab.h>
17 #include "fscache-int.h"
21 static int fscache_init(void);
22 static void fscache_exit(void);
24 fs_initcall(fscache_init);
25 module_exit(fscache_exit);
27 MODULE_DESCRIPTION("FS Cache Manager");
28 MODULE_AUTHOR("Red Hat, Inc.");
29 MODULE_LICENSE("GPL");
31 static void fscache_ktype_release(struct kobject *kobject);
33 static struct sysfs_ops fscache_sysfs_ops = {
38 static struct kobj_type fscache_ktype = {
39 .release = fscache_ktype_release,
40 .sysfs_ops = &fscache_sysfs_ops,
41 .default_attrs = NULL,
44 struct kset fscache_kset = {
45 .kobj.name = "fscache",
46 .kobj.kset = &fs_subsys.kset,
47 .ktype = &fscache_ktype,
50 EXPORT_SYMBOL(fscache_kset);
52 /*****************************************************************************/
54 * initialise the fs caching module
56 static int __init fscache_init(void)
61 kmem_cache_create("fscache_cookie_jar",
62 sizeof(struct fscache_cookie),
65 fscache_cookie_init_once,
68 if (!fscache_cookie_jar) {
70 "FS-Cache: Failed to allocate a cookie jar\n");
74 ret = kset_register(&fscache_kset);
76 kmem_cache_destroy(fscache_cookie_jar);
80 printk(KERN_NOTICE "FS-Cache: Loaded\n");
85 /*****************************************************************************/
87 * clean up on module removal
89 static void __exit fscache_exit(void)
93 kset_unregister(&fscache_kset);
94 kmem_cache_destroy(fscache_cookie_jar);
95 printk(KERN_NOTICE "FS-Cache: unloaded\n");
99 /*****************************************************************************/
103 static void fscache_ktype_release(struct kobject *kobject)