xref: /openbmc/linux/fs/fscache/main.c (revision 1e1236b841166f1d2daf36fdf6bb3e656bc5f5ca)
1*1e1236b8SDavid Howells // SPDX-License-Identifier: GPL-2.0-or-later
2*1e1236b8SDavid Howells /* General filesystem local caching manager
3*1e1236b8SDavid Howells  *
4*1e1236b8SDavid Howells  * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
5*1e1236b8SDavid Howells  * Written by David Howells (dhowells@redhat.com)
6*1e1236b8SDavid Howells  */
7*1e1236b8SDavid Howells 
8*1e1236b8SDavid Howells #define FSCACHE_DEBUG_LEVEL CACHE
9*1e1236b8SDavid Howells #include <linux/module.h>
10*1e1236b8SDavid Howells #include <linux/init.h>
11*1e1236b8SDavid Howells #define CREATE_TRACE_POINTS
12*1e1236b8SDavid Howells #include "internal.h"
13*1e1236b8SDavid Howells 
14*1e1236b8SDavid Howells MODULE_DESCRIPTION("FS Cache Manager");
15*1e1236b8SDavid Howells MODULE_AUTHOR("Red Hat, Inc.");
16*1e1236b8SDavid Howells MODULE_LICENSE("GPL");
17*1e1236b8SDavid Howells 
18*1e1236b8SDavid Howells unsigned fscache_debug;
19*1e1236b8SDavid Howells module_param_named(debug, fscache_debug, uint,
20*1e1236b8SDavid Howells 		   S_IWUSR | S_IRUGO);
21*1e1236b8SDavid Howells MODULE_PARM_DESC(fscache_debug,
22*1e1236b8SDavid Howells 		 "FS-Cache debugging mask");
23*1e1236b8SDavid Howells 
24*1e1236b8SDavid Howells struct workqueue_struct *fscache_wq;
25*1e1236b8SDavid Howells EXPORT_SYMBOL(fscache_wq);
26*1e1236b8SDavid Howells 
27*1e1236b8SDavid Howells /*
28*1e1236b8SDavid Howells  * initialise the fs caching module
29*1e1236b8SDavid Howells  */
30*1e1236b8SDavid Howells static int __init fscache_init(void)
31*1e1236b8SDavid Howells {
32*1e1236b8SDavid Howells 	int ret = -ENOMEM;
33*1e1236b8SDavid Howells 
34*1e1236b8SDavid Howells 	fscache_wq = alloc_workqueue("fscache", WQ_UNBOUND | WQ_FREEZABLE, 0);
35*1e1236b8SDavid Howells 	if (!fscache_wq)
36*1e1236b8SDavid Howells 		goto error_wq;
37*1e1236b8SDavid Howells 
38*1e1236b8SDavid Howells 	ret = fscache_proc_init();
39*1e1236b8SDavid Howells 	if (ret < 0)
40*1e1236b8SDavid Howells 		goto error_proc;
41*1e1236b8SDavid Howells 
42*1e1236b8SDavid Howells 	pr_notice("Loaded\n");
43*1e1236b8SDavid Howells 	return 0;
44*1e1236b8SDavid Howells 
45*1e1236b8SDavid Howells error_proc:
46*1e1236b8SDavid Howells 	destroy_workqueue(fscache_wq);
47*1e1236b8SDavid Howells error_wq:
48*1e1236b8SDavid Howells 	return ret;
49*1e1236b8SDavid Howells }
50*1e1236b8SDavid Howells 
51*1e1236b8SDavid Howells fs_initcall(fscache_init);
52*1e1236b8SDavid Howells 
53*1e1236b8SDavid Howells /*
54*1e1236b8SDavid Howells  * clean up on module removal
55*1e1236b8SDavid Howells  */
56*1e1236b8SDavid Howells static void __exit fscache_exit(void)
57*1e1236b8SDavid Howells {
58*1e1236b8SDavid Howells 	_enter("");
59*1e1236b8SDavid Howells 
60*1e1236b8SDavid Howells 	fscache_proc_cleanup();
61*1e1236b8SDavid Howells 	destroy_workqueue(fscache_wq);
62*1e1236b8SDavid Howells 	pr_notice("Unloaded\n");
63*1e1236b8SDavid Howells }
64*1e1236b8SDavid Howells 
65*1e1236b8SDavid Howells module_exit(fscache_exit);
66