[AF_RXRPC]: Make the in-kernel AFS filesystem use AF_RXRPC.
[firefly-linux-kernel-4.4.55.git] / fs / afs / main.c
1 /* AFS client file system
2  *
3  * Copyright (C) 2002 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/moduleparam.h>
14 #include <linux/init.h>
15 #include <linux/completion.h>
16 #include "internal.h"
17
18 MODULE_DESCRIPTION("AFS Client File System");
19 MODULE_AUTHOR("Red Hat, Inc.");
20 MODULE_LICENSE("GPL");
21
22 unsigned afs_debug;
23 module_param_named(debug, afs_debug, uint, S_IWUSR | S_IRUGO);
24 MODULE_PARM_DESC(afs_debug, "AFS debugging mask");
25
26 static char *rootcell;
27
28 module_param(rootcell, charp, 0);
29 MODULE_PARM_DESC(rootcell, "root AFS cell name and VL server IP addr list");
30
31 #ifdef AFS_CACHING_SUPPORT
32 static struct cachefs_netfs_operations afs_cache_ops = {
33         .get_page_cookie        = afs_cache_get_page_cookie,
34 };
35
36 struct cachefs_netfs afs_cache_netfs = {
37         .name                   = "afs",
38         .version                = 0,
39         .ops                    = &afs_cache_ops,
40 };
41 #endif
42
43 /*
44  * initialise the AFS client FS module
45  */
46 static int __init afs_init(void)
47 {
48         int ret;
49
50         printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 registering.\n");
51
52         /* register the /proc stuff */
53         ret = afs_proc_init();
54         if (ret < 0)
55                 return ret;
56
57 #ifdef AFS_CACHING_SUPPORT
58         /* we want to be able to cache */
59         ret = cachefs_register_netfs(&afs_cache_netfs,
60                                      &afs_cache_cell_index_def);
61         if (ret < 0)
62                 goto error_cache;
63 #endif
64
65         /* initialise the cell DB */
66         ret = afs_cell_init(rootcell);
67         if (ret < 0)
68                 goto error_cell_init;
69
70         /* initialise the VL update process */
71         ret = afs_vlocation_update_init();
72         if (ret < 0)
73                 goto error_vl_update_init;
74
75         /* initialise the callback update process */
76         ret = afs_callback_update_init();
77
78         /* create the RxRPC transport */
79         ret = afs_open_socket();
80         if (ret < 0)
81                 goto error_open_socket;
82
83         /* register the filesystems */
84         ret = afs_fs_init();
85         if (ret < 0)
86                 goto error_fs;
87
88         return ret;
89
90 error_fs:
91         afs_close_socket();
92 error_open_socket:
93 error_vl_update_init:
94 error_cell_init:
95 #ifdef AFS_CACHING_SUPPORT
96         cachefs_unregister_netfs(&afs_cache_netfs);
97 error_cache:
98 #endif
99         afs_callback_update_kill();
100         afs_vlocation_purge();
101         afs_cell_purge();
102         afs_proc_cleanup();
103         printk(KERN_ERR "kAFS: failed to register: %d\n", ret);
104         return ret;
105 }
106
107 /* XXX late_initcall is kludgy, but the only alternative seems to create
108  * a transport upon the first mount, which is worse. Or is it?
109  */
110 late_initcall(afs_init);        /* must be called after net/ to create socket */
111
112 /*
113  * clean up on module removal
114  */
115 static void __exit afs_exit(void)
116 {
117         printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 unregistering.\n");
118
119         afs_fs_exit();
120         afs_close_socket();
121         afs_purge_servers();
122         afs_callback_update_kill();
123         afs_vlocation_purge();
124         flush_scheduled_work();
125         afs_cell_purge();
126 #ifdef AFS_CACHING_SUPPORT
127         cachefs_unregister_netfs(&afs_cache_netfs);
128 #endif
129         afs_proc_cleanup();
130 }
131
132 module_exit(afs_exit);