diff options
Diffstat (limited to 'fs/afs/main.c')
-rw-r--r-- | fs/afs/main.c | 135 |
1 files changed, 22 insertions, 113 deletions
diff --git a/fs/afs/main.c b/fs/afs/main.c index 5bf39f66f4ce..0cf1b021ad54 100644 --- a/fs/afs/main.c +++ b/fs/afs/main.c | |||
@@ -13,43 +13,21 @@ | |||
13 | #include <linux/moduleparam.h> | 13 | #include <linux/moduleparam.h> |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/completion.h> | 15 | #include <linux/completion.h> |
16 | #include <rxrpc/rxrpc.h> | ||
17 | #include <rxrpc/transport.h> | ||
18 | #include <rxrpc/call.h> | ||
19 | #include <rxrpc/peer.h> | ||
20 | #include "cache.h" | ||
21 | #include "cell.h" | ||
22 | #include "server.h" | ||
23 | #include "fsclient.h" | ||
24 | #include "cmservice.h" | ||
25 | #include "kafstimod.h" | ||
26 | #include "kafsasyncd.h" | ||
27 | #include "internal.h" | 16 | #include "internal.h" |
28 | 17 | ||
29 | struct rxrpc_transport *afs_transport; | ||
30 | |||
31 | static int afs_adding_peer(struct rxrpc_peer *peer); | ||
32 | static void afs_discarding_peer(struct rxrpc_peer *peer); | ||
33 | |||
34 | |||
35 | MODULE_DESCRIPTION("AFS Client File System"); | 18 | MODULE_DESCRIPTION("AFS Client File System"); |
36 | MODULE_AUTHOR("Red Hat, Inc."); | 19 | MODULE_AUTHOR("Red Hat, Inc."); |
37 | MODULE_LICENSE("GPL"); | 20 | MODULE_LICENSE("GPL"); |
38 | 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 | |||
39 | static char *rootcell; | 26 | static char *rootcell; |
40 | 27 | ||
41 | module_param(rootcell, charp, 0); | 28 | module_param(rootcell, charp, 0); |
42 | MODULE_PARM_DESC(rootcell, "root AFS cell name and VL server IP addr list"); | 29 | MODULE_PARM_DESC(rootcell, "root AFS cell name and VL server IP addr list"); |
43 | 30 | ||
44 | |||
45 | static struct rxrpc_peer_ops afs_peer_ops = { | ||
46 | .adding = afs_adding_peer, | ||
47 | .discarding = afs_discarding_peer, | ||
48 | }; | ||
49 | |||
50 | struct list_head afs_cb_hash_tbl[AFS_CB_HASH_COUNT]; | ||
51 | DEFINE_SPINLOCK(afs_cb_hash_lock); | ||
52 | |||
53 | #ifdef AFS_CACHING_SUPPORT | 31 | #ifdef AFS_CACHING_SUPPORT |
54 | static struct cachefs_netfs_operations afs_cache_ops = { | 32 | static struct cachefs_netfs_operations afs_cache_ops = { |
55 | .get_page_cookie = afs_cache_get_page_cookie, | 33 | .get_page_cookie = afs_cache_get_page_cookie, |
@@ -67,15 +45,10 @@ struct cachefs_netfs afs_cache_netfs = { | |||
67 | */ | 45 | */ |
68 | static int __init afs_init(void) | 46 | static int __init afs_init(void) |
69 | { | 47 | { |
70 | int loop, ret; | 48 | int ret; |
71 | 49 | ||
72 | printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 registering.\n"); | 50 | printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 registering.\n"); |
73 | 51 | ||
74 | /* initialise the callback hash table */ | ||
75 | spin_lock_init(&afs_cb_hash_lock); | ||
76 | for (loop = AFS_CB_HASH_COUNT - 1; loop >= 0; loop--) | ||
77 | INIT_LIST_HEAD(&afs_cb_hash_tbl[loop]); | ||
78 | |||
79 | /* register the /proc stuff */ | 52 | /* register the /proc stuff */ |
80 | ret = afs_proc_init(); | 53 | ret = afs_proc_init(); |
81 | if (ret < 0) | 54 | if (ret < 0) |
@@ -94,22 +67,18 @@ static int __init afs_init(void) | |||
94 | if (ret < 0) | 67 | if (ret < 0) |
95 | goto error_cell_init; | 68 | goto error_cell_init; |
96 | 69 | ||
97 | /* start the timeout daemon */ | 70 | /* initialise the VL update process */ |
98 | ret = afs_kafstimod_start(); | 71 | ret = afs_vlocation_update_init(); |
99 | if (ret < 0) | 72 | if (ret < 0) |
100 | goto error_kafstimod; | 73 | goto error_vl_update_init; |
101 | 74 | ||
102 | /* start the async operation daemon */ | 75 | /* initialise the callback update process */ |
103 | ret = afs_kafsasyncd_start(); | 76 | ret = afs_callback_update_init(); |
104 | if (ret < 0) | ||
105 | goto error_kafsasyncd; | ||
106 | 77 | ||
107 | /* create the RxRPC transport */ | 78 | /* create the RxRPC transport */ |
108 | ret = rxrpc_create_transport(7001, &afs_transport); | 79 | ret = afs_open_socket(); |
109 | if (ret < 0) | 80 | if (ret < 0) |
110 | goto error_transport; | 81 | goto error_open_socket; |
111 | |||
112 | afs_transport->peer_ops = &afs_peer_ops; | ||
113 | 82 | ||
114 | /* register the filesystems */ | 83 | /* register the filesystems */ |
115 | ret = afs_fs_init(); | 84 | ret = afs_fs_init(); |
@@ -119,17 +88,16 @@ static int __init afs_init(void) | |||
119 | return ret; | 88 | return ret; |
120 | 89 | ||
121 | error_fs: | 90 | error_fs: |
122 | rxrpc_put_transport(afs_transport); | 91 | afs_close_socket(); |
123 | error_transport: | 92 | error_open_socket: |
124 | afs_kafsasyncd_stop(); | 93 | error_vl_update_init: |
125 | error_kafsasyncd: | ||
126 | afs_kafstimod_stop(); | ||
127 | error_kafstimod: | ||
128 | error_cell_init: | 94 | error_cell_init: |
129 | #ifdef AFS_CACHING_SUPPORT | 95 | #ifdef AFS_CACHING_SUPPORT |
130 | cachefs_unregister_netfs(&afs_cache_netfs); | 96 | cachefs_unregister_netfs(&afs_cache_netfs); |
131 | error_cache: | 97 | error_cache: |
132 | #endif | 98 | #endif |
99 | afs_callback_update_kill(); | ||
100 | afs_vlocation_purge(); | ||
133 | afs_cell_purge(); | 101 | afs_cell_purge(); |
134 | afs_proc_cleanup(); | 102 | afs_proc_cleanup(); |
135 | printk(KERN_ERR "kAFS: failed to register: %d\n", ret); | 103 | printk(KERN_ERR "kAFS: failed to register: %d\n", ret); |
@@ -149,9 +117,11 @@ static void __exit afs_exit(void) | |||
149 | printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 unregistering.\n"); | 117 | printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 unregistering.\n"); |
150 | 118 | ||
151 | afs_fs_exit(); | 119 | afs_fs_exit(); |
152 | rxrpc_put_transport(afs_transport); | 120 | afs_close_socket(); |
153 | afs_kafstimod_stop(); | 121 | afs_purge_servers(); |
154 | afs_kafsasyncd_stop(); | 122 | afs_callback_update_kill(); |
123 | afs_vlocation_purge(); | ||
124 | flush_scheduled_work(); | ||
155 | afs_cell_purge(); | 125 | afs_cell_purge(); |
156 | #ifdef AFS_CACHING_SUPPORT | 126 | #ifdef AFS_CACHING_SUPPORT |
157 | cachefs_unregister_netfs(&afs_cache_netfs); | 127 | cachefs_unregister_netfs(&afs_cache_netfs); |
@@ -160,64 +130,3 @@ static void __exit afs_exit(void) | |||
160 | } | 130 | } |
161 | 131 | ||
162 | module_exit(afs_exit); | 132 | module_exit(afs_exit); |
163 | |||
164 | /* | ||
165 | * notification that new peer record is being added | ||
166 | * - called from krxsecd | ||
167 | * - return an error to induce an abort | ||
168 | * - mustn't sleep (caller holds an rwlock) | ||
169 | */ | ||
170 | static int afs_adding_peer(struct rxrpc_peer *peer) | ||
171 | { | ||
172 | struct afs_server *server; | ||
173 | int ret; | ||
174 | |||
175 | _debug("kAFS: Adding new peer %08x\n", ntohl(peer->addr.s_addr)); | ||
176 | |||
177 | /* determine which server the peer resides in (if any) */ | ||
178 | ret = afs_server_find_by_peer(peer, &server); | ||
179 | if (ret < 0) | ||
180 | return ret; /* none that we recognise, so abort */ | ||
181 | |||
182 | _debug("Server %p{u=%d}\n", server, atomic_read(&server->usage)); | ||
183 | |||
184 | _debug("Cell %p{u=%d}\n", | ||
185 | server->cell, atomic_read(&server->cell->usage)); | ||
186 | |||
187 | /* cross-point the structs under a global lock */ | ||
188 | spin_lock(&afs_server_peer_lock); | ||
189 | peer->user = server; | ||
190 | server->peer = peer; | ||
191 | spin_unlock(&afs_server_peer_lock); | ||
192 | |||
193 | afs_put_server(server); | ||
194 | |||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | /* | ||
199 | * notification that a peer record is being discarded | ||
200 | * - called from krxiod or krxsecd | ||
201 | */ | ||
202 | static void afs_discarding_peer(struct rxrpc_peer *peer) | ||
203 | { | ||
204 | struct afs_server *server; | ||
205 | |||
206 | _enter("%p",peer); | ||
207 | |||
208 | _debug("Discarding peer %08x (rtt=%lu.%lumS)\n", | ||
209 | ntohl(peer->addr.s_addr), | ||
210 | (long) (peer->rtt / 1000), | ||
211 | (long) (peer->rtt % 1000)); | ||
212 | |||
213 | /* uncross-point the structs under a global lock */ | ||
214 | spin_lock(&afs_server_peer_lock); | ||
215 | server = peer->user; | ||
216 | if (server) { | ||
217 | peer->user = NULL; | ||
218 | server->peer = NULL; | ||
219 | } | ||
220 | spin_unlock(&afs_server_peer_lock); | ||
221 | |||
222 | _leave(""); | ||
223 | } | ||