This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / fs / fscache / main.c
1 /* main.c: general filesystem caching manager
2  *
3  * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells (dhowells@redhat.com)
5  *
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.
10  */
11
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"
18
19 int fscache_debug;
20
21 static int fscache_init(void);
22 static void fscache_exit(void);
23
24 fs_initcall(fscache_init);
25 module_exit(fscache_exit);
26
27 MODULE_DESCRIPTION("FS Cache Manager");
28 MODULE_AUTHOR("Red Hat, Inc.");
29 MODULE_LICENSE("GPL");
30
31 static void fscache_ktype_release(struct kobject *kobject);
32
33 static struct sysfs_ops fscache_sysfs_ops = {
34         .show           = NULL,
35         .store          = NULL,
36 };
37
38 static struct kobj_type fscache_ktype = {
39         .release        = fscache_ktype_release,
40         .sysfs_ops      = &fscache_sysfs_ops,
41         .default_attrs  = NULL,
42 };
43
44 struct kset fscache_kset = {
45         .kobj.name      = "fscache",
46         .kobj.kset      = &fs_subsys.kset,
47         .ktype          = &fscache_ktype,
48 };
49
50 EXPORT_SYMBOL(fscache_kset);
51
52 /*****************************************************************************/
53 /*
54  * initialise the fs caching module
55  */
56 static int __init fscache_init(void)
57 {
58         int ret;
59
60         fscache_cookie_jar =
61                 kmem_cache_create("fscache_cookie_jar",
62                                   sizeof(struct fscache_cookie),
63                                   0,
64                                   0,
65                                   fscache_cookie_init_once,
66                                   NULL);
67
68         if (!fscache_cookie_jar) {
69                 printk(KERN_NOTICE
70                        "FS-Cache: Failed to allocate a cookie jar\n");
71                 return -ENOMEM;
72         }
73
74         ret = kset_register(&fscache_kset);
75         if (ret < 0) {
76                 kmem_cache_destroy(fscache_cookie_jar);
77                 return ret;
78         }
79
80         printk(KERN_NOTICE "FS-Cache: Loaded\n");
81         return 0;
82
83 }
84
85 /*****************************************************************************/
86 /*
87  * clean up on module removal
88  */
89 static void __exit fscache_exit(void)
90 {
91         _enter("");
92
93         kset_unregister(&fscache_kset);
94         kmem_cache_destroy(fscache_cookie_jar);
95         printk(KERN_NOTICE "FS-Cache: unloaded\n");
96
97 }
98
99 /*****************************************************************************/
100 /*
101  * release the ktype
102  */
103 static void fscache_ktype_release(struct kobject *kobject)
104 {
105 }