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