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