1 /* Network filesystem caching backend to use cache files on a premounted
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public Licence
9 * as published by the Free Software Foundation; either version
10 * 2 of the Licence, or (at your option) any later version.
13 #include <linux/module.h>
14 #include <linux/init.h>
15 #include <linux/sched.h>
16 #include <linux/completion.h>
17 #include <linux/slab.h>
19 #include <linux/file.h>
20 #include <linux/namei.h>
21 #include <linux/mount.h>
22 #include <linux/statfs.h>
23 #include <linux/sysctl.h>
24 #include <linux/miscdevice.h>
27 unsigned cachefiles_debug
;
28 module_param_named(debug
, cachefiles_debug
, uint
, S_IWUSR
| S_IRUGO
);
29 MODULE_PARM_DESC(cachefiles_debug
, "CacheFiles debugging mask");
31 MODULE_DESCRIPTION("Mounted-filesystem based cache");
32 MODULE_AUTHOR("Red Hat, Inc.");
33 MODULE_LICENSE("GPL");
35 struct kmem_cache
*cachefiles_object_jar
;
37 static struct miscdevice cachefiles_dev
= {
38 .minor
= MISC_DYNAMIC_MINOR
,
40 .fops
= &cachefiles_daemon_fops
,
43 static void cachefiles_object_init_once(void *_object
)
45 struct cachefiles_object
*object
= _object
;
47 memset(object
, 0, sizeof(*object
));
48 spin_lock_init(&object
->work_lock
);
52 * initialise the fs caching module
54 static int __init
cachefiles_init(void)
58 ret
= misc_register(&cachefiles_dev
);
62 /* create an object jar */
64 cachefiles_object_jar
=
65 kmem_cache_create("cachefiles_object_jar",
66 sizeof(struct cachefiles_object
),
69 cachefiles_object_init_once
);
70 if (!cachefiles_object_jar
) {
72 "CacheFiles: Failed to allocate an object jar\n");
73 goto error_object_jar
;
76 ret
= cachefiles_proc_init();
80 printk(KERN_INFO
"CacheFiles: Loaded\n");
84 kmem_cache_destroy(cachefiles_object_jar
);
86 misc_deregister(&cachefiles_dev
);
88 kerror("failed to register: %d", ret
);
92 fs_initcall(cachefiles_init
);
95 * clean up on module removal
97 static void __exit
cachefiles_exit(void)
99 printk(KERN_INFO
"CacheFiles: Unloading\n");
101 cachefiles_proc_cleanup();
102 kmem_cache_destroy(cachefiles_object_jar
);
103 misc_deregister(&cachefiles_dev
);
106 module_exit(cachefiles_exit
);