]>
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> |
0722f186 | 24 | #include <linux/mm_types.h> |
0a5143f2 | 25 | #include <linux/dns_resolver.h> |
f044c884 | 26 | #include <net/net_namespace.h> |
5b86d4ff DH |
27 | #include <net/netns/generic.h> |
28 | #include <net/sock.h> | |
8324f0bc | 29 | #include <net/af_rxrpc.h> |
00c541ea | 30 | |
08e0e7c8 DH |
31 | #include "afs.h" |
32 | #include "afs_vl.h" | |
33 | ||
34 | #define AFS_CELL_MAX_ADDRS 15 | |
35 | ||
31143d5d | 36 | struct pagevec; |
08e0e7c8 DH |
37 | struct afs_call; |
38 | ||
00d3b7a4 DH |
39 | struct afs_mount_params { |
40 | bool rwpath; /* T if the parent should be considered R/W */ | |
41 | bool force; /* T to force cell type */ | |
bec5eb61 | 42 | bool autocell; /* T if set auto mount operation */ |
4d673da1 | 43 | bool dyn_root; /* T if dynamic root */ |
00d3b7a4 DH |
44 | afs_voltype_t type; /* type of volume requested */ |
45 | int volnamesz; /* size of volume name */ | |
46 | const char *volname; /* name of volume to mount */ | |
5b86d4ff DH |
47 | struct net *net_ns; /* Network namespace in effect */ |
48 | struct afs_net *net; /* the AFS net namespace stuff */ | |
00d3b7a4 DH |
49 | struct afs_cell *cell; /* cell in which to find volume */ |
50 | struct afs_volume *volume; /* volume record */ | |
51 | struct key *key; /* key to use for secure mounting */ | |
52 | }; | |
53 | ||
c435ee34 DH |
54 | struct afs_iget_data { |
55 | struct afs_fid fid; | |
56 | struct afs_volume *volume; /* volume on which resides */ | |
57 | }; | |
58 | ||
8e8d7f13 | 59 | enum afs_call_state { |
98bf40cd DH |
60 | AFS_CALL_CL_REQUESTING, /* Client: Request is being sent */ |
61 | AFS_CALL_CL_AWAIT_REPLY, /* Client: Awaiting reply */ | |
62 | AFS_CALL_CL_PROC_REPLY, /* Client: rxrpc call complete; processing reply */ | |
63 | AFS_CALL_SV_AWAIT_OP_ID, /* Server: Awaiting op ID */ | |
64 | AFS_CALL_SV_AWAIT_REQUEST, /* Server: Awaiting request data */ | |
65 | AFS_CALL_SV_REPLYING, /* Server: Replying */ | |
66 | AFS_CALL_SV_AWAIT_ACK, /* Server: Awaiting final ACK */ | |
67 | AFS_CALL_COMPLETE, /* Completed or failed */ | |
8e8d7f13 | 68 | }; |
f044c884 | 69 | |
8b2a464c DH |
70 | /* |
71 | * List of server addresses. | |
72 | */ | |
73 | struct afs_addr_list { | |
74 | struct rcu_head rcu; /* Must be first */ | |
75 | refcount_t usage; | |
d2ddc776 | 76 | u32 version; /* Version */ |
68eb64c3 DH |
77 | unsigned char max_addrs; |
78 | unsigned char nr_addrs; | |
79 | unsigned char index; /* Address currently in use */ | |
80 | unsigned char nr_ipv4; /* Number of IPv4 addresses */ | |
0a5143f2 DH |
81 | enum dns_record_source source:8; |
82 | enum dns_lookup_status status:8; | |
bf99a53c DH |
83 | unsigned long probed; /* Mask of servers that have been probed */ |
84 | unsigned long yfs; /* Mask of servers that are YFS */ | |
8b2a464c | 85 | struct sockaddr_rxrpc addrs[]; |
68eb64c3 | 86 | #define AFS_MAX_ADDRESSES ((unsigned int)(sizeof(unsigned long) * 8)) |
8b2a464c DH |
87 | }; |
88 | ||
08e0e7c8 DH |
89 | /* |
90 | * a record of an in-progress RxRPC call | |
91 | */ | |
92 | struct afs_call { | |
93 | const struct afs_call_type *type; /* type of call */ | |
08e0e7c8 | 94 | wait_queue_head_t waitq; /* processes awaiting completion */ |
341f741f | 95 | struct work_struct async_work; /* async I/O processor */ |
08e0e7c8 | 96 | struct work_struct work; /* actual work processor */ |
08e0e7c8 DH |
97 | struct rxrpc_call *rxcall; /* RxRPC call handle */ |
98 | struct key *key; /* security for this call */ | |
f044c884 | 99 | struct afs_net *net; /* The network namespace */ |
d0676a16 | 100 | struct afs_server *cm_server; /* Server affected by incoming CM call */ |
d2ddc776 | 101 | struct afs_cb_interest *cbi; /* Callback interest for server used */ |
08e0e7c8 | 102 | void *request; /* request data (first part) */ |
4343d008 | 103 | struct address_space *mapping; /* Pages being written from */ |
12bdcf33 DH |
104 | struct iov_iter iter; /* Buffer iterator */ |
105 | struct iov_iter *_iter; /* Iterator currently in use */ | |
106 | union { /* Convenience for ->iter */ | |
107 | struct kvec kvec[1]; | |
108 | struct bio_vec bvec[1]; | |
109 | }; | |
08e0e7c8 | 110 | void *buffer; /* reply receive buffer */ |
97e3043a | 111 | void *reply[4]; /* Where to put the reply */ |
31143d5d DH |
112 | pgoff_t first; /* first page in mapping to deal with */ |
113 | pgoff_t last; /* last page in mapping to deal with */ | |
341f741f | 114 | atomic_t usage; |
8e8d7f13 | 115 | enum afs_call_state state; |
98bf40cd | 116 | spinlock_t state_lock; |
08e0e7c8 | 117 | int error; /* error code */ |
d001648e | 118 | u32 abort_code; /* Remote abort ID or 0 */ |
08e0e7c8 DH |
119 | unsigned request_size; /* size of request data */ |
120 | unsigned reply_max; /* maximum size of reply */ | |
31143d5d | 121 | unsigned first_offset; /* offset into mapping[first] */ |
c435ee34 | 122 | unsigned int cb_break; /* cb_break + cb_s_break before the call */ |
bcd89270 MD |
123 | union { |
124 | unsigned last_to; /* amount of mapping[last] */ | |
125 | unsigned count2; /* count used in unmarshalling */ | |
126 | }; | |
08e0e7c8 DH |
127 | unsigned char unmarshall; /* unmarshalling phase */ |
128 | bool incoming; /* T if incoming call */ | |
31143d5d | 129 | bool send_pages; /* T if data from mapping should be sent */ |
d001648e | 130 | bool need_attention; /* T if RxRPC poked us */ |
56ff9c83 | 131 | bool async; /* T if asynchronous */ |
33cd7f2b | 132 | bool ret_reply0; /* T if should return reply[0] on success */ |
a68f4a27 | 133 | bool upgrade; /* T to request service upgrade */ |
12d8e95a | 134 | bool want_reply_time; /* T if want reply_time */ |
bf99a53c | 135 | u16 service_id; /* Actual service ID (after upgrade) */ |
a25e21f0 | 136 | unsigned int debug_id; /* Trace ID */ |
50a2c953 | 137 | u32 operation_ID; /* operation ID for an incoming call */ |
08e0e7c8 | 138 | u32 count; /* count for use in unmarshalling */ |
12bdcf33 DH |
139 | union { /* place to extract temporary data */ |
140 | struct { | |
141 | __be32 tmp_u; | |
142 | __be32 tmp; | |
143 | } __attribute__((packed)); | |
144 | __be64 tmp64; | |
145 | }; | |
0c3a5ac2 DH |
146 | afs_dataversion_t expected_version; /* Updated version expected from store */ |
147 | afs_dataversion_t expected_version_2; /* 2nd updated version expected from store */ | |
12d8e95a | 148 | ktime_t reply_time; /* Time of first reply packet */ |
08e0e7c8 DH |
149 | }; |
150 | ||
151 | struct afs_call_type { | |
00d3b7a4 | 152 | const char *name; |
025db80c | 153 | unsigned int op; /* Really enum afs_fs_operation */ |
00d3b7a4 | 154 | |
08e0e7c8 DH |
155 | /* deliver request or reply data to an call |
156 | * - returning an error will cause the call to be aborted | |
157 | */ | |
d001648e | 158 | int (*deliver)(struct afs_call *call); |
08e0e7c8 | 159 | |
08e0e7c8 DH |
160 | /* clean up a call */ |
161 | void (*destructor)(struct afs_call *call); | |
341f741f DH |
162 | |
163 | /* Work function */ | |
164 | void (*work)(struct work_struct *work); | |
08e0e7c8 DH |
165 | }; |
166 | ||
4343d008 DH |
167 | /* |
168 | * Key available for writeback on a file. | |
169 | */ | |
170 | struct afs_wb_key { | |
171 | refcount_t usage; | |
172 | struct key *key; | |
173 | struct list_head vnode_link; /* Link in vnode->wb_keys */ | |
174 | }; | |
175 | ||
215804a9 DH |
176 | /* |
177 | * AFS open file information record. Pointed to by file->private_data. | |
178 | */ | |
179 | struct afs_file { | |
180 | struct key *key; /* The key this file was opened with */ | |
4343d008 | 181 | struct afs_wb_key *wb; /* Writeback key record for this file */ |
215804a9 DH |
182 | }; |
183 | ||
184 | static inline struct key *afs_file_key(struct file *file) | |
185 | { | |
186 | struct afs_file *af = file->private_data; | |
187 | ||
188 | return af->key; | |
189 | } | |
190 | ||
196ee9cd DH |
191 | /* |
192 | * Record of an outstanding read operation on a vnode. | |
193 | */ | |
194 | struct afs_read { | |
195 | loff_t pos; /* Where to start reading */ | |
e8e581a8 | 196 | loff_t len; /* How much we're asking for */ |
196ee9cd | 197 | loff_t actual_len; /* How much we're actually getting */ |
6a0e3999 | 198 | loff_t remain; /* Amount remaining */ |
f3ddee8d DH |
199 | loff_t file_size; /* File size returned by server */ |
200 | afs_dataversion_t data_version; /* Version number returned by server */ | |
201 | refcount_t usage; | |
196ee9cd | 202 | unsigned int index; /* Which page we're reading into */ |
196ee9cd | 203 | unsigned int nr_pages; |
12bdcf33 | 204 | unsigned int offset; /* offset into current page */ |
196ee9cd | 205 | void (*page_done)(struct afs_call *, struct afs_read *); |
f3ddee8d DH |
206 | struct page **pages; |
207 | struct page *array[]; | |
196ee9cd DH |
208 | }; |
209 | ||
08e0e7c8 DH |
210 | /* |
211 | * AFS superblock private data | |
212 | * - there's one superblock per volume | |
213 | */ | |
214 | struct afs_super_info { | |
5b86d4ff | 215 | struct net *net_ns; /* Network namespace */ |
49566f6f | 216 | struct afs_cell *cell; /* The cell in which the volume resides */ |
08e0e7c8 | 217 | struct afs_volume *volume; /* volume record */ |
4d673da1 | 218 | bool dyn_root; /* True if dynamic root */ |
08e0e7c8 | 219 | }; |
1da177e4 | 220 | |
08e0e7c8 DH |
221 | static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) |
222 | { | |
223 | return sb->s_fs_info; | |
1da177e4 LT |
224 | } |
225 | ||
08e0e7c8 DH |
226 | extern struct file_system_type afs_fs_type; |
227 | ||
6f8880d8 DH |
228 | /* |
229 | * Set of substitutes for @sys. | |
230 | */ | |
231 | struct afs_sysnames { | |
232 | #define AFS_NR_SYSNAME 16 | |
233 | char *subs[AFS_NR_SYSNAME]; | |
234 | refcount_t usage; | |
235 | unsigned short nr; | |
6f8880d8 DH |
236 | char blank[1]; |
237 | }; | |
238 | ||
f044c884 DH |
239 | /* |
240 | * AFS network namespace record. | |
241 | */ | |
242 | struct afs_net { | |
5b86d4ff | 243 | struct net *net; /* Backpointer to the owning net namespace */ |
f044c884 DH |
244 | struct afs_uuid uuid; |
245 | bool live; /* F if this namespace is being removed */ | |
246 | ||
247 | /* AF_RXRPC I/O stuff */ | |
248 | struct socket *socket; | |
249 | struct afs_call *spare_incoming_call; | |
250 | struct work_struct charge_preallocation_work; | |
251 | struct mutex socket_mutex; | |
252 | atomic_t nr_outstanding_calls; | |
253 | atomic_t nr_superblocks; | |
254 | ||
255 | /* Cell database */ | |
989782dc | 256 | struct rb_root cells; |
1588def9 | 257 | struct afs_cell __rcu *ws_cell; |
989782dc DH |
258 | struct work_struct cells_manager; |
259 | struct timer_list cells_timer; | |
260 | atomic_t cells_outstanding; | |
261 | seqlock_t cells_lock; | |
f044c884 | 262 | |
0da0b7fd | 263 | struct mutex proc_cells_lock; |
6b3944e4 | 264 | struct hlist_head proc_cells; |
f044c884 | 265 | |
d2ddc776 DH |
266 | /* Known servers. Theoretically each fileserver can only be in one |
267 | * cell, but in practice, people create aliases and subsets and there's | |
268 | * no easy way to distinguish them. | |
269 | */ | |
270 | seqlock_t fs_lock; /* For fs_servers */ | |
271 | struct rb_root fs_servers; /* afs_server (by server UUID or address) */ | |
272 | struct list_head fs_updates; /* afs_server (by update_at) */ | |
273 | struct hlist_head fs_proc; /* procfs servers list */ | |
f044c884 | 274 | |
d2ddc776 DH |
275 | struct hlist_head fs_addresses4; /* afs_server (by lowest IPv4 addr) */ |
276 | struct hlist_head fs_addresses6; /* afs_server (by lowest IPv6 addr) */ | |
277 | seqlock_t fs_addr_lock; /* For fs_addresses[46] */ | |
f044c884 | 278 | |
d2ddc776 DH |
279 | struct work_struct fs_manager; |
280 | struct timer_list fs_timer; | |
59fa1c4a | 281 | atomic_t servers_outstanding; |
f044c884 | 282 | |
d2ddc776 DH |
283 | /* File locking renewal management */ |
284 | struct mutex lock_manager_mutex; | |
285 | ||
f044c884 | 286 | /* Misc */ |
0da0b7fd | 287 | struct super_block *dynroot_sb; /* Dynamic root mount superblock */ |
d55b4da4 | 288 | struct proc_dir_entry *proc_afs; /* /proc/net/afs directory */ |
6f8880d8 DH |
289 | struct afs_sysnames *sysnames; |
290 | rwlock_t sysnames_lock; | |
d55b4da4 DH |
291 | |
292 | /* Statistics counters */ | |
293 | atomic_t n_lookup; /* Number of lookups done */ | |
294 | atomic_t n_reval; /* Number of dentries needing revalidation */ | |
295 | atomic_t n_inval; /* Number of invalidations by the server */ | |
f3ddee8d | 296 | atomic_t n_relpg; /* Number of invalidations by releasepage */ |
d55b4da4 | 297 | atomic_t n_read_dir; /* Number of directory pages read */ |
63a4681f DH |
298 | atomic_t n_dir_cr; /* Number of directory entry creation edits */ |
299 | atomic_t n_dir_rm; /* Number of directory entry removal edits */ | |
76a5cb6f DH |
300 | atomic_t n_stores; /* Number of store ops */ |
301 | atomic_long_t n_store_bytes; /* Number of bytes stored */ | |
302 | atomic_long_t n_fetch_bytes; /* Number of bytes fetched */ | |
303 | atomic_t n_fetches; /* Number of data fetch ops */ | |
f044c884 DH |
304 | }; |
305 | ||
6f8880d8 | 306 | extern const char afs_init_sysname[]; |
f044c884 | 307 | |
989782dc DH |
308 | enum afs_cell_state { |
309 | AFS_CELL_UNSET, | |
310 | AFS_CELL_ACTIVATING, | |
311 | AFS_CELL_ACTIVE, | |
312 | AFS_CELL_DEACTIVATING, | |
313 | AFS_CELL_INACTIVE, | |
314 | AFS_CELL_FAILED, | |
315 | }; | |
316 | ||
08e0e7c8 | 317 | /* |
d2ddc776 DH |
318 | * AFS cell record. |
319 | * | |
320 | * This is a tricky concept to get right as it is possible to create aliases | |
321 | * simply by pointing AFSDB/SRV records for two names at the same set of VL | |
322 | * servers; it is also possible to do things like setting up two sets of VL | |
323 | * servers, one of which provides a superset of the volumes provided by the | |
324 | * other (for internal/external division, for example). | |
325 | * | |
326 | * Cells only exist in the sense that (a) a cell's name maps to a set of VL | |
327 | * servers and (b) a cell's name is used by the client to select the key to use | |
328 | * for authentication and encryption. The cell name is not typically used in | |
329 | * the protocol. | |
330 | * | |
331 | * There is no easy way to determine if two cells are aliases or one is a | |
332 | * subset of another. | |
08e0e7c8 DH |
333 | */ |
334 | struct afs_cell { | |
989782dc DH |
335 | union { |
336 | struct rcu_head rcu; | |
337 | struct rb_node net_node; /* Node in net->cells */ | |
338 | }; | |
339 | struct afs_net *net; | |
00d3b7a4 | 340 | struct key *anonymous_key; /* anonymous user key for this cell */ |
989782dc | 341 | struct work_struct manager; /* Manager for init/deinit/dns */ |
6b3944e4 | 342 | struct hlist_node proc_link; /* /proc cell list link */ |
9b3f26c9 DH |
343 | #ifdef CONFIG_AFS_FSCACHE |
344 | struct fscache_cookie *cache; /* caching cookie */ | |
08e0e7c8 | 345 | #endif |
989782dc DH |
346 | time64_t dns_expiry; /* Time AFSDB/SRV record expires */ |
347 | time64_t last_inactive; /* Time of last drop of usage count */ | |
348 | atomic_t usage; | |
349 | unsigned long flags; | |
350 | #define AFS_CELL_FL_NOT_READY 0 /* The cell record is not ready for use */ | |
351 | #define AFS_CELL_FL_NO_GC 1 /* The cell was added manually, don't auto-gc */ | |
352 | #define AFS_CELL_FL_NOT_FOUND 2 /* Permanent DNS error */ | |
353 | #define AFS_CELL_FL_DNS_FAIL 3 /* Failed to access DNS */ | |
8b2a464c | 354 | #define AFS_CELL_FL_NO_LOOKUP_YET 4 /* Not completed first DNS lookup yet */ |
989782dc DH |
355 | enum afs_cell_state state; |
356 | short error; | |
357 | ||
d2ddc776 DH |
358 | /* Active fileserver interaction state. */ |
359 | struct list_head proc_volumes; /* procfs volume list */ | |
360 | rwlock_t proc_lock; | |
989782dc | 361 | |
d2ddc776 | 362 | /* VL server list. */ |
0a5143f2 DH |
363 | rwlock_t vl_servers_lock; /* Lock on vl_servers */ |
364 | struct afs_vlserver_list __rcu *vl_servers; | |
365 | ||
989782dc DH |
366 | u8 name_len; /* Length of name */ |
367 | char name[64 + 1]; /* Cell name, case-flattened and NUL-padded */ | |
08e0e7c8 DH |
368 | }; |
369 | ||
0a5143f2 DH |
370 | /* |
371 | * Volume Location server record. | |
372 | */ | |
373 | struct afs_vlserver { | |
374 | struct rcu_head rcu; | |
375 | struct afs_addr_list __rcu *addresses; /* List of addresses for this VL server */ | |
376 | unsigned long flags; | |
377 | #define AFS_VLSERVER_FL_PROBED 0 /* The VL server has been probed */ | |
378 | #define AFS_VLSERVER_FL_PROBING 1 /* VL server is being probed */ | |
379 | rwlock_t lock; /* Lock on addresses */ | |
380 | atomic_t usage; | |
381 | u16 name_len; /* Length of name */ | |
382 | u16 port; | |
383 | char name[]; /* Server name, case-flattened */ | |
384 | }; | |
385 | ||
386 | /* | |
387 | * Weighted list of Volume Location servers. | |
388 | */ | |
389 | struct afs_vlserver_entry { | |
390 | u16 priority; /* Preference (as SRV) */ | |
391 | u16 weight; /* Weight (as SRV) */ | |
392 | enum dns_record_source source:8; | |
393 | enum dns_lookup_status status:8; | |
394 | struct afs_vlserver *server; | |
395 | }; | |
396 | ||
397 | struct afs_vlserver_list { | |
398 | struct rcu_head rcu; | |
399 | atomic_t usage; | |
400 | u8 nr_servers; | |
401 | u8 index; /* Server currently in use */ | |
402 | enum dns_record_source source:8; | |
403 | enum dns_lookup_status status:8; | |
404 | rwlock_t lock; | |
405 | struct afs_vlserver_entry servers[]; | |
406 | }; | |
407 | ||
08e0e7c8 | 408 | /* |
d2ddc776 DH |
409 | * Cached VLDB entry. |
410 | * | |
411 | * This is pointed to by cell->vldb_entries, indexed by name. | |
08e0e7c8 | 412 | */ |
d2ddc776 DH |
413 | struct afs_vldb_entry { |
414 | afs_volid_t vid[3]; /* Volume IDs for R/W, R/O and Bak volumes */ | |
00d3b7a4 | 415 | |
d2ddc776 DH |
416 | unsigned long flags; |
417 | #define AFS_VLDB_HAS_RW 0 /* - R/W volume exists */ | |
418 | #define AFS_VLDB_HAS_RO 1 /* - R/O volume exists */ | |
419 | #define AFS_VLDB_HAS_BAK 2 /* - Backup volume exists */ | |
420 | #define AFS_VLDB_QUERY_VALID 3 /* - Record is valid */ | |
421 | #define AFS_VLDB_QUERY_ERROR 4 /* - VL server returned error */ | |
422 | ||
423 | uuid_t fs_server[AFS_NMAXNSERVERS]; | |
424 | u8 fs_mask[AFS_NMAXNSERVERS]; | |
08e0e7c8 DH |
425 | #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */ |
426 | #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */ | |
427 | #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */ | |
d2ddc776 DH |
428 | short error; |
429 | u8 nr_servers; /* Number of server records */ | |
430 | u8 name_len; | |
431 | u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ | |
08e0e7c8 DH |
432 | }; |
433 | ||
434 | /* | |
d2ddc776 | 435 | * Record of fileserver with which we're actively communicating. |
08e0e7c8 DH |
436 | */ |
437 | struct afs_server { | |
d2ddc776 DH |
438 | struct rcu_head rcu; |
439 | union { | |
440 | uuid_t uuid; /* Server ID */ | |
441 | struct afs_uuid _uuid; | |
442 | }; | |
443 | ||
444 | struct afs_addr_list __rcu *addresses; | |
445 | struct rb_node uuid_rb; /* Link in net->servers */ | |
446 | struct hlist_node addr4_link; /* Link in net->fs_addresses4 */ | |
447 | struct hlist_node addr6_link; /* Link in net->fs_addresses6 */ | |
448 | struct hlist_node proc_link; /* Link in net->fs_proc */ | |
449 | struct afs_server *gc_next; /* Next server in manager's list */ | |
450 | time64_t put_time; /* Time at which last put */ | |
451 | time64_t update_at; /* Time at which to next update the record */ | |
c435ee34 | 452 | unsigned long flags; |
d2ddc776 DH |
453 | #define AFS_SERVER_FL_NEW 0 /* New server, don't inc cb_s_break */ |
454 | #define AFS_SERVER_FL_NOT_READY 1 /* The record is not ready for use */ | |
455 | #define AFS_SERVER_FL_NOT_FOUND 2 /* VL server says no such server */ | |
456 | #define AFS_SERVER_FL_VL_FAIL 3 /* Failed to access VL server */ | |
457 | #define AFS_SERVER_FL_UPDATING 4 | |
458 | #define AFS_SERVER_FL_PROBED 5 /* The fileserver has been probed */ | |
459 | #define AFS_SERVER_FL_PROBING 6 /* Fileserver is being probed */ | |
5cf9dd55 | 460 | #define AFS_SERVER_FL_NO_IBULK 7 /* Fileserver doesn't support FS.InlineBulkStatus */ |
f2686b09 | 461 | #define AFS_SERVER_FL_MAY_HAVE_CB 8 /* May have callbacks on this fileserver */ |
30062bd1 DH |
462 | #define AFS_SERVER_FL_IS_YFS 9 /* Server is YFS not AFS */ |
463 | #define AFS_SERVER_FL_NO_RM2 10 /* Fileserver doesn't support YFS.RemoveFile2 */ | |
d2ddc776 DH |
464 | atomic_t usage; |
465 | u32 addr_version; /* Address list version */ | |
08e0e7c8 DH |
466 | |
467 | /* file service access */ | |
d2ddc776 | 468 | rwlock_t fs_lock; /* access lock */ |
08e0e7c8 DH |
469 | |
470 | /* callback promise management */ | |
47ea0f2e | 471 | struct hlist_head cb_volumes; /* List of volume interests on this server */ |
c435ee34 DH |
472 | unsigned cb_s_break; /* Break-everything counter. */ |
473 | rwlock_t cb_break_lock; /* Volume finding lock */ | |
474 | }; | |
475 | ||
47ea0f2e DH |
476 | /* |
477 | * Volume collation in the server's callback interest list. | |
478 | */ | |
479 | struct afs_vol_interest { | |
480 | struct hlist_node srv_link; /* Link in server->cb_volumes */ | |
481 | struct hlist_head cb_interests; /* List of callback interests on the server */ | |
482 | afs_volid_t vid; /* Volume ID to match */ | |
483 | unsigned int usage; | |
484 | }; | |
485 | ||
c435ee34 DH |
486 | /* |
487 | * Interest by a superblock on a server. | |
488 | */ | |
489 | struct afs_cb_interest { | |
47ea0f2e DH |
490 | struct hlist_node cb_vlink; /* Link in vol_interest->cb_interests */ |
491 | struct afs_vol_interest *vol_interest; | |
c435ee34 DH |
492 | struct afs_server *server; /* Server on which this interest resides */ |
493 | struct super_block *sb; /* Superblock on which inodes reside */ | |
494 | afs_volid_t vid; /* Volume ID to match */ | |
495 | refcount_t usage; | |
08e0e7c8 DH |
496 | }; |
497 | ||
498 | /* | |
d2ddc776 DH |
499 | * Replaceable server list. |
500 | */ | |
501 | struct afs_server_entry { | |
502 | struct afs_server *server; | |
503 | struct afs_cb_interest *cb_interest; | |
504 | }; | |
505 | ||
506 | struct afs_server_list { | |
507 | refcount_t usage; | |
508 | unsigned short nr_servers; | |
509 | unsigned short index; /* Server currently in use */ | |
510 | unsigned short vnovol_mask; /* Servers to be skipped due to VNOVOL */ | |
511 | unsigned int seq; /* Set to ->servers_seq when installed */ | |
d4a96bec | 512 | rwlock_t lock; |
d2ddc776 DH |
513 | struct afs_server_entry servers[]; |
514 | }; | |
515 | ||
516 | /* | |
517 | * Live AFS volume management. | |
08e0e7c8 DH |
518 | */ |
519 | struct afs_volume { | |
d2ddc776 | 520 | afs_volid_t vid; /* volume ID */ |
08e0e7c8 | 521 | atomic_t usage; |
d2ddc776 DH |
522 | time64_t update_at; /* Time at which to next update */ |
523 | struct afs_cell *cell; /* Cell to which belongs (pins ref) */ | |
524 | struct list_head proc_link; /* Link in cell->vl_proc */ | |
525 | unsigned long flags; | |
526 | #define AFS_VOLUME_NEEDS_UPDATE 0 /* - T if an update needs performing */ | |
527 | #define AFS_VOLUME_UPDATING 1 /* - T if an update is in progress */ | |
528 | #define AFS_VOLUME_WAIT 2 /* - T if users must wait for update */ | |
529 | #define AFS_VOLUME_DELETED 3 /* - T if volume appears deleted */ | |
530 | #define AFS_VOLUME_OFFLINE 4 /* - T if volume offline notice given */ | |
531 | #define AFS_VOLUME_BUSY 5 /* - T if volume busy notice given */ | |
9b3f26c9 DH |
532 | #ifdef CONFIG_AFS_FSCACHE |
533 | struct fscache_cookie *cache; /* caching cookie */ | |
08e0e7c8 | 534 | #endif |
d2ddc776 DH |
535 | struct afs_server_list *servers; /* List of servers on which volume resides */ |
536 | rwlock_t servers_lock; /* Lock for ->servers */ | |
537 | unsigned int servers_seq; /* Incremented each time ->servers changes */ | |
538 | ||
68251f0a DH |
539 | unsigned cb_v_break; /* Break-everything counter. */ |
540 | rwlock_t cb_break_lock; | |
541 | ||
08e0e7c8 | 542 | afs_voltype_t type; /* type of volume */ |
d2ddc776 | 543 | short error; |
08e0e7c8 | 544 | char type_force; /* force volume type (suppress R/O -> R/W) */ |
d2ddc776 DH |
545 | u8 name_len; |
546 | u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ | |
08e0e7c8 DH |
547 | }; |
548 | ||
0fafdc9f DH |
549 | enum afs_lock_state { |
550 | AFS_VNODE_LOCK_NONE, /* The vnode has no lock on the server */ | |
551 | AFS_VNODE_LOCK_WAITING_FOR_CB, /* We're waiting for the server to break the callback */ | |
552 | AFS_VNODE_LOCK_SETTING, /* We're asking the server for a lock */ | |
553 | AFS_VNODE_LOCK_GRANTED, /* We have a lock on the server */ | |
554 | AFS_VNODE_LOCK_EXTENDING, /* We're extending a lock on the server */ | |
555 | AFS_VNODE_LOCK_NEED_UNLOCK, /* We need to unlock on the server */ | |
556 | AFS_VNODE_LOCK_UNLOCKING, /* We're telling the server to unlock */ | |
557 | }; | |
558 | ||
08e0e7c8 | 559 | /* |
f8de483e DH |
560 | * AFS inode private data. |
561 | * | |
562 | * Note that afs_alloc_inode() *must* reset anything that could incorrectly | |
563 | * leak from one inode to another. | |
08e0e7c8 DH |
564 | */ |
565 | struct afs_vnode { | |
566 | struct inode vfs_inode; /* the VFS's inode record */ | |
567 | ||
568 | struct afs_volume *volume; /* volume on which vnode resides */ | |
08e0e7c8 DH |
569 | struct afs_fid fid; /* the file identifier for this inode */ |
570 | struct afs_file_status status; /* AFS status info for this file */ | |
a4ff7401 | 571 | afs_dataversion_t invalid_before; /* Child dentries are invalid before this */ |
9b3f26c9 DH |
572 | #ifdef CONFIG_AFS_FSCACHE |
573 | struct fscache_cookie *cache; /* caching cookie */ | |
08e0e7c8 | 574 | #endif |
fe342cf7 | 575 | struct afs_permits __rcu *permit_cache; /* cache of permits so far obtained */ |
d2ddc776 | 576 | struct mutex io_lock; /* Lock for serialising I/O on this mutex */ |
b61f7dcf | 577 | struct rw_semaphore validate_lock; /* lock for validating this vnode */ |
4343d008 | 578 | spinlock_t wb_lock; /* lock for wb_keys */ |
08e0e7c8 DH |
579 | spinlock_t lock; /* waitqueue/flags lock */ |
580 | unsigned long flags; | |
c435ee34 | 581 | #define AFS_VNODE_CB_PROMISED 0 /* Set if vnode has a callback promise */ |
260a9803 | 582 | #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */ |
f3ddee8d | 583 | #define AFS_VNODE_DIR_VALID 2 /* Set if dir contents are valid */ |
08e0e7c8 DH |
584 | #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ |
585 | #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ | |
586 | #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ | |
0fafdc9f DH |
587 | #define AFS_VNODE_AUTOCELL 6 /* set if Vnode is an auto mount point */ |
588 | #define AFS_VNODE_PSEUDODIR 7 /* set if Vnode is a pseudo directory */ | |
5a813276 | 589 | #define AFS_VNODE_NEW_CONTENT 8 /* Set if file has new content (create/trunc-0) */ |
08e0e7c8 | 590 | |
4343d008 | 591 | struct list_head wb_keys; /* List of keys available for writeback */ |
e8d6c554 DH |
592 | struct list_head pending_locks; /* locks waiting to be granted */ |
593 | struct list_head granted_locks; /* locks granted on this file */ | |
594 | struct delayed_work lock_work; /* work to be done in locking */ | |
0fafdc9f DH |
595 | struct key *lock_key; /* Key to be used in lock ops */ |
596 | enum afs_lock_state lock_state : 8; | |
597 | afs_lock_type_t lock_type : 8; | |
31143d5d | 598 | |
08e0e7c8 | 599 | /* outstanding callback notification on this file */ |
c435ee34 DH |
600 | struct afs_cb_interest *cb_interest; /* Server on which this resides */ |
601 | unsigned int cb_s_break; /* Mass break counter on ->server */ | |
68251f0a | 602 | unsigned int cb_v_break; /* Mass break counter on ->volume */ |
c435ee34 DH |
603 | unsigned int cb_break; /* Break counter on vnode */ |
604 | seqlock_t cb_lock; /* Lock for ->cb_interest, ->status, ->cb_*break */ | |
605 | ||
606 | time64_t cb_expires_at; /* time at which callback expires */ | |
08e0e7c8 | 607 | unsigned cb_version; /* callback version */ |
08e0e7c8 | 608 | afs_callback_type_t cb_type; /* type of callback */ |
08e0e7c8 DH |
609 | }; |
610 | ||
12bdcf33 DH |
611 | static inline struct fscache_cookie *afs_vnode_cache(struct afs_vnode *vnode) |
612 | { | |
613 | #ifdef CONFIG_AFS_FSCACHE | |
614 | return vnode->cache; | |
615 | #else | |
616 | return NULL; | |
617 | #endif | |
618 | } | |
619 | ||
00d3b7a4 DH |
620 | /* |
621 | * cached security record for one user's attempt to access a vnode | |
622 | */ | |
623 | struct afs_permit { | |
624 | struct key *key; /* RxRPC ticket holding a security context */ | |
be080a6f | 625 | afs_access_t access; /* CallerAccess value for this key */ |
00d3b7a4 DH |
626 | }; |
627 | ||
628 | /* | |
be080a6f DH |
629 | * Immutable cache of CallerAccess records from attempts to access vnodes. |
630 | * These may be shared between multiple vnodes. | |
00d3b7a4 DH |
631 | */ |
632 | struct afs_permits { | |
be080a6f DH |
633 | struct rcu_head rcu; |
634 | struct hlist_node hash_node; /* Link in hash */ | |
635 | unsigned long h; /* Hash value for this permit list */ | |
636 | refcount_t usage; | |
637 | unsigned short nr_permits; /* Number of records */ | |
638 | bool invalidated; /* Invalidated due to key change */ | |
639 | struct afs_permit permits[]; /* List of permits sorted by key pointer */ | |
00d3b7a4 DH |
640 | }; |
641 | ||
b908fe6b DH |
642 | /* |
643 | * record of one of a system's set of network interfaces | |
644 | */ | |
645 | struct afs_interface { | |
b908fe6b DH |
646 | struct in_addr address; /* IPv4 address bound to interface */ |
647 | struct in_addr netmask; /* netmask applied to address */ | |
648 | unsigned mtu; /* MTU of interface */ | |
649 | }; | |
650 | ||
8b2a464c DH |
651 | /* |
652 | * Cursor for iterating over a server's address list. | |
653 | */ | |
654 | struct afs_addr_cursor { | |
655 | struct afs_addr_list *alist; /* Current address list (pins ref) */ | |
d2ddc776 | 656 | u32 abort_code; |
8b2a464c DH |
657 | unsigned short start; /* Starting point in alist->addrs[] */ |
658 | unsigned short index; /* Wrapping offset from start to current addr */ | |
659 | short error; | |
660 | bool begun; /* T if we've begun iteration */ | |
661 | bool responded; /* T if the current address responded */ | |
744bcd71 | 662 | unsigned short nr_iterations; /* Number of address iterations */ |
8b2a464c DH |
663 | }; |
664 | ||
0a5143f2 DH |
665 | /* |
666 | * Cursor for iterating over a set of volume location servers. | |
667 | */ | |
668 | struct afs_vl_cursor { | |
669 | struct afs_addr_cursor ac; | |
670 | struct afs_cell *cell; /* The cell we're querying */ | |
671 | struct afs_vlserver_list *server_list; /* Current server list (pins ref) */ | |
672 | struct key *key; /* Key for the server */ | |
673 | unsigned char start; /* Initial index in server list */ | |
674 | unsigned char index; /* Number of servers tried beyond start */ | |
675 | short error; | |
676 | unsigned short flags; | |
677 | #define AFS_VL_CURSOR_STOP 0x0001 /* Set to cease iteration */ | |
678 | #define AFS_VL_CURSOR_RETRY 0x0002 /* Set to do a retry */ | |
679 | #define AFS_VL_CURSOR_RETRIED 0x0004 /* Set if started a retry */ | |
744bcd71 | 680 | unsigned short nr_iterations; /* Number of server iterations */ |
0a5143f2 DH |
681 | }; |
682 | ||
8b2a464c DH |
683 | /* |
684 | * Cursor for iterating over a set of fileservers. | |
685 | */ | |
686 | struct afs_fs_cursor { | |
687 | struct afs_addr_cursor ac; | |
d2ddc776 DH |
688 | struct afs_vnode *vnode; |
689 | struct afs_server_list *server_list; /* Current server list (pins ref) */ | |
690 | struct afs_cb_interest *cbi; /* Server on which this resides (pins ref) */ | |
691 | struct key *key; /* Key for the server */ | |
692 | unsigned int cb_break; /* cb_break + cb_s_break before the call */ | |
693 | unsigned int cb_break_2; /* cb_break + cb_s_break (2nd vnode) */ | |
694 | unsigned char start; /* Initial index in server list */ | |
695 | unsigned char index; /* Number of servers tried beyond start */ | |
e7f680f4 | 696 | short error; |
d2ddc776 DH |
697 | unsigned short flags; |
698 | #define AFS_FS_CURSOR_STOP 0x0001 /* Set to cease iteration */ | |
699 | #define AFS_FS_CURSOR_VBUSY 0x0002 /* Set if seen VBUSY */ | |
700 | #define AFS_FS_CURSOR_VMOVED 0x0004 /* Set if seen VMOVED */ | |
701 | #define AFS_FS_CURSOR_VNOVOL 0x0008 /* Set if seen VNOVOL */ | |
702 | #define AFS_FS_CURSOR_CUR_ONLY 0x0010 /* Set if current server only (file lock held) */ | |
703 | #define AFS_FS_CURSOR_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */ | |
744bcd71 | 704 | unsigned short nr_iterations; /* Number of server iterations */ |
8b2a464c DH |
705 | }; |
706 | ||
402cb8dd DH |
707 | /* |
708 | * Cache auxiliary data. | |
709 | */ | |
710 | struct afs_vnode_cache_aux { | |
711 | u64 data_version; | |
712 | } __packed; | |
713 | ||
98bf40cd DH |
714 | #include <trace/events/afs.h> |
715 | ||
08e0e7c8 | 716 | /*****************************************************************************/ |
8b2a464c DH |
717 | /* |
718 | * addr_list.c | |
719 | */ | |
720 | static inline struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist) | |
721 | { | |
722 | if (alist) | |
723 | refcount_inc(&alist->usage); | |
724 | return alist; | |
725 | } | |
726 | extern struct afs_addr_list *afs_alloc_addrlist(unsigned int, | |
727 | unsigned short, | |
728 | unsigned short); | |
729 | extern void afs_put_addrlist(struct afs_addr_list *); | |
0a5143f2 DH |
730 | extern struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *, |
731 | const char *, size_t, char, | |
732 | unsigned short, unsigned short); | |
733 | extern struct afs_vlserver_list *afs_dns_query(struct afs_cell *, time64_t *); | |
8b2a464c DH |
734 | extern bool afs_iterate_addresses(struct afs_addr_cursor *); |
735 | extern int afs_end_cursor(struct afs_addr_cursor *); | |
8b2a464c | 736 | |
bf99a53c DH |
737 | extern void afs_merge_fs_addr4(struct afs_addr_list *, __be32, u16); |
738 | extern void afs_merge_fs_addr6(struct afs_addr_list *, __be32 *, u16); | |
d2ddc776 | 739 | |
9b3f26c9 DH |
740 | /* |
741 | * cache.c | |
742 | */ | |
743 | #ifdef CONFIG_AFS_FSCACHE | |
744 | extern struct fscache_netfs afs_cache_netfs; | |
745 | extern struct fscache_cookie_def afs_cell_cache_index_def; | |
9b3f26c9 DH |
746 | extern struct fscache_cookie_def afs_volume_cache_index_def; |
747 | extern struct fscache_cookie_def afs_vnode_cache_index_def; | |
748 | #else | |
749 | #define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL) | |
9b3f26c9 DH |
750 | #define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL) |
751 | #define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL) | |
752 | #endif | |
753 | ||
08e0e7c8 DH |
754 | /* |
755 | * callback.c | |
756 | */ | |
757 | extern void afs_init_callback_state(struct afs_server *); | |
30062bd1 | 758 | extern void __afs_break_callback(struct afs_vnode *); |
c435ee34 | 759 | extern void afs_break_callback(struct afs_vnode *); |
5cf9dd55 | 760 | extern void afs_break_callbacks(struct afs_server *, size_t, struct afs_callback_break*); |
c435ee34 | 761 | |
d4a96bec DH |
762 | extern int afs_register_server_cb_interest(struct afs_vnode *, |
763 | struct afs_server_list *, unsigned int); | |
c435ee34 | 764 | extern void afs_put_cb_interest(struct afs_net *, struct afs_cb_interest *); |
d2ddc776 | 765 | extern void afs_clear_callback_interests(struct afs_net *, struct afs_server_list *); |
c435ee34 DH |
766 | |
767 | static inline struct afs_cb_interest *afs_get_cb_interest(struct afs_cb_interest *cbi) | |
768 | { | |
d4a96bec DH |
769 | if (cbi) |
770 | refcount_inc(&cbi->usage); | |
c435ee34 DH |
771 | return cbi; |
772 | } | |
08e0e7c8 | 773 | |
68251f0a DH |
774 | static inline unsigned int afs_calc_vnode_cb_break(struct afs_vnode *vnode) |
775 | { | |
776 | return vnode->cb_break + vnode->cb_s_break + vnode->cb_v_break; | |
777 | } | |
778 | ||
18ac6185 DH |
779 | static inline bool afs_cb_is_broken(unsigned int cb_break, |
780 | const struct afs_vnode *vnode, | |
781 | const struct afs_cb_interest *cbi) | |
68251f0a | 782 | { |
18ac6185 DH |
783 | return !cbi || cb_break != (vnode->cb_break + |
784 | cbi->server->cb_s_break + | |
785 | vnode->volume->cb_v_break); | |
68251f0a DH |
786 | } |
787 | ||
1da177e4 LT |
788 | /* |
789 | * cell.c | |
790 | */ | |
989782dc DH |
791 | extern int afs_cell_init(struct afs_net *, const char *); |
792 | extern struct afs_cell *afs_lookup_cell_rcu(struct afs_net *, const char *, unsigned); | |
793 | extern struct afs_cell *afs_lookup_cell(struct afs_net *, const char *, unsigned, | |
794 | const char *, bool); | |
8b2a464c | 795 | extern struct afs_cell *afs_get_cell(struct afs_cell *); |
9ed900b1 | 796 | extern void afs_put_cell(struct afs_net *, struct afs_cell *); |
989782dc DH |
797 | extern void afs_manage_cells(struct work_struct *); |
798 | extern void afs_cells_timer(struct timer_list *); | |
f044c884 | 799 | extern void __net_exit afs_cell_purge(struct afs_net *); |
08e0e7c8 DH |
800 | |
801 | /* | |
802 | * cmservice.c | |
803 | */ | |
804 | extern bool afs_cm_incoming_call(struct afs_call *); | |
805 | ||
1da177e4 LT |
806 | /* |
807 | * dir.c | |
808 | */ | |
4d673da1 | 809 | extern const struct file_operations afs_dir_file_operations; |
754661f1 | 810 | extern const struct inode_operations afs_dir_inode_operations; |
f3ddee8d | 811 | extern const struct address_space_operations afs_dir_aops; |
d61dcce2 | 812 | extern const struct dentry_operations afs_fs_dentry_operations; |
4d673da1 | 813 | |
66c7e1d3 DH |
814 | extern void afs_d_release(struct dentry *); |
815 | ||
63a4681f DH |
816 | /* |
817 | * dir_edit.c | |
818 | */ | |
819 | extern void afs_edit_dir_add(struct afs_vnode *, struct qstr *, struct afs_fid *, | |
820 | enum afs_edit_dir_reason); | |
821 | extern void afs_edit_dir_remove(struct afs_vnode *, struct qstr *, enum afs_edit_dir_reason); | |
822 | ||
66c7e1d3 DH |
823 | /* |
824 | * dynroot.c | |
825 | */ | |
826 | extern const struct file_operations afs_dynroot_file_operations; | |
827 | extern const struct inode_operations afs_dynroot_inode_operations; | |
828 | extern const struct dentry_operations afs_dynroot_dentry_operations; | |
829 | ||
830 | extern struct inode *afs_try_auto_mntpt(struct dentry *, struct inode *); | |
0da0b7fd DH |
831 | extern int afs_dynroot_mkdir(struct afs_net *, struct afs_cell *); |
832 | extern void afs_dynroot_rmdir(struct afs_net *, struct afs_cell *); | |
833 | extern int afs_dynroot_populate(struct super_block *); | |
834 | extern void afs_dynroot_depopulate(struct super_block *); | |
1da177e4 LT |
835 | |
836 | /* | |
837 | * file.c | |
838 | */ | |
f5e54d6e | 839 | extern const struct address_space_operations afs_fs_aops; |
754661f1 | 840 | extern const struct inode_operations afs_file_inode_operations; |
00d3b7a4 DH |
841 | extern const struct file_operations afs_file_operations; |
842 | ||
4343d008 DH |
843 | extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *); |
844 | extern void afs_put_wb_key(struct afs_wb_key *); | |
00d3b7a4 DH |
845 | extern int afs_open(struct inode *, struct file *); |
846 | extern int afs_release(struct inode *, struct file *); | |
d2ddc776 | 847 | extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *); |
f6d335c0 | 848 | extern int afs_page_filler(void *, struct page *); |
196ee9cd | 849 | extern void afs_put_read(struct afs_read *); |
1da177e4 | 850 | |
e8d6c554 DH |
851 | /* |
852 | * flock.c | |
853 | */ | |
f044c884 DH |
854 | extern struct workqueue_struct *afs_lock_manager; |
855 | ||
e8d6c554 DH |
856 | extern void afs_lock_work(struct work_struct *); |
857 | extern void afs_lock_may_be_available(struct afs_vnode *); | |
858 | extern int afs_lock(struct file *, int, struct file_lock *); | |
859 | extern int afs_flock(struct file *, int, struct file_lock *); | |
860 | ||
08e0e7c8 DH |
861 | /* |
862 | * fsclient.c | |
863 | */ | |
dd9fbcb8 DH |
864 | #define AFS_VNODE_NOT_YET_SET 0x01 |
865 | #define AFS_VNODE_META_CHANGED 0x02 | |
866 | #define AFS_VNODE_DATA_CHANGED 0x04 | |
867 | extern void afs_update_inode_from_status(struct afs_vnode *, struct afs_file_status *, | |
868 | const afs_dataversion_t *, u8); | |
869 | ||
0c3a5ac2 | 870 | extern int afs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_volsync *, bool); |
d2ddc776 DH |
871 | extern int afs_fs_give_up_callbacks(struct afs_net *, struct afs_server *); |
872 | extern int afs_fs_fetch_data(struct afs_fs_cursor *, struct afs_read *); | |
63a4681f | 873 | extern int afs_fs_create(struct afs_fs_cursor *, const char *, umode_t, u64, |
d2ddc776 | 874 | struct afs_fid *, struct afs_file_status *, struct afs_callback *); |
30062bd1 | 875 | extern int afs_fs_remove(struct afs_fs_cursor *, struct afs_vnode *, const char *, bool, u64); |
63a4681f DH |
876 | extern int afs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64); |
877 | extern int afs_fs_symlink(struct afs_fs_cursor *, const char *, const char *, u64, | |
d2ddc776 DH |
878 | struct afs_fid *, struct afs_file_status *); |
879 | extern int afs_fs_rename(struct afs_fs_cursor *, const char *, | |
63a4681f | 880 | struct afs_vnode *, const char *, u64, u64); |
4343d008 | 881 | extern int afs_fs_store_data(struct afs_fs_cursor *, struct address_space *, |
d2ddc776 DH |
882 | pgoff_t, pgoff_t, unsigned, unsigned); |
883 | extern int afs_fs_setattr(struct afs_fs_cursor *, struct iattr *); | |
884 | extern int afs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *); | |
885 | extern int afs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t); | |
886 | extern int afs_fs_extend_lock(struct afs_fs_cursor *); | |
887 | extern int afs_fs_release_lock(struct afs_fs_cursor *); | |
888 | extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *, | |
889 | struct afs_addr_cursor *, struct key *); | |
890 | extern int afs_fs_get_capabilities(struct afs_net *, struct afs_server *, | |
891 | struct afs_addr_cursor *, struct key *); | |
5cf9dd55 DH |
892 | extern int afs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *, |
893 | struct afs_fid *, struct afs_file_status *, | |
894 | struct afs_callback *, unsigned int, | |
895 | struct afs_volsync *); | |
896 | extern int afs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *, | |
897 | struct afs_fid *, struct afs_file_status *, | |
898 | struct afs_callback *, struct afs_volsync *); | |
08e0e7c8 | 899 | |
1da177e4 LT |
900 | /* |
901 | * inode.c | |
902 | */ | |
0c3a5ac2 | 903 | extern int afs_fetch_status(struct afs_vnode *, struct key *, bool); |
c435ee34 | 904 | extern int afs_iget5_test(struct inode *, void *); |
4d673da1 | 905 | extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool); |
00d3b7a4 | 906 | extern struct inode *afs_iget(struct super_block *, struct key *, |
260a9803 | 907 | struct afs_fid *, struct afs_file_status *, |
d2ddc776 DH |
908 | struct afs_callback *, |
909 | struct afs_cb_interest *); | |
416351f2 | 910 | extern void afs_zap_data(struct afs_vnode *); |
260a9803 | 911 | extern int afs_validate(struct afs_vnode *, struct key *); |
a528d35e | 912 | extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int); |
31143d5d | 913 | extern int afs_setattr(struct dentry *, struct iattr *); |
b57922d9 | 914 | extern void afs_evict_inode(struct inode *); |
bec5eb61 | 915 | extern int afs_drop_inode(struct inode *); |
1da177e4 LT |
916 | |
917 | /* | |
918 | * main.c | |
919 | */ | |
0ad53eee | 920 | extern struct workqueue_struct *afs_wq; |
5b86d4ff | 921 | extern int afs_net_id; |
f044c884 | 922 | |
5b86d4ff | 923 | static inline struct afs_net *afs_net(struct net *net) |
f044c884 | 924 | { |
5b86d4ff | 925 | return net_generic(net, afs_net_id); |
f044c884 DH |
926 | } |
927 | ||
5b86d4ff | 928 | static inline struct afs_net *afs_sb2net(struct super_block *sb) |
f044c884 | 929 | { |
5b86d4ff | 930 | return afs_net(AFS_FS_S(sb)->net_ns); |
f044c884 DH |
931 | } |
932 | ||
5b86d4ff | 933 | static inline struct afs_net *afs_d2net(struct dentry *dentry) |
f044c884 | 934 | { |
5b86d4ff | 935 | return afs_sb2net(dentry->d_sb); |
f044c884 DH |
936 | } |
937 | ||
5b86d4ff | 938 | static inline struct afs_net *afs_i2net(struct inode *inode) |
f044c884 | 939 | { |
5b86d4ff | 940 | return afs_sb2net(inode->i_sb); |
f044c884 DH |
941 | } |
942 | ||
5b86d4ff | 943 | static inline struct afs_net *afs_v2net(struct afs_vnode *vnode) |
f044c884 | 944 | { |
5b86d4ff | 945 | return afs_i2net(&vnode->vfs_inode); |
f044c884 DH |
946 | } |
947 | ||
5b86d4ff | 948 | static inline struct afs_net *afs_sock2net(struct sock *sk) |
f044c884 | 949 | { |
5b86d4ff | 950 | return net_generic(sock_net(sk), afs_net_id); |
f044c884 | 951 | } |
1da177e4 | 952 | |
d55b4da4 DH |
953 | static inline void __afs_stat(atomic_t *s) |
954 | { | |
955 | atomic_inc(s); | |
956 | } | |
957 | ||
958 | #define afs_stat_v(vnode, n) __afs_stat(&afs_v2net(vnode)->n) | |
959 | ||
08e0e7c8 DH |
960 | /* |
961 | * misc.c | |
962 | */ | |
963 | extern int afs_abort_to_error(u32); | |
964 | ||
1da177e4 LT |
965 | /* |
966 | * mntpt.c | |
967 | */ | |
754661f1 | 968 | extern const struct inode_operations afs_mntpt_inode_operations; |
bec5eb61 | 969 | extern const struct inode_operations afs_autocell_inode_operations; |
4b6f5d20 | 970 | extern const struct file_operations afs_mntpt_file_operations; |
1da177e4 | 971 | |
d18610b0 | 972 | extern struct vfsmount *afs_d_automount(struct path *); |
08e0e7c8 | 973 | extern void afs_mntpt_kill_timer(void); |
1da177e4 | 974 | |
b4db2b35 AB |
975 | /* |
976 | * netdevices.c | |
977 | */ | |
5b86d4ff DH |
978 | extern int afs_get_ipv4_interfaces(struct afs_net *, struct afs_interface *, |
979 | size_t, bool); | |
b4db2b35 | 980 | |
1da177e4 LT |
981 | /* |
982 | * proc.c | |
983 | */ | |
b6cfbeca | 984 | #ifdef CONFIG_PROC_FS |
f044c884 DH |
985 | extern int __net_init afs_proc_init(struct afs_net *); |
986 | extern void __net_exit afs_proc_cleanup(struct afs_net *); | |
5b86d4ff DH |
987 | extern int afs_proc_cell_setup(struct afs_cell *); |
988 | extern void afs_proc_cell_remove(struct afs_cell *); | |
6f8880d8 | 989 | extern void afs_put_sysnames(struct afs_sysnames *); |
b6cfbeca DH |
990 | #else |
991 | static inline int afs_proc_init(struct afs_net *net) { return 0; } | |
992 | static inline void afs_proc_cleanup(struct afs_net *net) {} | |
993 | static inline int afs_proc_cell_setup(struct afs_cell *cell) { return 0; } | |
994 | static inline void afs_proc_cell_remove(struct afs_cell *cell) {} | |
995 | static inline void afs_put_sysnames(struct afs_sysnames *sysnames) {} | |
996 | #endif | |
1da177e4 | 997 | |
d2ddc776 DH |
998 | /* |
999 | * rotate.c | |
1000 | */ | |
1001 | extern bool afs_begin_vnode_operation(struct afs_fs_cursor *, struct afs_vnode *, | |
1002 | struct key *); | |
1003 | extern bool afs_select_fileserver(struct afs_fs_cursor *); | |
1004 | extern bool afs_select_current_fileserver(struct afs_fs_cursor *); | |
1005 | extern int afs_end_vnode_operation(struct afs_fs_cursor *); | |
1006 | ||
08e0e7c8 DH |
1007 | /* |
1008 | * rxrpc.c | |
1009 | */ | |
f044c884 | 1010 | extern struct workqueue_struct *afs_async_calls; |
8324f0bc | 1011 | |
f044c884 DH |
1012 | extern int __net_init afs_open_socket(struct afs_net *); |
1013 | extern void __net_exit afs_close_socket(struct afs_net *); | |
1014 | extern void afs_charge_preallocation(struct work_struct *); | |
341f741f DH |
1015 | extern void afs_put_call(struct afs_call *); |
1016 | extern int afs_queue_call_work(struct afs_call *); | |
8b2a464c | 1017 | extern long afs_make_call(struct afs_addr_cursor *, struct afs_call *, gfp_t, bool); |
f044c884 DH |
1018 | extern struct afs_call *afs_alloc_flat_call(struct afs_net *, |
1019 | const struct afs_call_type *, | |
08e0e7c8 DH |
1020 | size_t, size_t); |
1021 | extern void afs_flat_call_destructor(struct afs_call *); | |
08e0e7c8 | 1022 | extern void afs_send_empty_reply(struct afs_call *); |
b908fe6b | 1023 | extern void afs_send_simple_reply(struct afs_call *, const void *, size_t); |
12bdcf33 | 1024 | extern int afs_extract_data(struct afs_call *, bool); |
160cb957 | 1025 | extern int afs_protocol_error(struct afs_call *, int, enum afs_eproto_cause); |
08e0e7c8 | 1026 | |
12bdcf33 DH |
1027 | static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t size) |
1028 | { | |
1029 | call->kvec[0].iov_base = buf; | |
1030 | call->kvec[0].iov_len = size; | |
1031 | iov_iter_kvec(&call->iter, READ, call->kvec, 1, size); | |
1032 | } | |
1033 | ||
1034 | static inline void afs_extract_to_tmp(struct afs_call *call) | |
1035 | { | |
1036 | afs_extract_begin(call, &call->tmp, sizeof(call->tmp)); | |
1037 | } | |
1038 | ||
1039 | static inline void afs_extract_to_tmp64(struct afs_call *call) | |
1040 | { | |
1041 | afs_extract_begin(call, &call->tmp64, sizeof(call->tmp64)); | |
1042 | } | |
1043 | ||
1044 | static inline void afs_extract_discard(struct afs_call *call, size_t size) | |
1045 | { | |
1046 | iov_iter_discard(&call->iter, READ, size); | |
1047 | } | |
1048 | ||
1049 | static inline void afs_extract_to_buf(struct afs_call *call, size_t size) | |
1050 | { | |
1051 | afs_extract_begin(call, call->buffer, size); | |
1052 | } | |
1053 | ||
d001648e | 1054 | static inline int afs_transfer_reply(struct afs_call *call) |
372ee163 | 1055 | { |
12bdcf33 | 1056 | return afs_extract_data(call, false); |
372ee163 DH |
1057 | } |
1058 | ||
98bf40cd DH |
1059 | static inline bool afs_check_call_state(struct afs_call *call, |
1060 | enum afs_call_state state) | |
1061 | { | |
1062 | return READ_ONCE(call->state) == state; | |
1063 | } | |
1064 | ||
1065 | static inline bool afs_set_call_state(struct afs_call *call, | |
1066 | enum afs_call_state from, | |
1067 | enum afs_call_state to) | |
1068 | { | |
1069 | bool ok = false; | |
1070 | ||
1071 | spin_lock_bh(&call->state_lock); | |
1072 | if (call->state == from) { | |
1073 | call->state = to; | |
1074 | trace_afs_call_state(call, from, to, 0, 0); | |
1075 | ok = true; | |
1076 | } | |
1077 | spin_unlock_bh(&call->state_lock); | |
1078 | return ok; | |
1079 | } | |
1080 | ||
1081 | static inline void afs_set_call_complete(struct afs_call *call, | |
1082 | int error, u32 remote_abort) | |
1083 | { | |
1084 | enum afs_call_state state; | |
1085 | bool ok = false; | |
1086 | ||
1087 | spin_lock_bh(&call->state_lock); | |
1088 | state = call->state; | |
1089 | if (state != AFS_CALL_COMPLETE) { | |
1090 | call->abort_code = remote_abort; | |
1091 | call->error = error; | |
1092 | call->state = AFS_CALL_COMPLETE; | |
1093 | trace_afs_call_state(call, state, AFS_CALL_COMPLETE, | |
1094 | error, remote_abort); | |
1095 | ok = true; | |
1096 | } | |
1097 | spin_unlock_bh(&call->state_lock); | |
1098 | if (ok) | |
1099 | trace_afs_call_done(call); | |
1100 | } | |
1101 | ||
00d3b7a4 DH |
1102 | /* |
1103 | * security.c | |
1104 | */ | |
be080a6f | 1105 | extern void afs_put_permits(struct afs_permits *); |
00d3b7a4 | 1106 | extern void afs_clear_permits(struct afs_vnode *); |
be080a6f | 1107 | extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int); |
416351f2 | 1108 | extern void afs_zap_permits(struct rcu_head *); |
00d3b7a4 | 1109 | extern struct key *afs_request_key(struct afs_cell *); |
0fafdc9f | 1110 | extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *); |
10556cb2 | 1111 | extern int afs_permission(struct inode *, int); |
be080a6f | 1112 | extern void __exit afs_clean_up_permit_cache(void); |
00d3b7a4 | 1113 | |
08e0e7c8 DH |
1114 | /* |
1115 | * server.c | |
1116 | */ | |
1117 | extern spinlock_t afs_server_peer_lock; | |
1118 | ||
c435ee34 DH |
1119 | static inline struct afs_server *afs_get_server(struct afs_server *server) |
1120 | { | |
1121 | atomic_inc(&server->usage); | |
1122 | return server; | |
1123 | } | |
08e0e7c8 | 1124 | |
f044c884 DH |
1125 | extern struct afs_server *afs_find_server(struct afs_net *, |
1126 | const struct sockaddr_rxrpc *); | |
d2ddc776 DH |
1127 | extern struct afs_server *afs_find_server_by_uuid(struct afs_net *, const uuid_t *); |
1128 | extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *); | |
9ed900b1 | 1129 | extern void afs_put_server(struct afs_net *, struct afs_server *); |
d2ddc776 DH |
1130 | extern void afs_manage_servers(struct work_struct *); |
1131 | extern void afs_servers_timer(struct timer_list *); | |
f044c884 | 1132 | extern void __net_exit afs_purge_servers(struct afs_net *); |
d2ddc776 DH |
1133 | extern bool afs_probe_fileserver(struct afs_fs_cursor *); |
1134 | extern bool afs_check_server_record(struct afs_fs_cursor *, struct afs_server *); | |
08e0e7c8 | 1135 | |
00d3b7a4 | 1136 | /* |
d2ddc776 | 1137 | * server_list.c |
00d3b7a4 | 1138 | */ |
d2ddc776 DH |
1139 | static inline struct afs_server_list *afs_get_serverlist(struct afs_server_list *slist) |
1140 | { | |
1141 | refcount_inc(&slist->usage); | |
1142 | return slist; | |
1143 | } | |
00d3b7a4 | 1144 | |
d2ddc776 DH |
1145 | extern void afs_put_serverlist(struct afs_net *, struct afs_server_list *); |
1146 | extern struct afs_server_list *afs_alloc_server_list(struct afs_cell *, struct key *, | |
1147 | struct afs_vldb_entry *, | |
1148 | u8); | |
1149 | extern bool afs_annotate_server_list(struct afs_server_list *, struct afs_server_list *); | |
08e0e7c8 DH |
1150 | |
1151 | /* | |
d2ddc776 | 1152 | * super.c |
08e0e7c8 | 1153 | */ |
d2ddc776 | 1154 | extern int __init afs_fs_init(void); |
5b86d4ff | 1155 | extern void afs_fs_exit(void); |
08e0e7c8 DH |
1156 | |
1157 | /* | |
d2ddc776 | 1158 | * vlclient.c |
08e0e7c8 | 1159 | */ |
0a5143f2 DH |
1160 | extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *, |
1161 | const char *, int); | |
1162 | extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *, const uuid_t *); | |
bf99a53c | 1163 | extern int afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *, struct key *); |
0a5143f2 DH |
1164 | extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *, const uuid_t *); |
1165 | ||
1166 | /* | |
1167 | * vl_rotate.c | |
1168 | */ | |
1169 | extern bool afs_begin_vlserver_operation(struct afs_vl_cursor *, | |
1170 | struct afs_cell *, struct key *); | |
1171 | extern bool afs_select_vlserver(struct afs_vl_cursor *); | |
1172 | extern bool afs_select_current_vlserver(struct afs_vl_cursor *); | |
1173 | extern int afs_end_vlserver_operation(struct afs_vl_cursor *); | |
1174 | ||
1175 | /* | |
1176 | * vlserver_list.c | |
1177 | */ | |
1178 | static inline struct afs_vlserver *afs_get_vlserver(struct afs_vlserver *vlserver) | |
1179 | { | |
1180 | atomic_inc(&vlserver->usage); | |
1181 | return vlserver; | |
1182 | } | |
1183 | ||
1184 | static inline struct afs_vlserver_list *afs_get_vlserverlist(struct afs_vlserver_list *vllist) | |
1185 | { | |
1186 | if (vllist) | |
1187 | atomic_inc(&vllist->usage); | |
1188 | return vllist; | |
1189 | } | |
1190 | ||
1191 | extern struct afs_vlserver *afs_alloc_vlserver(const char *, size_t, unsigned short); | |
1192 | extern void afs_put_vlserver(struct afs_net *, struct afs_vlserver *); | |
1193 | extern struct afs_vlserver_list *afs_alloc_vlserver_list(unsigned int); | |
1194 | extern void afs_put_vlserverlist(struct afs_net *, struct afs_vlserver_list *); | |
1195 | extern struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *, | |
1196 | const void *, size_t); | |
08e0e7c8 DH |
1197 | |
1198 | /* | |
1199 | * volume.c | |
1200 | */ | |
d2ddc776 | 1201 | static inline struct afs_volume *__afs_get_volume(struct afs_volume *volume) |
49566f6f DH |
1202 | { |
1203 | if (volume) | |
1204 | atomic_inc(&volume->usage); | |
1205 | return volume; | |
1206 | } | |
08e0e7c8 | 1207 | |
d2ddc776 DH |
1208 | extern struct afs_volume *afs_create_volume(struct afs_mount_params *); |
1209 | extern void afs_activate_volume(struct afs_volume *); | |
1210 | extern void afs_deactivate_volume(struct afs_volume *); | |
9ed900b1 | 1211 | extern void afs_put_volume(struct afs_cell *, struct afs_volume *); |
d2ddc776 | 1212 | extern int afs_check_volume_status(struct afs_volume *, struct key *); |
08e0e7c8 | 1213 | |
31143d5d DH |
1214 | /* |
1215 | * write.c | |
1216 | */ | |
1217 | extern int afs_set_page_dirty(struct page *); | |
15b4650e NP |
1218 | extern int afs_write_begin(struct file *file, struct address_space *mapping, |
1219 | loff_t pos, unsigned len, unsigned flags, | |
1220 | struct page **pagep, void **fsdata); | |
1221 | extern int afs_write_end(struct file *file, struct address_space *mapping, | |
1222 | loff_t pos, unsigned len, unsigned copied, | |
1223 | struct page *page, void *fsdata); | |
31143d5d DH |
1224 | extern int afs_writepage(struct page *, struct writeback_control *); |
1225 | extern int afs_writepages(struct address_space *, struct writeback_control *); | |
31143d5d | 1226 | extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *); |
50b5551d | 1227 | extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *); |
02c24a82 | 1228 | extern int afs_fsync(struct file *, loff_t, loff_t, int); |
0722f186 | 1229 | extern vm_fault_t afs_page_mkwrite(struct vm_fault *vmf); |
4343d008 DH |
1230 | extern void afs_prune_wb_keys(struct afs_vnode *); |
1231 | extern int afs_launder_page(struct page *); | |
31143d5d | 1232 | |
d3e3b7ea DH |
1233 | /* |
1234 | * xattr.c | |
1235 | */ | |
1236 | extern const struct xattr_handler *afs_xattr_handlers[]; | |
1237 | extern ssize_t afs_listxattr(struct dentry *, char *, size_t); | |
31143d5d | 1238 | |
30062bd1 DH |
1239 | /* |
1240 | * yfsclient.c | |
1241 | */ | |
1242 | extern int yfs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_volsync *, bool); | |
1243 | extern int yfs_fs_fetch_data(struct afs_fs_cursor *, struct afs_read *); | |
1244 | extern int yfs_fs_create_file(struct afs_fs_cursor *, const char *, umode_t, u64, | |
1245 | struct afs_fid *, struct afs_file_status *, struct afs_callback *); | |
1246 | extern int yfs_fs_make_dir(struct afs_fs_cursor *, const char *, umode_t, u64, | |
1247 | struct afs_fid *, struct afs_file_status *, struct afs_callback *); | |
1248 | extern int yfs_fs_remove_file2(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64); | |
1249 | extern int yfs_fs_remove(struct afs_fs_cursor *, struct afs_vnode *, const char *, bool, u64); | |
1250 | extern int yfs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64); | |
1251 | extern int yfs_fs_symlink(struct afs_fs_cursor *, const char *, const char *, u64, | |
1252 | struct afs_fid *, struct afs_file_status *); | |
1253 | extern int yfs_fs_rename(struct afs_fs_cursor *, const char *, | |
1254 | struct afs_vnode *, const char *, u64, u64); | |
1255 | extern int yfs_fs_store_data(struct afs_fs_cursor *, struct address_space *, | |
1256 | pgoff_t, pgoff_t, unsigned, unsigned); | |
1257 | extern int yfs_fs_setattr(struct afs_fs_cursor *, struct iattr *); | |
1258 | extern int yfs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *); | |
1259 | extern int yfs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t); | |
1260 | extern int yfs_fs_extend_lock(struct afs_fs_cursor *); | |
1261 | extern int yfs_fs_release_lock(struct afs_fs_cursor *); | |
1262 | extern int yfs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *, | |
1263 | struct afs_fid *, struct afs_file_status *, | |
1264 | struct afs_callback *, struct afs_volsync *); | |
1265 | extern int yfs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *, | |
1266 | struct afs_fid *, struct afs_file_status *, | |
1267 | struct afs_callback *, unsigned int, | |
1268 | struct afs_volsync *); | |
d2ddc776 DH |
1269 | |
1270 | /* | |
1271 | * Miscellaneous inline functions. | |
1272 | */ | |
1273 | static inline struct afs_vnode *AFS_FS_I(struct inode *inode) | |
1274 | { | |
1275 | return container_of(inode, struct afs_vnode, vfs_inode); | |
1276 | } | |
1277 | ||
1278 | static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) | |
1279 | { | |
1280 | return &vnode->vfs_inode; | |
1281 | } | |
1282 | ||
1283 | static inline void afs_vnode_commit_status(struct afs_fs_cursor *fc, | |
1284 | struct afs_vnode *vnode, | |
1285 | unsigned int cb_break) | |
1286 | { | |
1287 | if (fc->ac.error == 0) | |
1288 | afs_cache_permit(vnode, fc->key, cb_break); | |
1289 | } | |
1290 | ||
1291 | static inline void afs_check_for_remote_deletion(struct afs_fs_cursor *fc, | |
1292 | struct afs_vnode *vnode) | |
1293 | { | |
1294 | if (fc->ac.error == -ENOENT) { | |
1295 | set_bit(AFS_VNODE_DELETED, &vnode->flags); | |
1296 | afs_break_callback(vnode); | |
1297 | } | |
1298 | } | |
1299 | ||
f51375cd DH |
1300 | static inline int afs_io_error(struct afs_call *call, enum afs_io_error where) |
1301 | { | |
1302 | trace_afs_io_error(call->debug_id, -EIO, where); | |
1303 | return -EIO; | |
1304 | } | |
1305 | ||
1306 | static inline int afs_bad(struct afs_vnode *vnode, enum afs_file_error where) | |
1307 | { | |
1308 | trace_afs_file_error(vnode, -EIO, where); | |
1309 | return -EIO; | |
1310 | } | |
d2ddc776 | 1311 | |
08e0e7c8 DH |
1312 | /*****************************************************************************/ |
1313 | /* | |
1314 | * debug tracing | |
1315 | */ | |
1316 | extern unsigned afs_debug; | |
1317 | ||
1318 | #define dbgprintk(FMT,...) \ | |
ad16df84 | 1319 | printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__) |
08e0e7c8 | 1320 | |
530b6412 HH |
1321 | #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) |
1322 | #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) | |
08e0e7c8 DH |
1323 | #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) |
1324 | ||
1325 | ||
1326 | #if defined(__KDEBUG) | |
1327 | #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__) | |
1328 | #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__) | |
1329 | #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__) | |
1330 | ||
1331 | #elif defined(CONFIG_AFS_DEBUG) | |
1332 | #define AFS_DEBUG_KENTER 0x01 | |
1333 | #define AFS_DEBUG_KLEAVE 0x02 | |
1334 | #define AFS_DEBUG_KDEBUG 0x04 | |
1335 | ||
1336 | #define _enter(FMT,...) \ | |
1337 | do { \ | |
1338 | if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \ | |
1339 | kenter(FMT,##__VA_ARGS__); \ | |
1340 | } while (0) | |
1341 | ||
1342 | #define _leave(FMT,...) \ | |
1343 | do { \ | |
1344 | if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \ | |
1345 | kleave(FMT,##__VA_ARGS__); \ | |
1346 | } while (0) | |
1347 | ||
1348 | #define _debug(FMT,...) \ | |
1349 | do { \ | |
1350 | if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \ | |
1351 | kdebug(FMT,##__VA_ARGS__); \ | |
1352 | } while (0) | |
1353 | ||
1354 | #else | |
12fdff3f DH |
1355 | #define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__) |
1356 | #define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) | |
1357 | #define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__) | |
08e0e7c8 DH |
1358 | #endif |
1359 | ||
1360 | /* | |
1361 | * debug assertion checking | |
1362 | */ | |
1363 | #if 1 // defined(__KDEBUGALL) | |
1364 | ||
1365 | #define ASSERT(X) \ | |
1366 | do { \ | |
1367 | if (unlikely(!(X))) { \ | |
1368 | printk(KERN_ERR "\n"); \ | |
1369 | printk(KERN_ERR "AFS: Assertion failed\n"); \ | |
1370 | BUG(); \ | |
1371 | } \ | |
1372 | } while(0) | |
1373 | ||
1374 | #define ASSERTCMP(X, OP, Y) \ | |
1375 | do { \ | |
1376 | if (unlikely(!((X) OP (Y)))) { \ | |
1377 | printk(KERN_ERR "\n"); \ | |
1378 | printk(KERN_ERR "AFS: Assertion failed\n"); \ | |
1379 | printk(KERN_ERR "%lu " #OP " %lu is false\n", \ | |
1380 | (unsigned long)(X), (unsigned long)(Y)); \ | |
1381 | printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ | |
1382 | (unsigned long)(X), (unsigned long)(Y)); \ | |
1383 | BUG(); \ | |
1384 | } \ | |
1385 | } while(0) | |
1386 | ||
416351f2 DH |
1387 | #define ASSERTRANGE(L, OP1, N, OP2, H) \ |
1388 | do { \ | |
1389 | if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \ | |
1390 | printk(KERN_ERR "\n"); \ | |
1391 | printk(KERN_ERR "AFS: Assertion failed\n"); \ | |
1392 | printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \ | |
1393 | (unsigned long)(L), (unsigned long)(N), \ | |
1394 | (unsigned long)(H)); \ | |
1395 | printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \ | |
1396 | (unsigned long)(L), (unsigned long)(N), \ | |
1397 | (unsigned long)(H)); \ | |
1398 | BUG(); \ | |
1399 | } \ | |
1400 | } while(0) | |
1401 | ||
08e0e7c8 DH |
1402 | #define ASSERTIF(C, X) \ |
1403 | do { \ | |
1404 | if (unlikely((C) && !(X))) { \ | |
1405 | printk(KERN_ERR "\n"); \ | |
1406 | printk(KERN_ERR "AFS: Assertion failed\n"); \ | |
1407 | BUG(); \ | |
1408 | } \ | |
1409 | } while(0) | |
1410 | ||
1411 | #define ASSERTIFCMP(C, X, OP, Y) \ | |
1412 | do { \ | |
1413 | if (unlikely((C) && !((X) OP (Y)))) { \ | |
1414 | printk(KERN_ERR "\n"); \ | |
1415 | printk(KERN_ERR "AFS: Assertion failed\n"); \ | |
1416 | printk(KERN_ERR "%lu " #OP " %lu is false\n", \ | |
1417 | (unsigned long)(X), (unsigned long)(Y)); \ | |
1418 | printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ | |
1419 | (unsigned long)(X), (unsigned long)(Y)); \ | |
1420 | BUG(); \ | |
1421 | } \ | |
1422 | } while(0) | |
1423 | ||
1424 | #else | |
1425 | ||
1426 | #define ASSERT(X) \ | |
1427 | do { \ | |
1428 | } while(0) | |
1429 | ||
1430 | #define ASSERTCMP(X, OP, Y) \ | |
1431 | do { \ | |
1432 | } while(0) | |
1433 | ||
416351f2 DH |
1434 | #define ASSERTRANGE(L, OP1, N, OP2, H) \ |
1435 | do { \ | |
1436 | } while(0) | |
1437 | ||
08e0e7c8 DH |
1438 | #define ASSERTIF(C, X) \ |
1439 | do { \ | |
1440 | } while(0) | |
1441 | ||
1442 | #define ASSERTIFCMP(C, X, OP, Y) \ | |
1443 | do { \ | |
1444 | } while(0) | |
1445 | ||
1446 | #endif /* __KDEBUGALL */ |