]>
Commit | Line | Data |
---|---|---|
ec26815a | 1 | /* internal AFS stuff |
1da177e4 | 2 | * |
08e0e7c8 | 3 | * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved. |
1da177e4 LT |
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 | ||
1da177e4 LT |
12 | #include <linux/compiler.h> |
13 | #include <linux/kernel.h> | |
8a79790b | 14 | #include <linux/ktime.h> |
1da177e4 LT |
15 | #include <linux/fs.h> |
16 | #include <linux/pagemap.h> | |
08e0e7c8 | 17 | #include <linux/rxrpc.h> |
00d3b7a4 | 18 | #include <linux/key.h> |
e8edc6e0 | 19 | #include <linux/workqueue.h> |
00c541ea | 20 | #include <linux/sched.h> |
80e50be4 | 21 | #include <linux/fscache.h> |
e1da0222 | 22 | #include <linux/backing-dev.h> |
ff548773 | 23 | #include <linux/uuid.h> |
f044c884 | 24 | #include <net/net_namespace.h> |
8324f0bc | 25 | #include <net/af_rxrpc.h> |
00c541ea | 26 | |
08e0e7c8 DH |
27 | #include "afs.h" |
28 | #include "afs_vl.h" | |
29 | ||
30 | #define AFS_CELL_MAX_ADDRS 15 | |
31 | ||
31143d5d | 32 | struct pagevec; |
08e0e7c8 DH |
33 | struct afs_call; |
34 | ||
00d3b7a4 DH |
35 | struct afs_mount_params { |
36 | bool rwpath; /* T if the parent should be considered R/W */ | |
37 | bool force; /* T to force cell type */ | |
bec5eb61 | 38 | bool autocell; /* T if set auto mount operation */ |
00d3b7a4 DH |
39 | afs_voltype_t type; /* type of volume requested */ |
40 | int volnamesz; /* size of volume name */ | |
41 | const char *volname; /* name of volume to mount */ | |
f044c884 | 42 | struct afs_net *net; /* Network namespace in effect */ |
00d3b7a4 DH |
43 | struct afs_cell *cell; /* cell in which to find volume */ |
44 | struct afs_volume *volume; /* volume record */ | |
45 | struct key *key; /* key to use for secure mounting */ | |
46 | }; | |
47 | ||
c435ee34 DH |
48 | struct afs_iget_data { |
49 | struct afs_fid fid; | |
50 | struct afs_volume *volume; /* volume on which resides */ | |
51 | }; | |
52 | ||
8e8d7f13 DH |
53 | enum afs_call_state { |
54 | AFS_CALL_REQUESTING, /* request is being sent for outgoing call */ | |
55 | AFS_CALL_AWAIT_REPLY, /* awaiting reply to outgoing call */ | |
56 | AFS_CALL_AWAIT_OP_ID, /* awaiting op ID on incoming call */ | |
57 | AFS_CALL_AWAIT_REQUEST, /* awaiting request data on incoming call */ | |
58 | AFS_CALL_REPLYING, /* replying to incoming call */ | |
59 | AFS_CALL_AWAIT_ACK, /* awaiting final ACK of incoming call */ | |
60 | AFS_CALL_COMPLETE, /* Completed or failed */ | |
61 | }; | |
f044c884 | 62 | |
8b2a464c DH |
63 | /* |
64 | * List of server addresses. | |
65 | */ | |
66 | struct afs_addr_list { | |
67 | struct rcu_head rcu; /* Must be first */ | |
68 | refcount_t usage; | |
d2ddc776 | 69 | u32 version; /* Version */ |
8b2a464c DH |
70 | unsigned short nr_addrs; |
71 | unsigned short index; /* Address currently in use */ | |
d2ddc776 | 72 | unsigned short nr_ipv4; /* Number of IPv4 addresses */ |
bf99a53c DH |
73 | unsigned long probed; /* Mask of servers that have been probed */ |
74 | unsigned long yfs; /* Mask of servers that are YFS */ | |
8b2a464c DH |
75 | struct sockaddr_rxrpc addrs[]; |
76 | }; | |
77 | ||
08e0e7c8 DH |
78 | /* |
79 | * a record of an in-progress RxRPC call | |
80 | */ | |
81 | struct afs_call { | |
82 | const struct afs_call_type *type; /* type of call */ | |
08e0e7c8 | 83 | wait_queue_head_t waitq; /* processes awaiting completion */ |
341f741f | 84 | struct work_struct async_work; /* async I/O processor */ |
08e0e7c8 | 85 | struct work_struct work; /* actual work processor */ |
08e0e7c8 DH |
86 | struct rxrpc_call *rxcall; /* RxRPC call handle */ |
87 | struct key *key; /* security for this call */ | |
f044c884 | 88 | struct afs_net *net; /* The network namespace */ |
d0676a16 | 89 | struct afs_server *cm_server; /* Server affected by incoming CM call */ |
d2ddc776 | 90 | struct afs_cb_interest *cbi; /* Callback interest for server used */ |
08e0e7c8 | 91 | void *request; /* request data (first part) */ |
31143d5d DH |
92 | struct address_space *mapping; /* page set */ |
93 | struct afs_writeback *wb; /* writeback being performed */ | |
08e0e7c8 | 94 | void *buffer; /* reply receive buffer */ |
97e3043a | 95 | void *reply[4]; /* Where to put the reply */ |
31143d5d DH |
96 | pgoff_t first; /* first page in mapping to deal with */ |
97 | pgoff_t last; /* last page in mapping to deal with */ | |
d001648e | 98 | size_t offset; /* offset into received data store */ |
341f741f | 99 | atomic_t usage; |
8e8d7f13 | 100 | enum afs_call_state state; |
08e0e7c8 | 101 | int error; /* error code */ |
d001648e | 102 | u32 abort_code; /* Remote abort ID or 0 */ |
08e0e7c8 DH |
103 | unsigned request_size; /* size of request data */ |
104 | unsigned reply_max; /* maximum size of reply */ | |
31143d5d | 105 | unsigned first_offset; /* offset into mapping[first] */ |
c435ee34 | 106 | unsigned int cb_break; /* cb_break + cb_s_break before the call */ |
bcd89270 MD |
107 | union { |
108 | unsigned last_to; /* amount of mapping[last] */ | |
109 | unsigned count2; /* count used in unmarshalling */ | |
110 | }; | |
08e0e7c8 DH |
111 | unsigned char unmarshall; /* unmarshalling phase */ |
112 | bool incoming; /* T if incoming call */ | |
31143d5d | 113 | bool send_pages; /* T if data from mapping should be sent */ |
d001648e | 114 | bool need_attention; /* T if RxRPC poked us */ |
56ff9c83 | 115 | bool async; /* T if asynchronous */ |
33cd7f2b | 116 | bool ret_reply0; /* T if should return reply[0] on success */ |
a68f4a27 | 117 | bool upgrade; /* T to request service upgrade */ |
bf99a53c | 118 | u16 service_id; /* Actual service ID (after upgrade) */ |
50a2c953 | 119 | u32 operation_ID; /* operation ID for an incoming call */ |
08e0e7c8 DH |
120 | u32 count; /* count for use in unmarshalling */ |
121 | __be32 tmp; /* place to extract temporary data */ | |
31143d5d | 122 | afs_dataversion_t store_version; /* updated version expected from store */ |
08e0e7c8 DH |
123 | }; |
124 | ||
125 | struct afs_call_type { | |
00d3b7a4 | 126 | const char *name; |
025db80c | 127 | unsigned int op; /* Really enum afs_fs_operation */ |
00d3b7a4 | 128 | |
08e0e7c8 DH |
129 | /* deliver request or reply data to an call |
130 | * - returning an error will cause the call to be aborted | |
131 | */ | |
d001648e | 132 | int (*deliver)(struct afs_call *call); |
08e0e7c8 | 133 | |
08e0e7c8 DH |
134 | /* clean up a call */ |
135 | void (*destructor)(struct afs_call *call); | |
341f741f DH |
136 | |
137 | /* Work function */ | |
138 | void (*work)(struct work_struct *work); | |
08e0e7c8 DH |
139 | }; |
140 | ||
215804a9 DH |
141 | /* |
142 | * AFS open file information record. Pointed to by file->private_data. | |
143 | */ | |
144 | struct afs_file { | |
145 | struct key *key; /* The key this file was opened with */ | |
146 | }; | |
147 | ||
148 | static inline struct key *afs_file_key(struct file *file) | |
149 | { | |
150 | struct afs_file *af = file->private_data; | |
151 | ||
152 | return af->key; | |
153 | } | |
154 | ||
196ee9cd DH |
155 | /* |
156 | * Record of an outstanding read operation on a vnode. | |
157 | */ | |
158 | struct afs_read { | |
159 | loff_t pos; /* Where to start reading */ | |
e8e581a8 | 160 | loff_t len; /* How much we're asking for */ |
196ee9cd | 161 | loff_t actual_len; /* How much we're actually getting */ |
6a0e3999 | 162 | loff_t remain; /* Amount remaining */ |
196ee9cd | 163 | atomic_t usage; |
196ee9cd | 164 | unsigned int index; /* Which page we're reading into */ |
196ee9cd DH |
165 | unsigned int nr_pages; |
166 | void (*page_done)(struct afs_call *, struct afs_read *); | |
167 | struct page *pages[]; | |
168 | }; | |
169 | ||
31143d5d DH |
170 | /* |
171 | * record of an outstanding writeback on a vnode | |
172 | */ | |
173 | struct afs_writeback { | |
174 | struct list_head link; /* link in vnode->writebacks */ | |
175 | struct work_struct writer; /* work item to perform the writeback */ | |
176 | struct afs_vnode *vnode; /* vnode to which this write applies */ | |
177 | struct key *key; /* owner of this write */ | |
178 | wait_queue_head_t waitq; /* completion and ready wait queue */ | |
179 | pgoff_t first; /* first page in batch */ | |
180 | pgoff_t point; /* last page in current store op */ | |
181 | pgoff_t last; /* last page in batch (inclusive) */ | |
182 | unsigned offset_first; /* offset into first page of start of write */ | |
183 | unsigned to_last; /* offset into last page of end of write */ | |
184 | int num_conflicts; /* count of conflicting writes in list */ | |
185 | int usage; | |
186 | bool conflicts; /* T if has dependent conflicts */ | |
187 | enum { | |
188 | AFS_WBACK_SYNCING, /* synchronisation being performed */ | |
189 | AFS_WBACK_PENDING, /* write pending */ | |
190 | AFS_WBACK_CONFLICTING, /* conflicting writes posted */ | |
191 | AFS_WBACK_WRITING, /* writing back */ | |
192 | AFS_WBACK_COMPLETE /* the writeback record has been unlinked */ | |
193 | } state __attribute__((packed)); | |
194 | }; | |
195 | ||
08e0e7c8 DH |
196 | /* |
197 | * AFS superblock private data | |
198 | * - there's one superblock per volume | |
199 | */ | |
200 | struct afs_super_info { | |
f044c884 | 201 | struct afs_net *net; /* Network namespace */ |
49566f6f | 202 | struct afs_cell *cell; /* The cell in which the volume resides */ |
08e0e7c8 | 203 | struct afs_volume *volume; /* volume record */ |
08e0e7c8 | 204 | }; |
1da177e4 | 205 | |
08e0e7c8 DH |
206 | static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) |
207 | { | |
208 | return sb->s_fs_info; | |
1da177e4 LT |
209 | } |
210 | ||
08e0e7c8 DH |
211 | extern struct file_system_type afs_fs_type; |
212 | ||
f044c884 DH |
213 | /* |
214 | * AFS network namespace record. | |
215 | */ | |
216 | struct afs_net { | |
217 | struct afs_uuid uuid; | |
218 | bool live; /* F if this namespace is being removed */ | |
219 | ||
220 | /* AF_RXRPC I/O stuff */ | |
221 | struct socket *socket; | |
222 | struct afs_call *spare_incoming_call; | |
223 | struct work_struct charge_preallocation_work; | |
224 | struct mutex socket_mutex; | |
225 | atomic_t nr_outstanding_calls; | |
226 | atomic_t nr_superblocks; | |
227 | ||
228 | /* Cell database */ | |
989782dc | 229 | struct rb_root cells; |
f044c884 | 230 | struct afs_cell *ws_cell; |
989782dc DH |
231 | struct work_struct cells_manager; |
232 | struct timer_list cells_timer; | |
233 | atomic_t cells_outstanding; | |
234 | seqlock_t cells_lock; | |
f044c884 | 235 | |
989782dc | 236 | spinlock_t proc_cells_lock; |
f044c884 DH |
237 | struct list_head proc_cells; |
238 | ||
d2ddc776 DH |
239 | /* Known servers. Theoretically each fileserver can only be in one |
240 | * cell, but in practice, people create aliases and subsets and there's | |
241 | * no easy way to distinguish them. | |
242 | */ | |
243 | seqlock_t fs_lock; /* For fs_servers */ | |
244 | struct rb_root fs_servers; /* afs_server (by server UUID or address) */ | |
245 | struct list_head fs_updates; /* afs_server (by update_at) */ | |
246 | struct hlist_head fs_proc; /* procfs servers list */ | |
f044c884 | 247 | |
d2ddc776 DH |
248 | struct hlist_head fs_addresses4; /* afs_server (by lowest IPv4 addr) */ |
249 | struct hlist_head fs_addresses6; /* afs_server (by lowest IPv6 addr) */ | |
250 | seqlock_t fs_addr_lock; /* For fs_addresses[46] */ | |
f044c884 | 251 | |
d2ddc776 DH |
252 | struct work_struct fs_manager; |
253 | struct timer_list fs_timer; | |
59fa1c4a | 254 | atomic_t servers_outstanding; |
f044c884 | 255 | |
d2ddc776 DH |
256 | /* File locking renewal management */ |
257 | struct mutex lock_manager_mutex; | |
258 | ||
f044c884 DH |
259 | /* Misc */ |
260 | struct proc_dir_entry *proc_afs; /* /proc/net/afs directory */ | |
261 | }; | |
262 | ||
263 | extern struct afs_net __afs_net;// Dummy AFS network namespace; TODO: replace with real netns | |
264 | ||
989782dc DH |
265 | enum afs_cell_state { |
266 | AFS_CELL_UNSET, | |
267 | AFS_CELL_ACTIVATING, | |
268 | AFS_CELL_ACTIVE, | |
269 | AFS_CELL_DEACTIVATING, | |
270 | AFS_CELL_INACTIVE, | |
271 | AFS_CELL_FAILED, | |
272 | }; | |
273 | ||
08e0e7c8 | 274 | /* |
d2ddc776 DH |
275 | * AFS cell record. |
276 | * | |
277 | * This is a tricky concept to get right as it is possible to create aliases | |
278 | * simply by pointing AFSDB/SRV records for two names at the same set of VL | |
279 | * servers; it is also possible to do things like setting up two sets of VL | |
280 | * servers, one of which provides a superset of the volumes provided by the | |
281 | * other (for internal/external division, for example). | |
282 | * | |
283 | * Cells only exist in the sense that (a) a cell's name maps to a set of VL | |
284 | * servers and (b) a cell's name is used by the client to select the key to use | |
285 | * for authentication and encryption. The cell name is not typically used in | |
286 | * the protocol. | |
287 | * | |
288 | * There is no easy way to determine if two cells are aliases or one is a | |
289 | * subset of another. | |
08e0e7c8 DH |
290 | */ |
291 | struct afs_cell { | |
989782dc DH |
292 | union { |
293 | struct rcu_head rcu; | |
294 | struct rb_node net_node; /* Node in net->cells */ | |
295 | }; | |
296 | struct afs_net *net; | |
00d3b7a4 | 297 | struct key *anonymous_key; /* anonymous user key for this cell */ |
989782dc | 298 | struct work_struct manager; /* Manager for init/deinit/dns */ |
08e0e7c8 | 299 | struct list_head proc_link; /* /proc cell list link */ |
9b3f26c9 DH |
300 | #ifdef CONFIG_AFS_FSCACHE |
301 | struct fscache_cookie *cache; /* caching cookie */ | |
08e0e7c8 | 302 | #endif |
989782dc DH |
303 | time64_t dns_expiry; /* Time AFSDB/SRV record expires */ |
304 | time64_t last_inactive; /* Time of last drop of usage count */ | |
305 | atomic_t usage; | |
306 | unsigned long flags; | |
307 | #define AFS_CELL_FL_NOT_READY 0 /* The cell record is not ready for use */ | |
308 | #define AFS_CELL_FL_NO_GC 1 /* The cell was added manually, don't auto-gc */ | |
309 | #define AFS_CELL_FL_NOT_FOUND 2 /* Permanent DNS error */ | |
310 | #define AFS_CELL_FL_DNS_FAIL 3 /* Failed to access DNS */ | |
8b2a464c | 311 | #define AFS_CELL_FL_NO_LOOKUP_YET 4 /* Not completed first DNS lookup yet */ |
989782dc DH |
312 | enum afs_cell_state state; |
313 | short error; | |
314 | ||
d2ddc776 DH |
315 | /* Active fileserver interaction state. */ |
316 | struct list_head proc_volumes; /* procfs volume list */ | |
317 | rwlock_t proc_lock; | |
989782dc | 318 | |
d2ddc776 | 319 | /* VL server list. */ |
8b2a464c DH |
320 | rwlock_t vl_addrs_lock; /* Lock on vl_addrs */ |
321 | struct afs_addr_list __rcu *vl_addrs; /* List of VL servers */ | |
989782dc DH |
322 | u8 name_len; /* Length of name */ |
323 | char name[64 + 1]; /* Cell name, case-flattened and NUL-padded */ | |
08e0e7c8 DH |
324 | }; |
325 | ||
326 | /* | |
d2ddc776 DH |
327 | * Cached VLDB entry. |
328 | * | |
329 | * This is pointed to by cell->vldb_entries, indexed by name. | |
08e0e7c8 | 330 | */ |
d2ddc776 DH |
331 | struct afs_vldb_entry { |
332 | afs_volid_t vid[3]; /* Volume IDs for R/W, R/O and Bak volumes */ | |
00d3b7a4 | 333 | |
d2ddc776 DH |
334 | unsigned long flags; |
335 | #define AFS_VLDB_HAS_RW 0 /* - R/W volume exists */ | |
336 | #define AFS_VLDB_HAS_RO 1 /* - R/O volume exists */ | |
337 | #define AFS_VLDB_HAS_BAK 2 /* - Backup volume exists */ | |
338 | #define AFS_VLDB_QUERY_VALID 3 /* - Record is valid */ | |
339 | #define AFS_VLDB_QUERY_ERROR 4 /* - VL server returned error */ | |
340 | ||
341 | uuid_t fs_server[AFS_NMAXNSERVERS]; | |
342 | u8 fs_mask[AFS_NMAXNSERVERS]; | |
08e0e7c8 DH |
343 | #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */ |
344 | #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */ | |
345 | #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */ | |
d2ddc776 DH |
346 | short error; |
347 | u8 nr_servers; /* Number of server records */ | |
348 | u8 name_len; | |
349 | u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ | |
08e0e7c8 DH |
350 | }; |
351 | ||
352 | /* | |
d2ddc776 | 353 | * Record of fileserver with which we're actively communicating. |
08e0e7c8 DH |
354 | */ |
355 | struct afs_server { | |
d2ddc776 DH |
356 | struct rcu_head rcu; |
357 | union { | |
358 | uuid_t uuid; /* Server ID */ | |
359 | struct afs_uuid _uuid; | |
360 | }; | |
361 | ||
362 | struct afs_addr_list __rcu *addresses; | |
363 | struct rb_node uuid_rb; /* Link in net->servers */ | |
364 | struct hlist_node addr4_link; /* Link in net->fs_addresses4 */ | |
365 | struct hlist_node addr6_link; /* Link in net->fs_addresses6 */ | |
366 | struct hlist_node proc_link; /* Link in net->fs_proc */ | |
367 | struct afs_server *gc_next; /* Next server in manager's list */ | |
368 | time64_t put_time; /* Time at which last put */ | |
369 | time64_t update_at; /* Time at which to next update the record */ | |
c435ee34 | 370 | unsigned long flags; |
d2ddc776 DH |
371 | #define AFS_SERVER_FL_NEW 0 /* New server, don't inc cb_s_break */ |
372 | #define AFS_SERVER_FL_NOT_READY 1 /* The record is not ready for use */ | |
373 | #define AFS_SERVER_FL_NOT_FOUND 2 /* VL server says no such server */ | |
374 | #define AFS_SERVER_FL_VL_FAIL 3 /* Failed to access VL server */ | |
375 | #define AFS_SERVER_FL_UPDATING 4 | |
376 | #define AFS_SERVER_FL_PROBED 5 /* The fileserver has been probed */ | |
377 | #define AFS_SERVER_FL_PROBING 6 /* Fileserver is being probed */ | |
378 | atomic_t usage; | |
379 | u32 addr_version; /* Address list version */ | |
08e0e7c8 DH |
380 | |
381 | /* file service access */ | |
d2ddc776 | 382 | rwlock_t fs_lock; /* access lock */ |
08e0e7c8 DH |
383 | |
384 | /* callback promise management */ | |
c435ee34 DH |
385 | struct list_head cb_interests; /* List of superblocks using this server */ |
386 | unsigned cb_s_break; /* Break-everything counter. */ | |
387 | rwlock_t cb_break_lock; /* Volume finding lock */ | |
388 | }; | |
389 | ||
390 | /* | |
391 | * Interest by a superblock on a server. | |
392 | */ | |
393 | struct afs_cb_interest { | |
394 | struct list_head cb_link; /* Link in server->cb_interests */ | |
395 | struct afs_server *server; /* Server on which this interest resides */ | |
396 | struct super_block *sb; /* Superblock on which inodes reside */ | |
397 | afs_volid_t vid; /* Volume ID to match */ | |
398 | refcount_t usage; | |
08e0e7c8 DH |
399 | }; |
400 | ||
401 | /* | |
d2ddc776 DH |
402 | * Replaceable server list. |
403 | */ | |
404 | struct afs_server_entry { | |
405 | struct afs_server *server; | |
406 | struct afs_cb_interest *cb_interest; | |
407 | }; | |
408 | ||
409 | struct afs_server_list { | |
410 | refcount_t usage; | |
411 | unsigned short nr_servers; | |
412 | unsigned short index; /* Server currently in use */ | |
413 | unsigned short vnovol_mask; /* Servers to be skipped due to VNOVOL */ | |
414 | unsigned int seq; /* Set to ->servers_seq when installed */ | |
415 | struct afs_server_entry servers[]; | |
416 | }; | |
417 | ||
418 | /* | |
419 | * Live AFS volume management. | |
08e0e7c8 DH |
420 | */ |
421 | struct afs_volume { | |
d2ddc776 | 422 | afs_volid_t vid; /* volume ID */ |
08e0e7c8 | 423 | atomic_t usage; |
d2ddc776 DH |
424 | time64_t update_at; /* Time at which to next update */ |
425 | struct afs_cell *cell; /* Cell to which belongs (pins ref) */ | |
426 | struct list_head proc_link; /* Link in cell->vl_proc */ | |
427 | unsigned long flags; | |
428 | #define AFS_VOLUME_NEEDS_UPDATE 0 /* - T if an update needs performing */ | |
429 | #define AFS_VOLUME_UPDATING 1 /* - T if an update is in progress */ | |
430 | #define AFS_VOLUME_WAIT 2 /* - T if users must wait for update */ | |
431 | #define AFS_VOLUME_DELETED 3 /* - T if volume appears deleted */ | |
432 | #define AFS_VOLUME_OFFLINE 4 /* - T if volume offline notice given */ | |
433 | #define AFS_VOLUME_BUSY 5 /* - T if volume busy notice given */ | |
9b3f26c9 DH |
434 | #ifdef CONFIG_AFS_FSCACHE |
435 | struct fscache_cookie *cache; /* caching cookie */ | |
08e0e7c8 | 436 | #endif |
d2ddc776 DH |
437 | struct afs_server_list *servers; /* List of servers on which volume resides */ |
438 | rwlock_t servers_lock; /* Lock for ->servers */ | |
439 | unsigned int servers_seq; /* Incremented each time ->servers changes */ | |
440 | ||
08e0e7c8 | 441 | afs_voltype_t type; /* type of volume */ |
d2ddc776 | 442 | short error; |
08e0e7c8 | 443 | char type_force; /* force volume type (suppress R/O -> R/W) */ |
d2ddc776 DH |
444 | u8 name_len; |
445 | u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ | |
08e0e7c8 DH |
446 | }; |
447 | ||
448 | /* | |
449 | * AFS inode private data | |
450 | */ | |
451 | struct afs_vnode { | |
452 | struct inode vfs_inode; /* the VFS's inode record */ | |
453 | ||
454 | struct afs_volume *volume; /* volume on which vnode resides */ | |
08e0e7c8 DH |
455 | struct afs_fid fid; /* the file identifier for this inode */ |
456 | struct afs_file_status status; /* AFS status info for this file */ | |
9b3f26c9 DH |
457 | #ifdef CONFIG_AFS_FSCACHE |
458 | struct fscache_cookie *cache; /* caching cookie */ | |
08e0e7c8 | 459 | #endif |
be080a6f | 460 | struct afs_permits *permit_cache; /* cache of permits so far obtained */ |
d2ddc776 | 461 | struct mutex io_lock; /* Lock for serialising I/O on this mutex */ |
260a9803 | 462 | struct mutex validate_lock; /* lock for validating this vnode */ |
31143d5d | 463 | spinlock_t writeback_lock; /* lock for writebacks */ |
08e0e7c8 DH |
464 | spinlock_t lock; /* waitqueue/flags lock */ |
465 | unsigned long flags; | |
c435ee34 | 466 | #define AFS_VNODE_CB_PROMISED 0 /* Set if vnode has a callback promise */ |
260a9803 | 467 | #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */ |
c435ee34 | 468 | #define AFS_VNODE_DIR_MODIFIED 2 /* set if dir vnode's data modified */ |
08e0e7c8 DH |
469 | #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ |
470 | #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ | |
471 | #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ | |
e8d6c554 DH |
472 | #define AFS_VNODE_LOCKING 6 /* set if waiting for lock on vnode */ |
473 | #define AFS_VNODE_READLOCKED 7 /* set if vnode is read-locked on the server */ | |
474 | #define AFS_VNODE_WRITELOCKED 8 /* set if vnode is write-locked on the server */ | |
475 | #define AFS_VNODE_UNLOCKING 9 /* set if vnode is being unlocked on the server */ | |
bec5eb61 | 476 | #define AFS_VNODE_AUTOCELL 10 /* set if Vnode is an auto mount point */ |
477 | #define AFS_VNODE_PSEUDODIR 11 /* set if Vnode is a pseudo directory */ | |
08e0e7c8 | 478 | |
31143d5d | 479 | struct list_head writebacks; /* alterations in pagecache that need writing */ |
e8d6c554 DH |
480 | struct list_head pending_locks; /* locks waiting to be granted */ |
481 | struct list_head granted_locks; /* locks granted on this file */ | |
482 | struct delayed_work lock_work; /* work to be done in locking */ | |
483 | struct key *unlock_key; /* key to be used in unlocking */ | |
31143d5d | 484 | |
08e0e7c8 | 485 | /* outstanding callback notification on this file */ |
c435ee34 DH |
486 | struct afs_cb_interest *cb_interest; /* Server on which this resides */ |
487 | unsigned int cb_s_break; /* Mass break counter on ->server */ | |
488 | unsigned int cb_break; /* Break counter on vnode */ | |
489 | seqlock_t cb_lock; /* Lock for ->cb_interest, ->status, ->cb_*break */ | |
490 | ||
491 | time64_t cb_expires_at; /* time at which callback expires */ | |
08e0e7c8 | 492 | unsigned cb_version; /* callback version */ |
08e0e7c8 | 493 | afs_callback_type_t cb_type; /* type of callback */ |
08e0e7c8 DH |
494 | }; |
495 | ||
00d3b7a4 DH |
496 | /* |
497 | * cached security record for one user's attempt to access a vnode | |
498 | */ | |
499 | struct afs_permit { | |
500 | struct key *key; /* RxRPC ticket holding a security context */ | |
be080a6f | 501 | afs_access_t access; /* CallerAccess value for this key */ |
00d3b7a4 DH |
502 | }; |
503 | ||
504 | /* | |
be080a6f DH |
505 | * Immutable cache of CallerAccess records from attempts to access vnodes. |
506 | * These may be shared between multiple vnodes. | |
00d3b7a4 DH |
507 | */ |
508 | struct afs_permits { | |
be080a6f DH |
509 | struct rcu_head rcu; |
510 | struct hlist_node hash_node; /* Link in hash */ | |
511 | unsigned long h; /* Hash value for this permit list */ | |
512 | refcount_t usage; | |
513 | unsigned short nr_permits; /* Number of records */ | |
514 | bool invalidated; /* Invalidated due to key change */ | |
515 | struct afs_permit permits[]; /* List of permits sorted by key pointer */ | |
00d3b7a4 DH |
516 | }; |
517 | ||
b908fe6b DH |
518 | /* |
519 | * record of one of a system's set of network interfaces | |
520 | */ | |
521 | struct afs_interface { | |
b908fe6b DH |
522 | struct in_addr address; /* IPv4 address bound to interface */ |
523 | struct in_addr netmask; /* netmask applied to address */ | |
524 | unsigned mtu; /* MTU of interface */ | |
525 | }; | |
526 | ||
8b2a464c DH |
527 | /* |
528 | * Cursor for iterating over a server's address list. | |
529 | */ | |
530 | struct afs_addr_cursor { | |
531 | struct afs_addr_list *alist; /* Current address list (pins ref) */ | |
532 | struct sockaddr_rxrpc *addr; | |
d2ddc776 | 533 | u32 abort_code; |
8b2a464c DH |
534 | unsigned short start; /* Starting point in alist->addrs[] */ |
535 | unsigned short index; /* Wrapping offset from start to current addr */ | |
536 | short error; | |
537 | bool begun; /* T if we've begun iteration */ | |
538 | bool responded; /* T if the current address responded */ | |
539 | }; | |
540 | ||
541 | /* | |
542 | * Cursor for iterating over a set of fileservers. | |
543 | */ | |
544 | struct afs_fs_cursor { | |
545 | struct afs_addr_cursor ac; | |
d2ddc776 DH |
546 | struct afs_vnode *vnode; |
547 | struct afs_server_list *server_list; /* Current server list (pins ref) */ | |
548 | struct afs_cb_interest *cbi; /* Server on which this resides (pins ref) */ | |
549 | struct key *key; /* Key for the server */ | |
550 | unsigned int cb_break; /* cb_break + cb_s_break before the call */ | |
551 | unsigned int cb_break_2; /* cb_break + cb_s_break (2nd vnode) */ | |
552 | unsigned char start; /* Initial index in server list */ | |
553 | unsigned char index; /* Number of servers tried beyond start */ | |
554 | unsigned short flags; | |
555 | #define AFS_FS_CURSOR_STOP 0x0001 /* Set to cease iteration */ | |
556 | #define AFS_FS_CURSOR_VBUSY 0x0002 /* Set if seen VBUSY */ | |
557 | #define AFS_FS_CURSOR_VMOVED 0x0004 /* Set if seen VMOVED */ | |
558 | #define AFS_FS_CURSOR_VNOVOL 0x0008 /* Set if seen VNOVOL */ | |
559 | #define AFS_FS_CURSOR_CUR_ONLY 0x0010 /* Set if current server only (file lock held) */ | |
560 | #define AFS_FS_CURSOR_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */ | |
8b2a464c DH |
561 | }; |
562 | ||
08e0e7c8 | 563 | /*****************************************************************************/ |
8b2a464c DH |
564 | /* |
565 | * addr_list.c | |
566 | */ | |
567 | static inline struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist) | |
568 | { | |
569 | if (alist) | |
570 | refcount_inc(&alist->usage); | |
571 | return alist; | |
572 | } | |
573 | extern struct afs_addr_list *afs_alloc_addrlist(unsigned int, | |
574 | unsigned short, | |
575 | unsigned short); | |
576 | extern void afs_put_addrlist(struct afs_addr_list *); | |
577 | extern struct afs_addr_list *afs_parse_text_addrs(const char *, size_t, char, | |
578 | unsigned short, unsigned short); | |
579 | extern struct afs_addr_list *afs_dns_query(struct afs_cell *, time64_t *); | |
580 | extern bool afs_iterate_addresses(struct afs_addr_cursor *); | |
581 | extern int afs_end_cursor(struct afs_addr_cursor *); | |
582 | extern int afs_set_vl_cursor(struct afs_addr_cursor *, struct afs_cell *); | |
583 | ||
bf99a53c DH |
584 | extern void afs_merge_fs_addr4(struct afs_addr_list *, __be32, u16); |
585 | extern void afs_merge_fs_addr6(struct afs_addr_list *, __be32 *, u16); | |
d2ddc776 | 586 | |
9b3f26c9 DH |
587 | /* |
588 | * cache.c | |
589 | */ | |
590 | #ifdef CONFIG_AFS_FSCACHE | |
591 | extern struct fscache_netfs afs_cache_netfs; | |
592 | extern struct fscache_cookie_def afs_cell_cache_index_def; | |
9b3f26c9 DH |
593 | extern struct fscache_cookie_def afs_volume_cache_index_def; |
594 | extern struct fscache_cookie_def afs_vnode_cache_index_def; | |
595 | #else | |
596 | #define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL) | |
9b3f26c9 DH |
597 | #define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL) |
598 | #define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL) | |
599 | #endif | |
600 | ||
08e0e7c8 DH |
601 | /* |
602 | * callback.c | |
603 | */ | |
604 | extern void afs_init_callback_state(struct afs_server *); | |
c435ee34 DH |
605 | extern void afs_break_callback(struct afs_vnode *); |
606 | extern void afs_break_callbacks(struct afs_server *, size_t,struct afs_callback[]); | |
607 | ||
d2ddc776 | 608 | extern int afs_register_server_cb_interest(struct afs_vnode *, struct afs_server_entry *); |
c435ee34 | 609 | extern void afs_put_cb_interest(struct afs_net *, struct afs_cb_interest *); |
d2ddc776 | 610 | extern void afs_clear_callback_interests(struct afs_net *, struct afs_server_list *); |
c435ee34 DH |
611 | |
612 | static inline struct afs_cb_interest *afs_get_cb_interest(struct afs_cb_interest *cbi) | |
613 | { | |
614 | refcount_inc(&cbi->usage); | |
615 | return cbi; | |
616 | } | |
08e0e7c8 | 617 | |
1da177e4 LT |
618 | /* |
619 | * cell.c | |
620 | */ | |
989782dc DH |
621 | extern int afs_cell_init(struct afs_net *, const char *); |
622 | extern struct afs_cell *afs_lookup_cell_rcu(struct afs_net *, const char *, unsigned); | |
623 | extern struct afs_cell *afs_lookup_cell(struct afs_net *, const char *, unsigned, | |
624 | const char *, bool); | |
8b2a464c | 625 | extern struct afs_cell *afs_get_cell(struct afs_cell *); |
9ed900b1 | 626 | extern void afs_put_cell(struct afs_net *, struct afs_cell *); |
989782dc DH |
627 | extern void afs_manage_cells(struct work_struct *); |
628 | extern void afs_cells_timer(struct timer_list *); | |
f044c884 | 629 | extern void __net_exit afs_cell_purge(struct afs_net *); |
08e0e7c8 DH |
630 | |
631 | /* | |
632 | * cmservice.c | |
633 | */ | |
634 | extern bool afs_cm_incoming_call(struct afs_call *); | |
635 | ||
1da177e4 LT |
636 | /* |
637 | * dir.c | |
638 | */ | |
dab17c1a | 639 | extern bool afs_dir_check_page(struct inode *, struct page *); |
754661f1 | 640 | extern const struct inode_operations afs_dir_inode_operations; |
d61dcce2 | 641 | extern const struct dentry_operations afs_fs_dentry_operations; |
4b6f5d20 | 642 | extern const struct file_operations afs_dir_file_operations; |
1da177e4 LT |
643 | |
644 | /* | |
645 | * file.c | |
646 | */ | |
f5e54d6e | 647 | extern const struct address_space_operations afs_fs_aops; |
754661f1 | 648 | extern const struct inode_operations afs_file_inode_operations; |
00d3b7a4 DH |
649 | extern const struct file_operations afs_file_operations; |
650 | ||
651 | extern int afs_open(struct inode *, struct file *); | |
652 | extern int afs_release(struct inode *, struct file *); | |
d2ddc776 | 653 | extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *); |
f6d335c0 | 654 | extern int afs_page_filler(void *, struct page *); |
196ee9cd | 655 | extern void afs_put_read(struct afs_read *); |
1da177e4 | 656 | |
e8d6c554 DH |
657 | /* |
658 | * flock.c | |
659 | */ | |
f044c884 DH |
660 | extern struct workqueue_struct *afs_lock_manager; |
661 | ||
e8d6c554 DH |
662 | extern void afs_lock_work(struct work_struct *); |
663 | extern void afs_lock_may_be_available(struct afs_vnode *); | |
664 | extern int afs_lock(struct file *, int, struct file_lock *); | |
665 | extern int afs_flock(struct file *, int, struct file_lock *); | |
666 | ||
08e0e7c8 DH |
667 | /* |
668 | * fsclient.c | |
669 | */ | |
d2ddc776 DH |
670 | extern int afs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_volsync *); |
671 | extern int afs_fs_give_up_callbacks(struct afs_net *, struct afs_server *); | |
672 | extern int afs_fs_fetch_data(struct afs_fs_cursor *, struct afs_read *); | |
673 | extern int afs_fs_create(struct afs_fs_cursor *, const char *, umode_t, | |
674 | struct afs_fid *, struct afs_file_status *, struct afs_callback *); | |
675 | extern int afs_fs_remove(struct afs_fs_cursor *, const char *, bool); | |
676 | extern int afs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *); | |
677 | extern int afs_fs_symlink(struct afs_fs_cursor *, const char *, const char *, | |
678 | struct afs_fid *, struct afs_file_status *); | |
679 | extern int afs_fs_rename(struct afs_fs_cursor *, const char *, | |
680 | struct afs_vnode *, const char *); | |
8b2a464c | 681 | extern int afs_fs_store_data(struct afs_fs_cursor *, struct afs_writeback *, |
d2ddc776 DH |
682 | pgoff_t, pgoff_t, unsigned, unsigned); |
683 | extern int afs_fs_setattr(struct afs_fs_cursor *, struct iattr *); | |
684 | extern int afs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *); | |
685 | extern int afs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t); | |
686 | extern int afs_fs_extend_lock(struct afs_fs_cursor *); | |
687 | extern int afs_fs_release_lock(struct afs_fs_cursor *); | |
688 | extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *, | |
689 | struct afs_addr_cursor *, struct key *); | |
690 | extern int afs_fs_get_capabilities(struct afs_net *, struct afs_server *, | |
691 | struct afs_addr_cursor *, struct key *); | |
08e0e7c8 | 692 | |
1da177e4 LT |
693 | /* |
694 | * inode.c | |
695 | */ | |
d2ddc776 | 696 | extern int afs_fetch_status(struct afs_vnode *, struct key *); |
c435ee34 | 697 | extern int afs_iget5_test(struct inode *, void *); |
bec5eb61 | 698 | extern struct inode *afs_iget_autocell(struct inode *, const char *, int, |
699 | struct key *); | |
00d3b7a4 | 700 | extern struct inode *afs_iget(struct super_block *, struct key *, |
260a9803 | 701 | struct afs_fid *, struct afs_file_status *, |
d2ddc776 DH |
702 | struct afs_callback *, |
703 | struct afs_cb_interest *); | |
416351f2 | 704 | extern void afs_zap_data(struct afs_vnode *); |
260a9803 | 705 | extern int afs_validate(struct afs_vnode *, struct key *); |
a528d35e | 706 | extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int); |
31143d5d | 707 | extern int afs_setattr(struct dentry *, struct iattr *); |
b57922d9 | 708 | extern void afs_evict_inode(struct inode *); |
bec5eb61 | 709 | extern int afs_drop_inode(struct inode *); |
1da177e4 LT |
710 | |
711 | /* | |
712 | * main.c | |
713 | */ | |
0ad53eee | 714 | extern struct workqueue_struct *afs_wq; |
f044c884 DH |
715 | |
716 | static inline struct afs_net *afs_d2net(struct dentry *dentry) | |
717 | { | |
718 | return &__afs_net; | |
719 | } | |
720 | ||
721 | static inline struct afs_net *afs_i2net(struct inode *inode) | |
722 | { | |
723 | return &__afs_net; | |
724 | } | |
725 | ||
726 | static inline struct afs_net *afs_v2net(struct afs_vnode *vnode) | |
727 | { | |
728 | return &__afs_net; | |
729 | } | |
730 | ||
731 | static inline struct afs_net *afs_sock2net(struct sock *sk) | |
732 | { | |
733 | return &__afs_net; | |
734 | } | |
735 | ||
736 | static inline struct afs_net *afs_get_net(struct afs_net *net) | |
737 | { | |
738 | return net; | |
739 | } | |
740 | ||
741 | static inline void afs_put_net(struct afs_net *net) | |
742 | { | |
743 | } | |
1da177e4 | 744 | |
08e0e7c8 DH |
745 | /* |
746 | * misc.c | |
747 | */ | |
748 | extern int afs_abort_to_error(u32); | |
749 | ||
1da177e4 LT |
750 | /* |
751 | * mntpt.c | |
752 | */ | |
754661f1 | 753 | extern const struct inode_operations afs_mntpt_inode_operations; |
bec5eb61 | 754 | extern const struct inode_operations afs_autocell_inode_operations; |
4b6f5d20 | 755 | extern const struct file_operations afs_mntpt_file_operations; |
1da177e4 | 756 | |
d18610b0 | 757 | extern struct vfsmount *afs_d_automount(struct path *); |
08e0e7c8 | 758 | extern void afs_mntpt_kill_timer(void); |
1da177e4 | 759 | |
b4db2b35 AB |
760 | /* |
761 | * netdevices.c | |
762 | */ | |
763 | extern int afs_get_ipv4_interfaces(struct afs_interface *, size_t, bool); | |
764 | ||
1da177e4 LT |
765 | /* |
766 | * proc.c | |
767 | */ | |
f044c884 DH |
768 | extern int __net_init afs_proc_init(struct afs_net *); |
769 | extern void __net_exit afs_proc_cleanup(struct afs_net *); | |
770 | extern int afs_proc_cell_setup(struct afs_net *, struct afs_cell *); | |
771 | extern void afs_proc_cell_remove(struct afs_net *, struct afs_cell *); | |
1da177e4 | 772 | |
d2ddc776 DH |
773 | /* |
774 | * rotate.c | |
775 | */ | |
776 | extern bool afs_begin_vnode_operation(struct afs_fs_cursor *, struct afs_vnode *, | |
777 | struct key *); | |
778 | extern bool afs_select_fileserver(struct afs_fs_cursor *); | |
779 | extern bool afs_select_current_fileserver(struct afs_fs_cursor *); | |
780 | extern int afs_end_vnode_operation(struct afs_fs_cursor *); | |
781 | ||
08e0e7c8 DH |
782 | /* |
783 | * rxrpc.c | |
784 | */ | |
f044c884 | 785 | extern struct workqueue_struct *afs_async_calls; |
8324f0bc | 786 | |
f044c884 DH |
787 | extern int __net_init afs_open_socket(struct afs_net *); |
788 | extern void __net_exit afs_close_socket(struct afs_net *); | |
789 | extern void afs_charge_preallocation(struct work_struct *); | |
341f741f DH |
790 | extern void afs_put_call(struct afs_call *); |
791 | extern int afs_queue_call_work(struct afs_call *); | |
8b2a464c | 792 | extern long afs_make_call(struct afs_addr_cursor *, struct afs_call *, gfp_t, bool); |
f044c884 DH |
793 | extern struct afs_call *afs_alloc_flat_call(struct afs_net *, |
794 | const struct afs_call_type *, | |
08e0e7c8 DH |
795 | size_t, size_t); |
796 | extern void afs_flat_call_destructor(struct afs_call *); | |
08e0e7c8 | 797 | extern void afs_send_empty_reply(struct afs_call *); |
b908fe6b | 798 | extern void afs_send_simple_reply(struct afs_call *, const void *, size_t); |
d001648e | 799 | extern int afs_extract_data(struct afs_call *, void *, size_t, bool); |
08e0e7c8 | 800 | |
d001648e | 801 | static inline int afs_transfer_reply(struct afs_call *call) |
372ee163 | 802 | { |
d001648e | 803 | return afs_extract_data(call, call->buffer, call->reply_max, false); |
372ee163 DH |
804 | } |
805 | ||
00d3b7a4 DH |
806 | /* |
807 | * security.c | |
808 | */ | |
be080a6f | 809 | extern void afs_put_permits(struct afs_permits *); |
00d3b7a4 | 810 | extern void afs_clear_permits(struct afs_vnode *); |
be080a6f | 811 | extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int); |
416351f2 | 812 | extern void afs_zap_permits(struct rcu_head *); |
00d3b7a4 | 813 | extern struct key *afs_request_key(struct afs_cell *); |
10556cb2 | 814 | extern int afs_permission(struct inode *, int); |
be080a6f | 815 | extern void __exit afs_clean_up_permit_cache(void); |
00d3b7a4 | 816 | |
08e0e7c8 DH |
817 | /* |
818 | * server.c | |
819 | */ | |
820 | extern spinlock_t afs_server_peer_lock; | |
821 | ||
c435ee34 DH |
822 | static inline struct afs_server *afs_get_server(struct afs_server *server) |
823 | { | |
824 | atomic_inc(&server->usage); | |
825 | return server; | |
826 | } | |
08e0e7c8 | 827 | |
f044c884 DH |
828 | extern struct afs_server *afs_find_server(struct afs_net *, |
829 | const struct sockaddr_rxrpc *); | |
d2ddc776 DH |
830 | extern struct afs_server *afs_find_server_by_uuid(struct afs_net *, const uuid_t *); |
831 | extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *); | |
9ed900b1 | 832 | extern void afs_put_server(struct afs_net *, struct afs_server *); |
d2ddc776 DH |
833 | extern void afs_manage_servers(struct work_struct *); |
834 | extern void afs_servers_timer(struct timer_list *); | |
f044c884 | 835 | extern void __net_exit afs_purge_servers(struct afs_net *); |
d2ddc776 DH |
836 | extern bool afs_probe_fileserver(struct afs_fs_cursor *); |
837 | extern bool afs_check_server_record(struct afs_fs_cursor *, struct afs_server *); | |
08e0e7c8 | 838 | |
00d3b7a4 | 839 | /* |
d2ddc776 | 840 | * server_list.c |
00d3b7a4 | 841 | */ |
d2ddc776 DH |
842 | static inline struct afs_server_list *afs_get_serverlist(struct afs_server_list *slist) |
843 | { | |
844 | refcount_inc(&slist->usage); | |
845 | return slist; | |
846 | } | |
00d3b7a4 | 847 | |
d2ddc776 DH |
848 | extern void afs_put_serverlist(struct afs_net *, struct afs_server_list *); |
849 | extern struct afs_server_list *afs_alloc_server_list(struct afs_cell *, struct key *, | |
850 | struct afs_vldb_entry *, | |
851 | u8); | |
852 | extern bool afs_annotate_server_list(struct afs_server_list *, struct afs_server_list *); | |
08e0e7c8 DH |
853 | |
854 | /* | |
d2ddc776 | 855 | * super.c |
08e0e7c8 | 856 | */ |
d2ddc776 DH |
857 | extern int __init afs_fs_init(void); |
858 | extern void __exit afs_fs_exit(void); | |
08e0e7c8 DH |
859 | |
860 | /* | |
d2ddc776 | 861 | * vlclient.c |
08e0e7c8 | 862 | */ |
d2ddc776 DH |
863 | extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_net *, |
864 | struct afs_addr_cursor *, | |
865 | struct key *, const char *, int); | |
866 | extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_net *, struct afs_addr_cursor *, | |
867 | struct key *, const uuid_t *); | |
bf99a53c DH |
868 | extern int afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *, struct key *); |
869 | extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_net *, struct afs_addr_cursor *, | |
870 | struct key *, const uuid_t *); | |
08e0e7c8 DH |
871 | |
872 | /* | |
873 | * volume.c | |
874 | */ | |
d2ddc776 | 875 | static inline struct afs_volume *__afs_get_volume(struct afs_volume *volume) |
49566f6f DH |
876 | { |
877 | if (volume) | |
878 | atomic_inc(&volume->usage); | |
879 | return volume; | |
880 | } | |
08e0e7c8 | 881 | |
d2ddc776 DH |
882 | extern struct afs_volume *afs_create_volume(struct afs_mount_params *); |
883 | extern void afs_activate_volume(struct afs_volume *); | |
884 | extern void afs_deactivate_volume(struct afs_volume *); | |
9ed900b1 | 885 | extern void afs_put_volume(struct afs_cell *, struct afs_volume *); |
d2ddc776 | 886 | extern int afs_check_volume_status(struct afs_volume *, struct key *); |
08e0e7c8 | 887 | |
31143d5d DH |
888 | /* |
889 | * write.c | |
890 | */ | |
891 | extern int afs_set_page_dirty(struct page *); | |
892 | extern void afs_put_writeback(struct afs_writeback *); | |
15b4650e NP |
893 | extern int afs_write_begin(struct file *file, struct address_space *mapping, |
894 | loff_t pos, unsigned len, unsigned flags, | |
895 | struct page **pagep, void **fsdata); | |
896 | extern int afs_write_end(struct file *file, struct address_space *mapping, | |
897 | loff_t pos, unsigned len, unsigned copied, | |
898 | struct page *page, void *fsdata); | |
31143d5d DH |
899 | extern int afs_writepage(struct page *, struct writeback_control *); |
900 | extern int afs_writepages(struct address_space *, struct writeback_control *); | |
31143d5d | 901 | extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *); |
50b5551d | 902 | extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *); |
31143d5d | 903 | extern int afs_writeback_all(struct afs_vnode *); |
58fed94d | 904 | extern int afs_flush(struct file *, fl_owner_t); |
02c24a82 | 905 | extern int afs_fsync(struct file *, loff_t, loff_t, int); |
31143d5d | 906 | |
d3e3b7ea DH |
907 | /* |
908 | * xattr.c | |
909 | */ | |
910 | extern const struct xattr_handler *afs_xattr_handlers[]; | |
911 | extern ssize_t afs_listxattr(struct dentry *, char *, size_t); | |
31143d5d | 912 | |
d2ddc776 DH |
913 | |
914 | /* | |
915 | * Miscellaneous inline functions. | |
916 | */ | |
917 | static inline struct afs_vnode *AFS_FS_I(struct inode *inode) | |
918 | { | |
919 | return container_of(inode, struct afs_vnode, vfs_inode); | |
920 | } | |
921 | ||
922 | static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) | |
923 | { | |
924 | return &vnode->vfs_inode; | |
925 | } | |
926 | ||
927 | static inline void afs_vnode_commit_status(struct afs_fs_cursor *fc, | |
928 | struct afs_vnode *vnode, | |
929 | unsigned int cb_break) | |
930 | { | |
931 | if (fc->ac.error == 0) | |
932 | afs_cache_permit(vnode, fc->key, cb_break); | |
933 | } | |
934 | ||
935 | static inline void afs_check_for_remote_deletion(struct afs_fs_cursor *fc, | |
936 | struct afs_vnode *vnode) | |
937 | { | |
938 | if (fc->ac.error == -ENOENT) { | |
939 | set_bit(AFS_VNODE_DELETED, &vnode->flags); | |
940 | afs_break_callback(vnode); | |
941 | } | |
942 | } | |
943 | ||
944 | ||
08e0e7c8 DH |
945 | /*****************************************************************************/ |
946 | /* | |
947 | * debug tracing | |
948 | */ | |
8e8d7f13 DH |
949 | #include <trace/events/afs.h> |
950 | ||
08e0e7c8 DH |
951 | extern unsigned afs_debug; |
952 | ||
953 | #define dbgprintk(FMT,...) \ | |
ad16df84 | 954 | printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__) |
08e0e7c8 | 955 | |
530b6412 HH |
956 | #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) |
957 | #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) | |
08e0e7c8 DH |
958 | #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) |
959 | ||
960 | ||
961 | #if defined(__KDEBUG) | |
962 | #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__) | |
963 | #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__) | |
964 | #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__) | |
965 | ||
966 | #elif defined(CONFIG_AFS_DEBUG) | |
967 | #define AFS_DEBUG_KENTER 0x01 | |
968 | #define AFS_DEBUG_KLEAVE 0x02 | |
969 | #define AFS_DEBUG_KDEBUG 0x04 | |
970 | ||
971 | #define _enter(FMT,...) \ | |
972 | do { \ | |
973 | if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \ | |
974 | kenter(FMT,##__VA_ARGS__); \ | |
975 | } while (0) | |
976 | ||
977 | #define _leave(FMT,...) \ | |
978 | do { \ | |
979 | if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \ | |
980 | kleave(FMT,##__VA_ARGS__); \ | |
981 | } while (0) | |
982 | ||
983 | #define _debug(FMT,...) \ | |
984 | do { \ | |
985 | if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \ | |
986 | kdebug(FMT,##__VA_ARGS__); \ | |
987 | } while (0) | |
988 | ||
989 | #else | |
12fdff3f DH |
990 | #define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__) |
991 | #define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) | |
992 | #define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__) | |
08e0e7c8 DH |
993 | #endif |
994 | ||
995 | /* | |
996 | * debug assertion checking | |
997 | */ | |
998 | #if 1 // defined(__KDEBUGALL) | |
999 | ||
1000 | #define ASSERT(X) \ | |
1001 | do { \ | |
1002 | if (unlikely(!(X))) { \ | |
1003 | printk(KERN_ERR "\n"); \ | |
1004 | printk(KERN_ERR "AFS: Assertion failed\n"); \ | |
1005 | BUG(); \ | |
1006 | } \ | |
1007 | } while(0) | |
1008 | ||
1009 | #define ASSERTCMP(X, OP, Y) \ | |
1010 | do { \ | |
1011 | if (unlikely(!((X) OP (Y)))) { \ | |
1012 | printk(KERN_ERR "\n"); \ | |
1013 | printk(KERN_ERR "AFS: Assertion failed\n"); \ | |
1014 | printk(KERN_ERR "%lu " #OP " %lu is false\n", \ | |
1015 | (unsigned long)(X), (unsigned long)(Y)); \ | |
1016 | printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ | |
1017 | (unsigned long)(X), (unsigned long)(Y)); \ | |
1018 | BUG(); \ | |
1019 | } \ | |
1020 | } while(0) | |
1021 | ||
416351f2 DH |
1022 | #define ASSERTRANGE(L, OP1, N, OP2, H) \ |
1023 | do { \ | |
1024 | if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \ | |
1025 | printk(KERN_ERR "\n"); \ | |
1026 | printk(KERN_ERR "AFS: Assertion failed\n"); \ | |
1027 | printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \ | |
1028 | (unsigned long)(L), (unsigned long)(N), \ | |
1029 | (unsigned long)(H)); \ | |
1030 | printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \ | |
1031 | (unsigned long)(L), (unsigned long)(N), \ | |
1032 | (unsigned long)(H)); \ | |
1033 | BUG(); \ | |
1034 | } \ | |
1035 | } while(0) | |
1036 | ||
08e0e7c8 DH |
1037 | #define ASSERTIF(C, X) \ |
1038 | do { \ | |
1039 | if (unlikely((C) && !(X))) { \ | |
1040 | printk(KERN_ERR "\n"); \ | |
1041 | printk(KERN_ERR "AFS: Assertion failed\n"); \ | |
1042 | BUG(); \ | |
1043 | } \ | |
1044 | } while(0) | |
1045 | ||
1046 | #define ASSERTIFCMP(C, X, OP, Y) \ | |
1047 | do { \ | |
1048 | if (unlikely((C) && !((X) OP (Y)))) { \ | |
1049 | printk(KERN_ERR "\n"); \ | |
1050 | printk(KERN_ERR "AFS: Assertion failed\n"); \ | |
1051 | printk(KERN_ERR "%lu " #OP " %lu is false\n", \ | |
1052 | (unsigned long)(X), (unsigned long)(Y)); \ | |
1053 | printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ | |
1054 | (unsigned long)(X), (unsigned long)(Y)); \ | |
1055 | BUG(); \ | |
1056 | } \ | |
1057 | } while(0) | |
1058 | ||
1059 | #else | |
1060 | ||
1061 | #define ASSERT(X) \ | |
1062 | do { \ | |
1063 | } while(0) | |
1064 | ||
1065 | #define ASSERTCMP(X, OP, Y) \ | |
1066 | do { \ | |
1067 | } while(0) | |
1068 | ||
416351f2 DH |
1069 | #define ASSERTRANGE(L, OP1, N, OP2, H) \ |
1070 | do { \ | |
1071 | } while(0) | |
1072 | ||
08e0e7c8 DH |
1073 | #define ASSERTIF(C, X) \ |
1074 | do { \ | |
1075 | } while(0) | |
1076 | ||
1077 | #define ASSERTIFCMP(C, X, OP, Y) \ | |
1078 | do { \ | |
1079 | } while(0) | |
1080 | ||
1081 | #endif /* __KDEBUGALL */ |