Merge tag 'io_uring-6.16-20250630' of git://git.kernel.dk/linux
[linux-2.6-block.git] / fs / afs / internal.h
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
ec26815a 2/* internal AFS stuff
1da177e4 3 *
08e0e7c8 4 * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
1da177e4 5 * Written by David Howells (dhowells@redhat.com)
1da177e4
LT
6 */
7
1da177e4
LT
8#include <linux/compiler.h>
9#include <linux/kernel.h>
8a79790b 10#include <linux/ktime.h>
1da177e4 11#include <linux/fs.h>
5970e15d 12#include <linux/filelock.h>
1da177e4 13#include <linux/pagemap.h>
08e0e7c8 14#include <linux/rxrpc.h>
00d3b7a4 15#include <linux/key.h>
e8edc6e0 16#include <linux/workqueue.h>
00c541ea 17#include <linux/sched.h>
80e50be4 18#include <linux/fscache.h>
e1da0222 19#include <linux/backing-dev.h>
ff548773 20#include <linux/uuid.h>
0722f186 21#include <linux/mm_types.h>
0a5143f2 22#include <linux/dns_resolver.h>
d98c317f 23#include <crypto/krb5.h>
f044c884 24#include <net/net_namespace.h>
5b86d4ff
DH
25#include <net/netns/generic.h>
26#include <net/sock.h>
8324f0bc 27#include <net/af_rxrpc.h>
00c541ea 28
08e0e7c8
DH
29#include "afs.h"
30#include "afs_vl.h"
31
32#define AFS_CELL_MAX_ADDRS 15
33
31143d5d 34struct pagevec;
08e0e7c8 35struct afs_call;
c4508464 36struct afs_vnode;
f49b594d 37struct afs_server_probe;
08e0e7c8 38
6c6c1d63
DH
39/*
40 * Partial file-locking emulation mode. (The problem being that AFS3 only
41 * allows whole-file locks and no upgrading/downgrading).
42 */
43enum afs_flock_mode {
44 afs_flock_mode_unset,
45 afs_flock_mode_local, /* Local locking only */
46 afs_flock_mode_openafs, /* Don't get server lock for a partial lock */
47 afs_flock_mode_strict, /* Always get a server lock for a partial lock */
48 afs_flock_mode_write, /* Get an exclusive server lock for a partial lock */
49};
50
13fcc683 51struct afs_fs_context {
00d3b7a4 52 bool force; /* T to force cell type */
bec5eb61 53 bool autocell; /* T if set auto mount operation */
4d673da1 54 bool dyn_root; /* T if dynamic root */
13fcc683 55 bool no_cell; /* T if the source is "none" (for dynroot) */
6c6c1d63 56 enum afs_flock_mode flock_mode; /* Partial file-locking emulation mode */
00d3b7a4 57 afs_voltype_t type; /* type of volume requested */
13fcc683 58 unsigned int volnamesz; /* size of volume name */
00d3b7a4 59 const char *volname; /* name of volume to mount */
5b86d4ff 60 struct afs_net *net; /* the AFS net namespace stuff */
00d3b7a4
DH
61 struct afs_cell *cell; /* cell in which to find volume */
62 struct afs_volume *volume; /* volume record */
63 struct key *key; /* key to use for secure mounting */
64};
65
8e8d7f13 66enum afs_call_state {
98bf40cd
DH
67 AFS_CALL_CL_REQUESTING, /* Client: Request is being sent */
68 AFS_CALL_CL_AWAIT_REPLY, /* Client: Awaiting reply */
69 AFS_CALL_CL_PROC_REPLY, /* Client: rxrpc call complete; processing reply */
70 AFS_CALL_SV_AWAIT_OP_ID, /* Server: Awaiting op ID */
71 AFS_CALL_SV_AWAIT_REQUEST, /* Server: Awaiting request data */
72 AFS_CALL_SV_REPLYING, /* Server: Replying */
73 AFS_CALL_SV_AWAIT_ACK, /* Server: Awaiting final ACK */
74 AFS_CALL_COMPLETE, /* Completed or failed */
8e8d7f13 75};
f044c884 76
f94f70d3
DH
77/*
78 * Address preferences.
79 */
80struct afs_addr_preference {
81 union {
82 struct in_addr ipv4_addr; /* AF_INET address to compare against */
83 struct in6_addr ipv6_addr; /* AF_INET6 address to compare against */
84 };
85 sa_family_t family; /* Which address to use */
86 u16 prio; /* Priority */
87 u8 subnet_mask; /* How many bits to compare */
88};
89
90struct afs_addr_preference_list {
91 struct rcu_head rcu;
92 u16 version; /* Incremented when prefs list changes */
93 u8 ipv6_off; /* Offset of IPv6 addresses */
94 u8 nr; /* Number of addresses in total */
95 u8 max_prefs; /* Number of prefs allocated */
96 struct afs_addr_preference prefs[] __counted_by(max_prefs);
97};
98
72904d7b
DH
99struct afs_address {
100 struct rxrpc_peer *peer;
aa453bec 101 short last_error; /* Last error from this address */
d14cf8ed 102 u16 prio; /* Address priority */
72904d7b
DH
103};
104
8b2a464c
DH
105/*
106 * List of server addresses.
107 */
108struct afs_addr_list {
ddd2b85f 109 struct rcu_head rcu;
8b2a464c 110 refcount_t usage;
d2ddc776 111 u32 version; /* Version */
1e5d8493 112 unsigned int debug_id;
d14cf8ed 113 unsigned int addr_pref_version; /* Version of address preference list */
68eb64c3
DH
114 unsigned char max_addrs;
115 unsigned char nr_addrs;
3bf0fb6f 116 unsigned char preferred; /* Preferred address */
68eb64c3 117 unsigned char nr_ipv4; /* Number of IPv4 addresses */
0a5143f2
DH
118 enum dns_record_source source:8;
119 enum dns_lookup_status status:8;
aa4917d6 120 unsigned long probe_failed; /* Mask of addrs that failed locally/ICMP */
3bf0fb6f 121 unsigned long responded; /* Mask of addrs that responded */
72904d7b 122 struct afs_address addrs[] __counted_by(max_addrs);
68eb64c3 123#define AFS_MAX_ADDRESSES ((unsigned int)(sizeof(unsigned long) * 8))
8b2a464c
DH
124};
125
08e0e7c8
DH
126/*
127 * a record of an in-progress RxRPC call
128 */
129struct afs_call {
130 const struct afs_call_type *type; /* type of call */
08e0e7c8 131 wait_queue_head_t waitq; /* processes awaiting completion */
341f741f 132 struct work_struct async_work; /* async I/O processor */
08e0e7c8 133 struct work_struct work; /* actual work processor */
610a79ff 134 struct work_struct free_work; /* Deferred free processor */
08e0e7c8 135 struct rxrpc_call *rxcall; /* RxRPC call handle */
e38f299e 136 struct rxrpc_peer *peer; /* Remote endpoint */
08e0e7c8 137 struct key *key; /* security for this call */
f044c884 138 struct afs_net *net; /* The network namespace */
a6853b9c
DH
139 struct afs_server *server; /* The fileserver record if fs op (pins ref) */
140 struct afs_vlserver *vlserver; /* The vlserver record if vl op */
08e0e7c8 141 void *request; /* request data (first part) */
f105da1a 142 size_t iov_len; /* Size of *iter to be used */
fc276122 143 struct iov_iter def_iter; /* Default buffer/data iterator */
bd80d8a8 144 struct iov_iter *write_iter; /* Iterator defining write to be made */
fc276122
DH
145 struct iov_iter *iter; /* Iterator currently in use */
146 union { /* Convenience for ->def_iter */
12bdcf33
DH
147 struct kvec kvec[1];
148 struct bio_vec bvec[1];
149 };
08e0e7c8 150 void *buffer; /* reply receive buffer */
ffba718e 151 union {
f49b594d
DH
152 struct afs_endpoint_state *probe;
153 struct afs_addr_list *vl_probe;
ffba718e
DH
154 struct afs_addr_list *ret_alist;
155 struct afs_vldb_entry *ret_vldb;
c3e9f888 156 char *ret_str;
ffba718e 157 };
abcbd3bf 158 struct afs_fid fid; /* Primary vnode ID (or all zeroes) */
f49b594d 159 unsigned char probe_index; /* Address in ->probe_alist */
e49c7b2f 160 struct afs_operation *op;
ffba718e 161 unsigned int server_index;
c56f9ec8 162 refcount_t ref;
8e8d7f13 163 enum afs_call_state state;
98bf40cd 164 spinlock_t state_lock;
08e0e7c8 165 int error; /* error code */
d001648e 166 u32 abort_code; /* Remote abort ID or 0 */
f28fc201 167 unsigned long long remaining; /* How much is left to receive */
db099c62 168 unsigned int max_lifespan; /* Maximum lifespan in secs to set if not 0 */
08e0e7c8
DH
169 unsigned request_size; /* size of request data */
170 unsigned reply_max; /* maximum size of reply */
e49c7b2f 171 unsigned count2; /* count used in unmarshalling */
08e0e7c8 172 unsigned char unmarshall; /* unmarshalling phase */
dde9f095 173 bool drop_ref; /* T if need to drop ref for incoming call */
d001648e 174 bool need_attention; /* T if RxRPC poked us */
56ff9c83 175 bool async; /* T if asynchronous */
a68f4a27 176 bool upgrade; /* T to request service upgrade */
20b8391f 177 bool intr; /* T if interruptible */
38355eec 178 bool unmarshalling_error; /* T if an unmarshalling error occurred */
aa453bec 179 bool responded; /* Got a response from the call (may be abort) */
d03539d5 180 u8 security_ix; /* Security class */
bf99a53c 181 u16 service_id; /* Actual service ID (after upgrade) */
a25e21f0 182 unsigned int debug_id; /* Trace ID */
d03539d5 183 u32 enctype; /* Security encoding type */
50a2c953 184 u32 operation_ID; /* operation ID for an incoming call */
08e0e7c8 185 u32 count; /* count for use in unmarshalling */
12bdcf33
DH
186 union { /* place to extract temporary data */
187 struct {
188 __be32 tmp_u;
189 __be32 tmp;
190 } __attribute__((packed));
191 __be64 tmp64;
192 };
7903192c 193 ktime_t issue_time; /* Time of issue of operation */
08e0e7c8
DH
194};
195
196struct afs_call_type {
00d3b7a4 197 const char *name;
025db80c 198 unsigned int op; /* Really enum afs_fs_operation */
00d3b7a4 199
08e0e7c8
DH
200 /* deliver request or reply data to an call
201 * - returning an error will cause the call to be aborted
202 */
d001648e 203 int (*deliver)(struct afs_call *call);
08e0e7c8 204
08e0e7c8
DH
205 /* clean up a call */
206 void (*destructor)(struct afs_call *call);
341f741f 207
eddf51f2
DH
208 /* Async receive processing function */
209 void (*async_rx)(struct work_struct *work);
210
341f741f
DH
211 /* Work function */
212 void (*work)(struct work_struct *work);
3bf0fb6f
DH
213
214 /* Call done function (gets called immediately on success or failure) */
215 void (*done)(struct afs_call *call);
eddf51f2
DH
216
217 /* Handle a call being immediately cancelled. */
218 void (*immediate_cancel)(struct afs_call *call);
08e0e7c8
DH
219};
220
4343d008
DH
221/*
222 * Key available for writeback on a file.
223 */
224struct afs_wb_key {
225 refcount_t usage;
226 struct key *key;
227 struct list_head vnode_link; /* Link in vnode->wb_keys */
228};
229
215804a9
DH
230/*
231 * AFS open file information record. Pointed to by file->private_data.
232 */
233struct afs_file {
234 struct key *key; /* The key this file was opened with */
4343d008 235 struct afs_wb_key *wb; /* Writeback key record for this file */
215804a9
DH
236};
237
238static inline struct key *afs_file_key(struct file *file)
239{
240 struct afs_file *af = file->private_data;
241
242 return af->key;
243}
244
08e0e7c8
DH
245/*
246 * AFS superblock private data
247 * - there's one superblock per volume
248 */
249struct afs_super_info {
5b86d4ff 250 struct net *net_ns; /* Network namespace */
49566f6f 251 struct afs_cell *cell; /* The cell in which the volume resides */
08e0e7c8 252 struct afs_volume *volume; /* volume record */
6c6c1d63 253 enum afs_flock_mode flock_mode:8; /* File locking emulation mode */
4d673da1 254 bool dyn_root; /* True if dynamic root */
08e0e7c8 255};
1da177e4 256
08e0e7c8
DH
257static inline struct afs_super_info *AFS_FS_S(struct super_block *sb)
258{
259 return sb->s_fs_info;
1da177e4
LT
260}
261
08e0e7c8
DH
262extern struct file_system_type afs_fs_type;
263
6f8880d8
DH
264/*
265 * Set of substitutes for @sys.
266 */
267struct afs_sysnames {
268#define AFS_NR_SYSNAME 16
269 char *subs[AFS_NR_SYSNAME];
270 refcount_t usage;
271 unsigned short nr;
6f8880d8
DH
272 char blank[1];
273};
274
f044c884
DH
275/*
276 * AFS network namespace record.
277 */
278struct afs_net {
5b86d4ff 279 struct net *net; /* Backpointer to the owning net namespace */
f044c884
DH
280 struct afs_uuid uuid;
281 bool live; /* F if this namespace is being removed */
282
283 /* AF_RXRPC I/O stuff */
284 struct socket *socket;
285 struct afs_call *spare_incoming_call;
286 struct work_struct charge_preallocation_work;
5800b1cf 287 struct work_struct rx_oob_work;
f044c884
DH
288 struct mutex socket_mutex;
289 atomic_t nr_outstanding_calls;
290 atomic_t nr_superblocks;
291
292 /* Cell database */
989782dc 293 struct rb_root cells;
1d0b929f 294 struct idr cells_dyn_ino; /* cell->dynroot_ino mapping */
823869e1 295 struct afs_cell __rcu *ws_cell;
989782dc 296 atomic_t cells_outstanding;
92e3cc91 297 struct rw_semaphore cells_lock;
8a070a96 298 struct mutex cells_alias_lock;
f044c884 299
0da0b7fd 300 struct mutex proc_cells_lock;
6b3944e4 301 struct hlist_head proc_cells;
f044c884 302
d2ddc776
DH
303 /* Known servers. Theoretically each fileserver can only be in one
304 * cell, but in practice, people create aliases and subsets and there's
305 * no easy way to distinguish them.
306 */
4882ba78 307 seqlock_t fs_lock; /* For fs_probe_*, fs_proc */
f6cbb368
DH
308 struct list_head fs_probe_fast; /* List of afs_server to probe at 30s intervals */
309 struct list_head fs_probe_slow; /* List of afs_server to probe at 5m intervals */
d2ddc776 310 struct hlist_head fs_proc; /* procfs servers list */
f044c884 311
d98c317f 312 struct key *fs_cm_token_key; /* Key for creating CM tokens */
f6cbb368
DH
313 struct work_struct fs_prober;
314 struct timer_list fs_probe_timer;
59fa1c4a 315 atomic_t servers_outstanding;
f044c884 316
d2ddc776
DH
317 /* File locking renewal management */
318 struct mutex lock_manager_mutex;
319
f044c884 320 /* Misc */
0da0b7fd 321 struct super_block *dynroot_sb; /* Dynamic root mount superblock */
d55b4da4 322 struct proc_dir_entry *proc_afs; /* /proc/net/afs directory */
6f8880d8
DH
323 struct afs_sysnames *sysnames;
324 rwlock_t sysnames_lock;
f94f70d3
DH
325 struct afs_addr_preference_list __rcu *address_prefs;
326 u16 address_pref_version;
d55b4da4
DH
327
328 /* Statistics counters */
329 atomic_t n_lookup; /* Number of lookups done */
330 atomic_t n_reval; /* Number of dentries needing revalidation */
331 atomic_t n_inval; /* Number of invalidations by the server */
508cae68 332 atomic_t n_relpg; /* Number of invalidations by release_folio */
d55b4da4 333 atomic_t n_read_dir; /* Number of directory pages read */
63a4681f
DH
334 atomic_t n_dir_cr; /* Number of directory entry creation edits */
335 atomic_t n_dir_rm; /* Number of directory entry removal edits */
76a5cb6f
DH
336 atomic_t n_stores; /* Number of store ops */
337 atomic_long_t n_store_bytes; /* Number of bytes stored */
338 atomic_long_t n_fetch_bytes; /* Number of bytes fetched */
339 atomic_t n_fetches; /* Number of data fetch ops */
f044c884
DH
340};
341
6f8880d8 342extern const char afs_init_sysname[];
f044c884 343
989782dc 344enum afs_cell_state {
e2c2cb8e 345 AFS_CELL_SETTING_UP,
989782dc 346 AFS_CELL_ACTIVE,
e2c2cb8e
DH
347 AFS_CELL_REMOVING,
348 AFS_CELL_DEAD,
989782dc
DH
349};
350
08e0e7c8 351/*
d2ddc776
DH
352 * AFS cell record.
353 *
354 * This is a tricky concept to get right as it is possible to create aliases
355 * simply by pointing AFSDB/SRV records for two names at the same set of VL
356 * servers; it is also possible to do things like setting up two sets of VL
357 * servers, one of which provides a superset of the volumes provided by the
358 * other (for internal/external division, for example).
359 *
360 * Cells only exist in the sense that (a) a cell's name maps to a set of VL
361 * servers and (b) a cell's name is used by the client to select the key to use
362 * for authentication and encryption. The cell name is not typically used in
363 * the protocol.
364 *
8a070a96
DH
365 * Two cells are determined to be aliases if they have an explicit alias (YFS
366 * only), share any VL servers in common or have at least one volume in common.
367 * "In common" means that the address list of the VL servers or the fileservers
368 * share at least one endpoint.
08e0e7c8
DH
369 */
370struct afs_cell {
989782dc
DH
371 union {
372 struct rcu_head rcu;
373 struct rb_node net_node; /* Node in net->cells */
374 };
375 struct afs_net *net;
8a070a96
DH
376 struct afs_cell *alias_of; /* The cell this is an alias of */
377 struct afs_volume *root_volume; /* The root.cell volume if there is one */
00d3b7a4 378 struct key *anonymous_key; /* anonymous user key for this cell */
e2c2cb8e 379 struct work_struct destroyer; /* Destroyer for cell */
989782dc 380 struct work_struct manager; /* Manager for init/deinit/dns */
e2c2cb8e 381 struct timer_list management_timer; /* General management timer */
6b3944e4 382 struct hlist_node proc_link; /* /proc cell list link */
989782dc
DH
383 time64_t dns_expiry; /* Time AFSDB/SRV record expires */
384 time64_t last_inactive; /* Time of last drop of usage count */
c56f9ec8 385 refcount_t ref; /* Struct refcount */
88c853c3 386 atomic_t active; /* Active usage counter */
989782dc 387 unsigned long flags;
d5c32c89
DH
388#define AFS_CELL_FL_NO_GC 0 /* The cell was added manually, don't auto-gc */
389#define AFS_CELL_FL_DO_LOOKUP 1 /* DNS lookup requested */
8a070a96 390#define AFS_CELL_FL_CHECK_ALIAS 2 /* Need to check for aliases */
989782dc
DH
391 enum afs_cell_state state;
392 short error;
d5c32c89
DH
393 enum dns_record_source dns_source:8; /* Latest source of data from lookup */
394 enum dns_lookup_status dns_status:8; /* Latest status of data from lookup */
395 unsigned int dns_lookup_count; /* Counter of DNS lookups */
dca54a7b 396 unsigned int debug_id;
1d0b929f 397 unsigned int dynroot_ino; /* Inode numbers for dynroot (a pair) */
989782dc 398
20325960 399 /* The volumes belonging to this cell */
32222f09 400 struct rw_semaphore vs_lock; /* Lock for server->volumes */
20325960
DH
401 struct rb_root volumes; /* Tree of volumes on this server */
402 struct hlist_head proc_volumes; /* procfs volume list */
403 seqlock_t volume_lock; /* For volumes */
404
d2ddc776 405 /* Active fileserver interaction state. */
20325960 406 struct rb_root fs_servers; /* afs_server (by server UUID) */
4882ba78 407 struct rw_semaphore fs_lock; /* For fs_servers */
989782dc 408
d2ddc776 409 /* VL server list. */
0a5143f2
DH
410 rwlock_t vl_servers_lock; /* Lock on vl_servers */
411 struct afs_vlserver_list __rcu *vl_servers;
412
989782dc 413 u8 name_len; /* Length of name */
719fdd32 414 char *name; /* Cell name, case-flattened and NUL-padded */
08e0e7c8
DH
415};
416
0a5143f2
DH
417/*
418 * Volume Location server record.
419 */
420struct afs_vlserver {
421 struct rcu_head rcu;
422 struct afs_addr_list __rcu *addresses; /* List of addresses for this VL server */
423 unsigned long flags;
424#define AFS_VLSERVER_FL_PROBED 0 /* The VL server has been probed */
425#define AFS_VLSERVER_FL_PROBING 1 /* VL server is being probed */
3bf0fb6f 426#define AFS_VLSERVER_FL_IS_YFS 2 /* Server is YFS not AFS */
b95b3094 427#define AFS_VLSERVER_FL_RESPONDING 3 /* VL server is responding */
0a5143f2 428 rwlock_t lock; /* Lock on addresses */
c56f9ec8 429 refcount_t ref;
b95b3094 430 unsigned int rtt; /* Server's current RTT in uS */
e6a7d7f7 431 unsigned int debug_id;
3bf0fb6f
DH
432
433 /* Probe state */
434 wait_queue_head_t probe_wq;
435 atomic_t probe_outstanding;
436 spinlock_t probe_lock;
437 struct {
72904d7b 438 unsigned int rtt; /* Best RTT in uS (or UINT_MAX) */
3bf0fb6f
DH
439 u32 abort_code;
440 short error;
fb72cd3d
DH
441 unsigned short flags;
442#define AFS_VLSERVER_PROBE_RESPONDED 0x01 /* At least once response (may be abort) */
443#define AFS_VLSERVER_PROBE_IS_YFS 0x02 /* The peer appears to be YFS */
444#define AFS_VLSERVER_PROBE_NOT_YFS 0x04 /* The peer appears not to be YFS */
445#define AFS_VLSERVER_PROBE_LOCAL_FAILURE 0x08 /* A local failure prevented a probe */
3bf0fb6f
DH
446 } probe;
447
e38f299e 448 u16 service_id; /* Service ID we're using */
0a5143f2 449 u16 port;
3bf0fb6f 450 u16 name_len; /* Length of name */
0a5143f2
DH
451 char name[]; /* Server name, case-flattened */
452};
453
454/*
455 * Weighted list of Volume Location servers.
456 */
457struct afs_vlserver_entry {
458 u16 priority; /* Preference (as SRV) */
459 u16 weight; /* Weight (as SRV) */
460 enum dns_record_source source:8;
461 enum dns_lookup_status status:8;
462 struct afs_vlserver *server;
463};
464
465struct afs_vlserver_list {
466 struct rcu_head rcu;
c56f9ec8 467 refcount_t ref;
0a5143f2
DH
468 u8 nr_servers;
469 u8 index; /* Server currently in use */
3bf0fb6f 470 u8 preferred; /* Preferred server */
0a5143f2
DH
471 enum dns_record_source source:8;
472 enum dns_lookup_status status:8;
473 rwlock_t lock;
474 struct afs_vlserver_entry servers[];
475};
476
08e0e7c8 477/*
d2ddc776
DH
478 * Cached VLDB entry.
479 *
480 * This is pointed to by cell->vldb_entries, indexed by name.
08e0e7c8 481 */
d2ddc776
DH
482struct afs_vldb_entry {
483 afs_volid_t vid[3]; /* Volume IDs for R/W, R/O and Bak volumes */
00d3b7a4 484
d2ddc776
DH
485 unsigned long flags;
486#define AFS_VLDB_HAS_RW 0 /* - R/W volume exists */
487#define AFS_VLDB_HAS_RO 1 /* - R/O volume exists */
488#define AFS_VLDB_HAS_BAK 2 /* - Backup volume exists */
489#define AFS_VLDB_QUERY_VALID 3 /* - Record is valid */
490#define AFS_VLDB_QUERY_ERROR 4 /* - VL server returned error */
491
492 uuid_t fs_server[AFS_NMAXNSERVERS];
81006805 493 u32 addr_version[AFS_NMAXNSERVERS]; /* Registration change counters */
d2ddc776 494 u8 fs_mask[AFS_NMAXNSERVERS];
08e0e7c8
DH
495#define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */
496#define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */
497#define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */
d3acd81e 498 u8 vlsf_flags[AFS_NMAXNSERVERS];
d2ddc776
DH
499 short error;
500 u8 nr_servers; /* Number of server records */
501 u8 name_len;
502 u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */
08e0e7c8
DH
503};
504
f49b594d
DH
505/*
506 * Fileserver endpoint state. The records the addresses of a fileserver's
507 * endpoints and the state and result of a round of probing on them. This
508 * allows the rotation algorithm to access those results without them being
509 * erased by a subsequent round of probing.
510 */
511struct afs_endpoint_state {
512 struct rcu_head rcu;
513 struct afs_addr_list *addresses; /* The addresses being probed */
514 unsigned long responsive_set; /* Bitset of responsive endpoints */
515 unsigned long failed_set; /* Bitset of endpoints we failed to probe */
516 refcount_t ref;
517 unsigned int server_id; /* Debug ID of server */
518 unsigned int probe_seq; /* Probe sequence (from server::probe_counter) */
f49b594d
DH
519 atomic_t nr_probing; /* Number of outstanding probes */
520 unsigned int rtt; /* Best RTT in uS (or UINT_MAX) */
521 s32 abort_code;
522 short error;
21c1f410
DH
523 unsigned long flags;
524#define AFS_ESTATE_RESPONDED 0 /* Set if the server responded */
525#define AFS_ESTATE_SUPERSEDED 1 /* Set if this record has been superseded */
526#define AFS_ESTATE_IS_YFS 2 /* Set if probe upgraded to YFS */
527#define AFS_ESTATE_NOT_YFS 3 /* Set if probe didn't upgrade to YFS */
528#define AFS_ESTATE_LOCAL_FAILURE 4 /* Set if there was a local failure (eg. ENOMEM) */
f49b594d
DH
529};
530
08e0e7c8 531/*
d2ddc776 532 * Record of fileserver with which we're actively communicating.
08e0e7c8
DH
533 */
534struct afs_server {
d2ddc776
DH
535 struct rcu_head rcu;
536 union {
537 uuid_t uuid; /* Server ID */
538 struct afs_uuid _uuid;
539 };
540
20325960 541 struct afs_cell *cell; /* Cell to which belongs (pins ref) */
4882ba78
DH
542 struct rb_node uuid_rb; /* Link in cell->fs_servers */
543 struct list_head probe_link; /* Link in net->fs_probe_* */
d2ddc776 544 struct hlist_node proc_link; /* Link in net->fs_proc */
ca0e79a4 545 struct list_head volumes; /* RCU list of afs_server_entry objects */
4882ba78
DH
546 struct work_struct destroyer; /* Work item to try and destroy a server */
547 struct timer_list timer; /* Management timer */
d98c317f
DH
548 struct mutex cm_token_lock; /* Lock governing creation of appdata */
549 struct krb5_buffer cm_rxgk_appdata; /* Appdata to be included in RESPONSE packet */
977e5f8e 550 time64_t unuse_time; /* Time at which last unused */
c435ee34 551 unsigned long flags;
f3c130e6 552#define AFS_SERVER_FL_RESPONDING 0 /* The server is responding */
32275d3f
DH
553#define AFS_SERVER_FL_UPDATING 1
554#define AFS_SERVER_FL_NEEDS_UPDATE 2 /* Fileserver address list is out of date */
4882ba78
DH
555#define AFS_SERVER_FL_UNCREATED 3 /* The record needs creating */
556#define AFS_SERVER_FL_CREATING 4 /* The record is being created */
557#define AFS_SERVER_FL_EXPIRED 5 /* The record has expired */
558#define AFS_SERVER_FL_NOT_FOUND 6 /* VL server says no such server */
559#define AFS_SERVER_FL_VL_FAIL 7 /* Failed to access VL server */
f2686b09 560#define AFS_SERVER_FL_MAY_HAVE_CB 8 /* May have callbacks on this fileserver */
32275d3f
DH
561#define AFS_SERVER_FL_IS_YFS 16 /* Server is YFS not AFS */
562#define AFS_SERVER_FL_NO_IBULK 17 /* Fileserver doesn't support FS.InlineBulkStatus */
563#define AFS_SERVER_FL_NO_RM2 18 /* Fileserver doesn't support YFS.RemoveFile2 */
b537a3c2 564#define AFS_SERVER_FL_HAS_FS64 19 /* Fileserver supports FS.{Fetch,Store}Data64 */
c56f9ec8 565 refcount_t ref; /* Object refcount */
977e5f8e 566 atomic_t active; /* Active user count */
d2ddc776 567 u32 addr_version; /* Address list version */
e38f299e 568 u16 service_id; /* Service ID we're using. */
4882ba78 569 short create_error; /* Creation error */
f3c130e6 570 unsigned int rtt; /* Server's current RTT in uS */
45218193 571 unsigned int debug_id; /* Debugging ID for traces */
08e0e7c8
DH
572
573 /* file service access */
d2ddc776 574 rwlock_t fs_lock; /* access lock */
08e0e7c8 575
3bf0fb6f 576 /* Probe state */
f49b594d 577 struct afs_endpoint_state __rcu *endpoint_state; /* Latest endpoint/probe state */
f6cbb368 578 unsigned long probed_at; /* Time last probe was dispatched (jiffies) */
3bf0fb6f 579 wait_queue_head_t probe_wq;
f49b594d 580 unsigned int probe_counter; /* Number of probes issued */
3bf0fb6f 581 spinlock_t probe_lock;
c435ee34
DH
582};
583
d3acd81e
DH
584enum afs_ro_replicating {
585 AFS_RO_NOT_REPLICATING, /* Not doing replication */
586 AFS_RO_REPLICATING_USE_OLD, /* Replicating; use old version */
587 AFS_RO_REPLICATING_USE_NEW, /* Replicating; switch to new version */
588} __mode(byte);
589
08e0e7c8 590/*
194d28cf 591 * Replaceable volume server list.
d2ddc776
DH
592 */
593struct afs_server_entry {
594 struct afs_server *server;
ca0e79a4
DH
595 struct afs_volume *volume;
596 struct list_head slink; /* Link in server->volumes */
453924de 597 time64_t cb_expires_at; /* Time at which volume-level callback expires */
d3acd81e
DH
598 unsigned long flags;
599#define AFS_SE_EXCLUDED 0 /* Set if server is to be excluded in rotation */
28f4c580
DH
600#define AFS_SE_VOLUME_OFFLINE 1 /* Set if volume offline notice given */
601#define AFS_SE_VOLUME_BUSY 2 /* Set if volume busy notice given */
d2ddc776
DH
602};
603
604struct afs_server_list {
e6bace73 605 struct rcu_head rcu;
d2ddc776 606 refcount_t usage;
ca0e79a4 607 bool attached; /* T if attached to servers */
d3acd81e 608 enum afs_ro_replicating ro_replicating; /* RW->RO update (probably) in progress */
3bf0fb6f 609 unsigned char nr_servers;
d2ddc776
DH
610 unsigned short vnovol_mask; /* Servers to be skipped due to VNOVOL */
611 unsigned int seq; /* Set to ->servers_seq when installed */
d4a96bec 612 rwlock_t lock;
d2ddc776
DH
613 struct afs_server_entry servers[];
614};
615
616/*
617 * Live AFS volume management.
08e0e7c8
DH
618 */
619struct afs_volume {
ca0e79a4
DH
620 struct rcu_head rcu;
621 afs_volid_t vid; /* The volume ID of this volume */
622 afs_volid_t vids[AFS_MAXTYPES]; /* All associated volume IDs */
c56f9ec8 623 refcount_t ref;
4f67bcf6 624 unsigned int debug_id; /* Debugging ID for traces */
d2ddc776
DH
625 time64_t update_at; /* Time at which to next update */
626 struct afs_cell *cell; /* Cell to which belongs (pins ref) */
20325960
DH
627 struct rb_node cell_node; /* Link in cell->volumes */
628 struct hlist_node proc_link; /* Link in cell->proc_volumes */
629 struct super_block __rcu *sb; /* Superblock on which inodes reside */
445f9b69 630 struct work_struct destructor; /* Deferred destructor */
d2ddc776
DH
631 unsigned long flags;
632#define AFS_VOLUME_NEEDS_UPDATE 0 /* - T if an update needs performing */
633#define AFS_VOLUME_UPDATING 1 /* - T if an update is in progress */
634#define AFS_VOLUME_WAIT 2 /* - T if users must wait for update */
635#define AFS_VOLUME_DELETED 3 /* - T if volume appears deleted */
28f4c580
DH
636#define AFS_VOLUME_MAYBE_NO_IBULK 4 /* - T if some servers don't have InlineBulkStatus */
637#define AFS_VOLUME_RM_TREE 5 /* - Set if volume removed from cell->volumes */
9b3f26c9 638#ifdef CONFIG_AFS_FSCACHE
523d27cd 639 struct fscache_volume *cache; /* Caching cookie */
08e0e7c8 640#endif
8a070a96 641 struct afs_server_list __rcu *servers; /* List of servers on which volume resides */
d2ddc776
DH
642 rwlock_t servers_lock; /* Lock for ->servers */
643 unsigned int servers_seq; /* Incremented each time ->servers changes */
644
16069e13
DH
645 /* RO release tracking */
646 struct mutex volsync_lock; /* Time/state evaluation lock */
647 time64_t creation_time; /* Volume creation time (or TIME64_MIN) */
648 time64_t update_time; /* Volume update time (or TIME64_MIN) */
649
650 /* Callback management */
453924de
DH
651 struct mutex cb_check_lock; /* Lock to control race to check after v_break */
652 time64_t cb_expires_at; /* Earliest volume callback expiry time */
16069e13
DH
653 atomic_t cb_ro_snapshot; /* RO volume update-from-snapshot counter */
654 atomic_t cb_v_break; /* Volume-break event counter. */
453924de 655 atomic_t cb_v_check; /* Volume-break has-been-checked counter. */
16069e13 656 atomic_t cb_scrub; /* Scrub-all-data event counter. */
90fa9b64 657 rwlock_t cb_v_break_lock;
453924de
DH
658 struct rw_semaphore open_mmaps_lock;
659 struct list_head open_mmaps; /* List of vnodes that are mmapped */
68251f0a 660
08e0e7c8
DH
661 afs_voltype_t type; /* type of volume */
662 char type_force; /* force volume type (suppress R/O -> R/W) */
d2ddc776
DH
663 u8 name_len;
664 u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */
08e0e7c8
DH
665};
666
0fafdc9f
DH
667enum afs_lock_state {
668 AFS_VNODE_LOCK_NONE, /* The vnode has no lock on the server */
669 AFS_VNODE_LOCK_WAITING_FOR_CB, /* We're waiting for the server to break the callback */
670 AFS_VNODE_LOCK_SETTING, /* We're asking the server for a lock */
671 AFS_VNODE_LOCK_GRANTED, /* We have a lock on the server */
672 AFS_VNODE_LOCK_EXTENDING, /* We're extending a lock on the server */
673 AFS_VNODE_LOCK_NEED_UNLOCK, /* We need to unlock on the server */
674 AFS_VNODE_LOCK_UNLOCKING, /* We're telling the server to unlock */
cdfb26b4 675 AFS_VNODE_LOCK_DELETED, /* The vnode has been deleted whilst we have a lock */
0fafdc9f
DH
676};
677
08e0e7c8 678/*
f8de483e
DH
679 * AFS inode private data.
680 *
681 * Note that afs_alloc_inode() *must* reset anything that could incorrectly
682 * leak from one inode to another.
08e0e7c8
DH
683 */
684struct afs_vnode {
874c8ca1 685 struct netfs_inode netfs; /* Netfslib context and vfs inode */
08e0e7c8 686 struct afs_volume *volume; /* volume on which vnode resides */
08e0e7c8
DH
687 struct afs_fid fid; /* the file identifier for this inode */
688 struct afs_file_status status; /* AFS status info for this file */
a4ff7401 689 afs_dataversion_t invalid_before; /* Child dentries are invalid before this */
fe342cf7 690 struct afs_permits __rcu *permit_cache; /* cache of permits so far obtained */
6e0b503d 691 struct list_head io_lock_waiters; /* Threads waiting for the I/O lock */
b61f7dcf 692 struct rw_semaphore validate_lock; /* lock for validating this vnode */
79ddbfa5
DH
693 struct rw_semaphore rmdir_lock; /* Lock for rmdir vs sillyrename */
694 struct key *silly_key; /* Silly rename key */
4343d008 695 spinlock_t wb_lock; /* lock for wb_keys */
08e0e7c8
DH
696 spinlock_t lock; /* waitqueue/flags lock */
697 unsigned long flags;
6e0b503d 698#define AFS_VNODE_IO_LOCK 0 /* Set if the I/O serialisation lock is held */
260a9803 699#define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */
f3ddee8d 700#define AFS_VNODE_DIR_VALID 2 /* Set if dir contents are valid */
08e0e7c8
DH
701#define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */
702#define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */
703#define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */
0fafdc9f 704#define AFS_VNODE_PSEUDODIR 7 /* set if Vnode is a pseudo directory */
5a813276 705#define AFS_VNODE_NEW_CONTENT 8 /* Set if file has new content (create/trunc-0) */
b6489a49 706#define AFS_VNODE_SILLY_DELETED 9 /* Set if file has been silly-deleted */
22650f14 707#define AFS_VNODE_MODIFYING 10 /* Set if we're performing a modification op */
6dd80936 708#define AFS_VNODE_DIR_READ 11 /* Set if we've read a dir's contents */
08e0e7c8 709
6dd80936 710 struct folio_queue *directory; /* Directory contents */
4343d008 711 struct list_head wb_keys; /* List of keys available for writeback */
e8d6c554
DH
712 struct list_head pending_locks; /* locks waiting to be granted */
713 struct list_head granted_locks; /* locks granted on this file */
714 struct delayed_work lock_work; /* work to be done in locking */
0fafdc9f 715 struct key *lock_key; /* Key to be used in lock ops */
a690f60a 716 ktime_t locked_at; /* Time at which lock obtained */
0fafdc9f
DH
717 enum afs_lock_state lock_state : 8;
718 afs_lock_type_t lock_type : 8;
6dd80936 719 unsigned int directory_size; /* Amount of space in ->directory */
31143d5d 720
08e0e7c8 721 /* outstanding callback notification on this file */
6e0e99d5
DH
722 struct work_struct cb_work; /* Work for mmap'd files */
723 struct list_head cb_mmap_link; /* Link in cell->fs_open_mmaps */
20325960 724 void *cb_server; /* Server with callback/filelock */
6e0e99d5 725 atomic_t cb_nr_mmap; /* Number of mmaps */
453924de
DH
726 unsigned int cb_ro_snapshot; /* RO volume release counter on ->volume */
727 unsigned int cb_scrub; /* Scrub counter on ->volume */
c435ee34 728 unsigned int cb_break; /* Break counter on vnode */
453924de 729 unsigned int cb_v_check; /* Break check counter on ->volume */
20325960 730 seqlock_t cb_lock; /* Lock for ->cb_server, ->status, ->cb_*break */
c435ee34 731
453924de
DH
732 atomic64_t cb_expires_at; /* time at which callback expires */
733#define AFS_NO_CB_PROMISE TIME64_MIN
08e0e7c8
DH
734};
735
12bdcf33
DH
736static inline struct fscache_cookie *afs_vnode_cache(struct afs_vnode *vnode)
737{
738#ifdef CONFIG_AFS_FSCACHE
e81fb419 739 return netfs_i_cookie(&vnode->netfs);
12bdcf33
DH
740#else
741 return NULL;
742#endif
743}
744
bc899ee1
DH
745static inline void afs_vnode_set_cache(struct afs_vnode *vnode,
746 struct fscache_cookie *cookie)
747{
748#ifdef CONFIG_AFS_FSCACHE
874c8ca1 749 vnode->netfs.cache = cookie;
b4fa966f
DH
750 if (cookie)
751 mapping_set_release_always(vnode->netfs.inode.i_mapping);
bc899ee1
DH
752#endif
753}
754
00d3b7a4
DH
755/*
756 * cached security record for one user's attempt to access a vnode
757 */
758struct afs_permit {
759 struct key *key; /* RxRPC ticket holding a security context */
be080a6f 760 afs_access_t access; /* CallerAccess value for this key */
00d3b7a4
DH
761};
762
763/*
be080a6f
DH
764 * Immutable cache of CallerAccess records from attempts to access vnodes.
765 * These may be shared between multiple vnodes.
00d3b7a4
DH
766 */
767struct afs_permits {
be080a6f
DH
768 struct rcu_head rcu;
769 struct hlist_node hash_node; /* Link in hash */
770 unsigned long h; /* Hash value for this permit list */
771 refcount_t usage;
772 unsigned short nr_permits; /* Number of records */
773 bool invalidated; /* Invalidated due to key change */
aade1533 774 struct afs_permit permits[] __counted_by(nr_permits); /* List of permits sorted by key pointer */
00d3b7a4
DH
775};
776
4584ae96
DH
777/*
778 * Error prioritisation and accumulation.
779 */
780struct afs_error {
aa453bec
DH
781 s32 abort_code; /* Cumulative abort code */
782 short error; /* Cumulative error */
4584ae96 783 bool responded; /* T if server responded */
aa453bec 784 bool aborted; /* T if ->error is from an abort */
4584ae96
DH
785};
786
0a5143f2
DH
787/*
788 * Cursor for iterating over a set of volume location servers.
789 */
790struct afs_vl_cursor {
0a5143f2
DH
791 struct afs_cell *cell; /* The cell we're querying */
792 struct afs_vlserver_list *server_list; /* Current server list (pins ref) */
3bf0fb6f 793 struct afs_vlserver *server; /* Server on which this resides */
98f9fda2 794 struct afs_addr_list *alist; /* Current address list (pins ref) */
0a5143f2 795 struct key *key; /* Key for the server */
905b8615 796 unsigned long untried_servers; /* Bitmask of untried servers */
98f9fda2 797 unsigned long addr_tried; /* Tried addresses */
aa453bec 798 struct afs_error cumul_error; /* Cumulative error */
98f9fda2 799 unsigned int debug_id;
aa453bec 800 s32 call_abort_code;
aa453bec 801 short call_error; /* Error from single call */
905b8615 802 short server_index; /* Current server */
98f9fda2 803 signed char addr_index; /* Current address */
0a5143f2
DH
804 unsigned short flags;
805#define AFS_VL_CURSOR_STOP 0x0001 /* Set to cease iteration */
806#define AFS_VL_CURSOR_RETRY 0x0002 /* Set to do a retry */
807#define AFS_VL_CURSOR_RETRIED 0x0004 /* Set if started a retry */
aa453bec
DH
808 short nr_iterations; /* Number of server iterations */
809 bool call_responded; /* T if the current address responded */
0a5143f2
DH
810};
811
495f2ae9
DH
812/*
813 * Fileserver state tracking for an operation. An array of these is kept,
814 * indexed by server index.
815 */
816struct afs_server_state {
817 /* Tracking of fileserver probe state. Other operations may interfere
818 * by probing a fileserver when accessing other volumes.
819 */
820 unsigned int probe_seq;
821 unsigned long untried_addrs; /* Addresses we haven't tried yet */
822 struct wait_queue_entry probe_waiter;
823 struct afs_endpoint_state *endpoint_state; /* Endpoint state being monitored */
824};
825
8b2a464c 826/*
e49c7b2f
DH
827 * Fileserver operation methods.
828 */
829struct afs_operation_ops {
830 void (*issue_afs_rpc)(struct afs_operation *op);
831 void (*issue_yfs_rpc)(struct afs_operation *op);
832 void (*success)(struct afs_operation *op);
833 void (*aborted)(struct afs_operation *op);
dc419184 834 void (*failed)(struct afs_operation *op);
e49c7b2f
DH
835 void (*edit_dir)(struct afs_operation *op);
836 void (*put)(struct afs_operation *op);
837};
838
839struct afs_vnode_param {
840 struct afs_vnode *vnode;
841 struct afs_fid fid; /* Fid to access */
842 struct afs_status_cb scb; /* Returned status and callback promise */
843 afs_dataversion_t dv_before; /* Data version before the call */
453924de 844 unsigned int cb_break_before; /* cb_break before the call */
e49c7b2f 845 u8 dv_delta; /* Expected change in data version */
793fe82e
DH
846 bool put_vnode:1; /* T if we have a ref on the vnode */
847 bool need_io_lock:1; /* T if we need the I/O lock on this */
848 bool update_ctime:1; /* Need to update the ctime */
849 bool set_size:1; /* Must update i_size */
b6489a49 850 bool op_unlinked:1; /* True if file was unlinked by op */
a9e5c87c 851 bool speculative:1; /* T if speculative status fetch (no vnode lock) */
22650f14 852 bool modification:1; /* Set if the content gets modified */
e49c7b2f
DH
853};
854
855/*
856 * Fileserver operation wrapper, handling server and address rotation
857 * asynchronously. May make simultaneous calls to multiple servers.
8b2a464c 858 */
a310082f 859struct afs_operation {
e49c7b2f
DH
860 struct afs_net *net; /* Network namespace */
861 struct key *key; /* Key for the cell */
a58823ac 862 const struct afs_call_type *type; /* Type of call done */
e49c7b2f
DH
863 const struct afs_operation_ops *ops;
864
865 /* Parameters/results for the operation */
866 struct afs_volume *volume; /* Volume being accessed */
867 struct afs_vnode_param file[2];
868 struct afs_vnode_param *more_files;
16069e13
DH
869 struct afs_volsync pre_volsync; /* Volsync before op */
870 struct afs_volsync volsync; /* Volsync returned by op */
e49c7b2f
DH
871 struct dentry *dentry; /* Dentry to be altered */
872 struct dentry *dentry_2; /* Second dentry to be altered */
873 struct timespec64 mtime; /* Modification time to record */
da8d0755 874 struct timespec64 ctime; /* Change time to set */
aa453bec 875 struct afs_error cumul_error; /* Cumulative error */
e49c7b2f 876 short nr_files; /* Number of entries in file[], more_files */
e49c7b2f
DH
877 unsigned int debug_id;
878
879 unsigned int cb_v_break; /* Volume break counter before op */
e49c7b2f
DH
880
881 union {
882 struct {
883 int which; /* Which ->file[] to fetch for */
884 } fetch_status;
885 struct {
886 int reason; /* enum afs_edit_dir_reason */
887 mode_t mode;
888 const char *symlink;
889 } create;
890 struct {
891 bool need_rehash;
892 } unlink;
893 struct {
894 struct dentry *rehash;
895 struct dentry *tmp;
896 bool new_negative;
897 } rename;
898 struct {
f28fc201 899 struct netfs_io_subrequest *subreq;
e49c7b2f
DH
900 } fetch;
901 struct {
e49c7b2f
DH
902 afs_lock_type_t type;
903 } lock;
904 struct {
bd80d8a8
DH
905 struct iov_iter *write_iter;
906 loff_t pos;
907 loff_t size;
908 loff_t i_size;
e49c7b2f
DH
909 } store;
910 struct {
911 struct iattr *attr;
ec0fa0b6 912 loff_t old_i_size;
e49c7b2f
DH
913 } setattr;
914 struct afs_acl *acl;
915 struct yfs_acl *yacl;
916 struct {
917 struct afs_volume_status vs;
918 struct kstatfs *buf;
919 } volstatus;
920 };
921
922 /* Fileserver iteration state */
d2ddc776 923 struct afs_server_list *server_list; /* Current server list (pins ref) */
20325960 924 struct afs_server *server; /* Server we're using (ref pinned by server_list) */
495f2ae9
DH
925 struct afs_endpoint_state *estate; /* Current endpoint state (doesn't pin ref) */
926 struct afs_server_state *server_states; /* States of the servers involved */
e49c7b2f 927 struct afs_call *call;
905b8615 928 unsigned long untried_servers; /* Bitmask of untried servers */
98f9fda2
DH
929 unsigned long addr_tried; /* Tried addresses */
930 s32 call_abort_code; /* Abort code from single call */
931 short call_error; /* Error from single call */
905b8615 932 short server_index; /* Current server */
075171fd 933 short nr_iterations; /* Number of server iterations */
98f9fda2 934 signed char addr_index; /* Current address */
aa453bec
DH
935 bool call_responded; /* T if the current address responded */
936
e49c7b2f 937 unsigned int flags;
8409f67b
DH
938#define AFS_OPERATION_STOP 0x0001 /* Set to cease iteration */
939#define AFS_OPERATION_VBUSY 0x0002 /* Set if seen VBUSY */
940#define AFS_OPERATION_VMOVED 0x0004 /* Set if seen VMOVED */
941#define AFS_OPERATION_VNOVOL 0x0008 /* Set if seen VNOVOL */
942#define AFS_OPERATION_CUR_ONLY 0x0010 /* Set if current server only (file lock held) */
943#define AFS_OPERATION_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */
944#define AFS_OPERATION_UNINTR 0x0040 /* Set if op is uninterruptible */
945#define AFS_OPERATION_DOWNGRADE 0x0080 /* Set to retry with downgraded opcode */
946#define AFS_OPERATION_LOCK_0 0x0100 /* Set if have io_lock on file[0] */
947#define AFS_OPERATION_LOCK_1 0x0200 /* Set if have io_lock on file[1] */
948#define AFS_OPERATION_TRIED_ALL 0x0400 /* Set if we've tried all the fileservers */
949#define AFS_OPERATION_RETRY_SERVER 0x0800 /* Set if we should retry the current server */
b6489a49 950#define AFS_OPERATION_DIR_CONFLICT 0x1000 /* Set if we detected a 3rd-party dir change */
eddf51f2 951#define AFS_OPERATION_ASYNC 0x2000 /* Set if should run asynchronously */
8b2a464c
DH
952};
953
402cb8dd
DH
954/*
955 * Cache auxiliary data.
956 */
957struct afs_vnode_cache_aux {
523d27cd 958 __be64 data_version;
402cb8dd
DH
959} __packed;
960
523d27cd
DH
961static inline void afs_set_cache_aux(struct afs_vnode *vnode,
962 struct afs_vnode_cache_aux *aux)
963{
964 aux->data_version = cpu_to_be64(vnode->status.data_version);
965}
966
967static inline void afs_invalidate_cache(struct afs_vnode *vnode, unsigned int flags)
968{
969 struct afs_vnode_cache_aux aux;
970
971 afs_set_cache_aux(vnode, &aux);
972 fscache_invalidate(afs_vnode_cache(vnode), &aux,
874c8ca1 973 i_size_read(&vnode->netfs.inode), flags);
523d27cd
DH
974}
975
6dd80936
DH
976/*
977 * Directory iteration management.
978 */
979struct afs_dir_iter {
980 struct afs_vnode *dvnode;
a5b5beeb 981 union afs_xdr_dir_block *block;
6dd80936
DH
982 struct folio_queue *fq;
983 unsigned int fpos;
984 int fq_slot;
a5b5beeb
DH
985 unsigned int loop_check;
986 u8 nr_slots;
987 u8 bucket;
988 unsigned int prev_entry;
6dd80936
DH
989};
990
98bf40cd
DH
991#include <trace/events/afs.h>
992
08e0e7c8 993/*****************************************************************************/
8b2a464c
DH
994/*
995 * addr_list.c
996 */
1e5d8493 997struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist, enum afs_alist_trace reason);
e38f299e 998extern struct afs_addr_list *afs_alloc_addrlist(unsigned int nr);
1e5d8493 999extern void afs_put_addrlist(struct afs_addr_list *alist, enum afs_alist_trace reason);
0a5143f2
DH
1000extern struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *,
1001 const char *, size_t, char,
1002 unsigned short, unsigned short);
07f3502b
DH
1003bool afs_addr_list_same(const struct afs_addr_list *a,
1004 const struct afs_addr_list *b);
0a5143f2 1005extern struct afs_vlserver_list *afs_dns_query(struct afs_cell *, time64_t *);
8b2a464c 1006
72904d7b
DH
1007extern int afs_merge_fs_addr4(struct afs_net *net, struct afs_addr_list *addr,
1008 __be32 xdr, u16 port);
1009extern int afs_merge_fs_addr6(struct afs_net *net, struct afs_addr_list *addr,
1010 __be32 *xdr, u16 port);
40e8b52f
DH
1011void afs_set_peer_appdata(struct afs_server *server,
1012 struct afs_addr_list *old_alist,
1013 struct afs_addr_list *new_alist);
d2ddc776 1014
f94f70d3
DH
1015/*
1016 * addr_prefs.c
1017 */
1018int afs_proc_addr_prefs_write(struct file *file, char *buf, size_t size);
d14cf8ed
DH
1019void afs_get_address_preferences_rcu(struct afs_net *net, struct afs_addr_list *alist);
1020void afs_get_address_preferences(struct afs_net *net, struct afs_addr_list *alist);
f94f70d3 1021
08e0e7c8
DH
1022/*
1023 * callback.c
1024 */
6e0e99d5 1025extern void afs_invalidate_mmap_work(struct work_struct *);
08e0e7c8 1026extern void afs_init_callback_state(struct afs_server *);
051d2525
DH
1027extern void __afs_break_callback(struct afs_vnode *, enum afs_cb_break_reason);
1028extern void afs_break_callback(struct afs_vnode *, enum afs_cb_break_reason);
1029extern void afs_break_callbacks(struct afs_server *, size_t, struct afs_callback_break *);
c435ee34 1030
68251f0a
DH
1031static inline unsigned int afs_calc_vnode_cb_break(struct afs_vnode *vnode)
1032{
453924de 1033 return vnode->cb_break + vnode->cb_ro_snapshot + vnode->cb_scrub;
68251f0a
DH
1034}
1035
18ac6185 1036static inline bool afs_cb_is_broken(unsigned int cb_break,
20325960 1037 const struct afs_vnode *vnode)
68251f0a 1038{
453924de
DH
1039 return cb_break != (vnode->cb_break +
1040 atomic_read(&vnode->volume->cb_ro_snapshot) +
1041 atomic_read(&vnode->volume->cb_scrub));
68251f0a
DH
1042}
1043
1da177e4
LT
1044/*
1045 * cell.c
1046 */
989782dc 1047extern int afs_cell_init(struct afs_net *, const char *);
dca54a7b
DH
1048extern struct afs_cell *afs_find_cell(struct afs_net *, const char *, unsigned,
1049 enum afs_cell_trace);
92c48157
DH
1050struct afs_cell *afs_lookup_cell(struct afs_net *net,
1051 const char *name, unsigned int namesz,
1052 const char *vllist, bool excl,
1053 enum afs_cell_trace trace);
dca54a7b 1054extern struct afs_cell *afs_use_cell(struct afs_cell *, enum afs_cell_trace);
469c82b5 1055void afs_unuse_cell(struct afs_cell *cell, enum afs_cell_trace reason);
dca54a7b
DH
1056extern struct afs_cell *afs_get_cell(struct afs_cell *, enum afs_cell_trace);
1057extern void afs_see_cell(struct afs_cell *, enum afs_cell_trace);
1058extern void afs_put_cell(struct afs_cell *, enum afs_cell_trace);
1059extern void afs_queue_cell(struct afs_cell *, enum afs_cell_trace);
e2c2cb8e 1060void afs_set_cell_timer(struct afs_cell *cell, unsigned int delay_secs);
f044c884 1061extern void __net_exit afs_cell_purge(struct afs_net *);
08e0e7c8
DH
1062
1063/*
1064 * cmservice.c
1065 */
1066extern bool afs_cm_incoming_call(struct afs_call *);
1067
5800b1cf
DH
1068/*
1069 * cm_security.c
1070 */
1071void afs_process_oob_queue(struct work_struct *work);
d98c317f
DH
1072#ifdef CONFIG_RXGK
1073int afs_create_token_key(struct afs_net *net, struct socket *socket);
1074#else
1075static inline int afs_create_token_key(struct afs_net *net, struct socket *socket)
1076{
1077 return 0;
1078}
1079#endif
5800b1cf 1080
1da177e4
LT
1081/*
1082 * dir.c
1083 */
4d673da1 1084extern const struct file_operations afs_dir_file_operations;
754661f1 1085extern const struct inode_operations afs_dir_inode_operations;
f3ddee8d 1086extern const struct address_space_operations afs_dir_aops;
d61dcce2 1087extern const struct dentry_operations afs_fs_dentry_operations;
4d673da1 1088
6dd80936 1089ssize_t afs_read_single(struct afs_vnode *dvnode, struct file *file);
a5b5beeb
DH
1090ssize_t afs_read_dir(struct afs_vnode *dvnode, struct file *file)
1091 __acquires(&dvnode->validate_lock);
66c7e1d3 1092extern void afs_d_release(struct dentry *);
728279a5 1093extern void afs_check_for_remote_deletion(struct afs_operation *);
6dd80936
DH
1094int afs_single_writepages(struct address_space *mapping,
1095 struct writeback_control *wbc);
66c7e1d3 1096
63a4681f
DH
1097/*
1098 * dir_edit.c
1099 */
1100extern void afs_edit_dir_add(struct afs_vnode *, struct qstr *, struct afs_fid *,
1101 enum afs_edit_dir_reason);
1102extern void afs_edit_dir_remove(struct afs_vnode *, struct qstr *, enum afs_edit_dir_reason);
247d65fb
DH
1103void afs_edit_dir_update_dotdot(struct afs_vnode *vnode, struct afs_vnode *new_dvnode,
1104 enum afs_edit_dir_reason why);
836bb70b 1105void afs_mkdir_init_dir(struct afs_vnode *dvnode, struct afs_vnode *parent_vnode);
63a4681f 1106
a5b5beeb
DH
1107/*
1108 * dir_search.c
1109 */
1110unsigned int afs_dir_hash_name(const struct qstr *name);
1111bool afs_dir_init_iter(struct afs_dir_iter *iter, const struct qstr *name);
1112union afs_xdr_dir_block *afs_dir_find_block(struct afs_dir_iter *iter, size_t block);
1113int afs_dir_search_bucket(struct afs_dir_iter *iter, const struct qstr *name,
1114 struct afs_fid *_fid);
1115int afs_dir_search(struct afs_vnode *dvnode, struct qstr *name,
1116 struct afs_fid *_fid, afs_dataversion_t *_dir_version);
1117
79ddbfa5
DH
1118/*
1119 * dir_silly.c
1120 */
1121extern int afs_sillyrename(struct afs_vnode *, struct afs_vnode *,
1122 struct dentry *, struct key *);
1123extern int afs_silly_iput(struct dentry *, struct inode *);
1124
66c7e1d3
DH
1125/*
1126 * dynroot.c
1127 */
66c7e1d3
DH
1128extern const struct inode_operations afs_dynroot_inode_operations;
1129extern const struct dentry_operations afs_dynroot_dentry_operations;
1130
1d0b929f 1131struct inode *afs_dynroot_iget_root(struct super_block *sb);
1da177e4
LT
1132
1133/*
1134 * file.c
1135 */
75bd228d 1136extern const struct address_space_operations afs_file_aops;
754661f1 1137extern const struct inode_operations afs_file_inode_operations;
00d3b7a4 1138extern const struct file_operations afs_file_operations;
f28fc201 1139extern const struct afs_operation_ops afs_fetch_data_operation;
6a19114b 1140extern const struct netfs_request_ops afs_req_ops;
00d3b7a4 1141
4343d008
DH
1142extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *);
1143extern void afs_put_wb_key(struct afs_wb_key *);
00d3b7a4
DH
1144extern int afs_open(struct inode *, struct file *);
1145extern int afs_release(struct inode *, struct file *);
eddf51f2
DH
1146void afs_fetch_data_async_rx(struct work_struct *work);
1147void afs_fetch_data_immediate_cancel(struct afs_call *call);
d4438a25 1148
e8d6c554
DH
1149/*
1150 * flock.c
1151 */
f044c884
DH
1152extern struct workqueue_struct *afs_lock_manager;
1153
a690f60a 1154extern void afs_lock_op_done(struct afs_call *);
e8d6c554
DH
1155extern void afs_lock_work(struct work_struct *);
1156extern void afs_lock_may_be_available(struct afs_vnode *);
1157extern int afs_lock(struct file *, int, struct file_lock *);
1158extern int afs_flock(struct file *, int, struct file_lock *);
1159
08e0e7c8
DH
1160/*
1161 * fsclient.c
1162 */
e49c7b2f
DH
1163extern void afs_fs_fetch_status(struct afs_operation *);
1164extern void afs_fs_fetch_data(struct afs_operation *);
1165extern void afs_fs_create_file(struct afs_operation *);
1166extern void afs_fs_make_dir(struct afs_operation *);
1167extern void afs_fs_remove_file(struct afs_operation *);
1168extern void afs_fs_remove_dir(struct afs_operation *);
1169extern void afs_fs_link(struct afs_operation *);
1170extern void afs_fs_symlink(struct afs_operation *);
1171extern void afs_fs_rename(struct afs_operation *);
1172extern void afs_fs_store_data(struct afs_operation *);
1173extern void afs_fs_setattr(struct afs_operation *);
1174extern void afs_fs_get_volume_status(struct afs_operation *);
1175extern void afs_fs_set_lock(struct afs_operation *);
1176extern void afs_fs_extend_lock(struct afs_operation *);
1177extern void afs_fs_release_lock(struct afs_operation *);
98f9fda2
DH
1178int afs_fs_give_up_all_callbacks(struct afs_net *net, struct afs_server *server,
1179 struct afs_address *addr, struct key *key);
1180bool afs_fs_get_capabilities(struct afs_net *net, struct afs_server *server,
f49b594d 1181 struct afs_endpoint_state *estate, unsigned int addr_index,
98f9fda2 1182 struct key *key);
e49c7b2f 1183extern void afs_fs_inline_bulk_status(struct afs_operation *);
08e0e7c8 1184
260f082b
DH
1185struct afs_acl {
1186 u32 size;
44642564 1187 u8 data[] __counted_by(size);
260f082b
DH
1188};
1189
e49c7b2f
DH
1190extern void afs_fs_fetch_acl(struct afs_operation *);
1191extern void afs_fs_store_acl(struct afs_operation *);
1192
1193/*
1194 * fs_operation.c
1195 */
1196extern struct afs_operation *afs_alloc_operation(struct key *, struct afs_volume *);
1197extern int afs_put_operation(struct afs_operation *);
1198extern bool afs_begin_vnode_operation(struct afs_operation *);
eddf51f2 1199extern void afs_end_vnode_operation(struct afs_operation *op);
e49c7b2f
DH
1200extern void afs_wait_for_operation(struct afs_operation *);
1201extern int afs_do_sync_operation(struct afs_operation *);
1202
e49c7b2f
DH
1203static inline void afs_op_set_vnode(struct afs_operation *op, unsigned int n,
1204 struct afs_vnode *vnode)
1205{
1206 op->file[n].vnode = vnode;
1207 op->file[n].need_io_lock = true;
1208}
1209
1210static inline void afs_op_set_fid(struct afs_operation *op, unsigned int n,
1211 const struct afs_fid *fid)
1212{
1213 op->file[n].fid = *fid;
1214}
260f082b 1215
3bf0fb6f
DH
1216/*
1217 * fs_probe.c
1218 */
f49b594d
DH
1219struct afs_endpoint_state *afs_get_endpoint_state(struct afs_endpoint_state *estate,
1220 enum afs_estate_trace where);
1221void afs_put_endpoint_state(struct afs_endpoint_state *estate, enum afs_estate_trace where);
3bf0fb6f 1222extern void afs_fileserver_probe_result(struct afs_call *);
40e8b52f
DH
1223int afs_fs_probe_fileserver(struct afs_net *net, struct afs_server *server,
1224 struct afs_addr_list *new_alist, struct key *key);
495f2ae9 1225int afs_wait_for_fs_probes(struct afs_operation *op, struct afs_server_state *states, bool intr);
8409f67b 1226extern void afs_probe_fileserver(struct afs_net *, struct afs_server *);
f6cbb368 1227extern void afs_fs_probe_dispatcher(struct work_struct *);
f49b594d 1228int afs_wait_for_one_fs_probe(struct afs_server *server, struct afs_endpoint_state *estate,
495f2ae9 1229 unsigned long exclude, bool is_intr);
5481fc6e 1230extern void afs_fs_probe_cleanup(struct afs_net *);
3bf0fb6f 1231
1da177e4
LT
1232/*
1233 * inode.c
1234 */
b6489a49
DH
1235extern const struct afs_operation_ops afs_fetch_status_operation;
1236
6698c02d 1237void afs_init_new_symlink(struct afs_vnode *vnode, struct afs_operation *op);
eae9e789
DH
1238const char *afs_get_link(struct dentry *dentry, struct inode *inode,
1239 struct delayed_call *callback);
1240int afs_readlink(struct dentry *dentry, char __user *buffer, int buflen);
e49c7b2f 1241extern void afs_vnode_commit_status(struct afs_operation *, struct afs_vnode_param *);
a58823ac 1242extern int afs_fetch_status(struct afs_vnode *, struct key *, bool, afs_access_t *);
e49c7b2f 1243extern int afs_ilookup5_test_by_fid(struct inode *, void *);
e49c7b2f
DH
1244extern struct inode *afs_iget(struct afs_operation *, struct afs_vnode_param *);
1245extern struct inode *afs_root_iget(struct super_block *, struct key *);
b74d24f7 1246extern int afs_getattr(struct mnt_idmap *idmap, const struct path *,
549c7297 1247 struct kstat *, u32, unsigned int);
c1632a0f 1248extern int afs_setattr(struct mnt_idmap *idmap, struct dentry *, struct iattr *);
b57922d9 1249extern void afs_evict_inode(struct inode *);
bec5eb61 1250extern int afs_drop_inode(struct inode *);
1da177e4
LT
1251
1252/*
1253 * main.c
1254 */
0ad53eee 1255extern struct workqueue_struct *afs_wq;
5b86d4ff 1256extern int afs_net_id;
f044c884 1257
5b86d4ff 1258static inline struct afs_net *afs_net(struct net *net)
f044c884 1259{
5b86d4ff 1260 return net_generic(net, afs_net_id);
f044c884
DH
1261}
1262
5b86d4ff 1263static inline struct afs_net *afs_sb2net(struct super_block *sb)
f044c884 1264{
5b86d4ff 1265 return afs_net(AFS_FS_S(sb)->net_ns);
f044c884
DH
1266}
1267
5b86d4ff 1268static inline struct afs_net *afs_d2net(struct dentry *dentry)
f044c884 1269{
5b86d4ff 1270 return afs_sb2net(dentry->d_sb);
f044c884
DH
1271}
1272
5b86d4ff 1273static inline struct afs_net *afs_i2net(struct inode *inode)
f044c884 1274{
5b86d4ff 1275 return afs_sb2net(inode->i_sb);
f044c884
DH
1276}
1277
5b86d4ff 1278static inline struct afs_net *afs_v2net(struct afs_vnode *vnode)
f044c884 1279{
874c8ca1 1280 return afs_i2net(&vnode->netfs.inode);
f044c884
DH
1281}
1282
5b86d4ff 1283static inline struct afs_net *afs_sock2net(struct sock *sk)
f044c884 1284{
5b86d4ff 1285 return net_generic(sock_net(sk), afs_net_id);
f044c884 1286}
1da177e4 1287
d55b4da4
DH
1288static inline void __afs_stat(atomic_t *s)
1289{
1290 atomic_inc(s);
1291}
1292
1293#define afs_stat_v(vnode, n) __afs_stat(&afs_v2net(vnode)->n)
1294
08e0e7c8
DH
1295/*
1296 * misc.c
1297 */
1298extern int afs_abort_to_error(u32);
4584ae96 1299extern void afs_prioritise_error(struct afs_error *, int, u32);
08e0e7c8 1300
2de5599f
DH
1301static inline void afs_op_nomem(struct afs_operation *op)
1302{
aa453bec 1303 op->cumul_error.error = -ENOMEM;
2de5599f
DH
1304}
1305
1306static inline int afs_op_error(const struct afs_operation *op)
1307{
aa453bec
DH
1308 return op->cumul_error.error;
1309}
1310
1311static inline s32 afs_op_abort_code(const struct afs_operation *op)
1312{
1313 return op->cumul_error.abort_code;
2de5599f
DH
1314}
1315
1316static inline int afs_op_set_error(struct afs_operation *op, int error)
1317{
aa453bec
DH
1318 return op->cumul_error.error = error;
1319}
1320
1321static inline void afs_op_accumulate_error(struct afs_operation *op, int error, s32 abort_code)
1322{
1323 afs_prioritise_error(&op->cumul_error, error, abort_code);
2de5599f
DH
1324}
1325
1da177e4
LT
1326/*
1327 * mntpt.c
1328 */
754661f1 1329extern const struct inode_operations afs_mntpt_inode_operations;
bec5eb61 1330extern const struct inode_operations afs_autocell_inode_operations;
4b6f5d20 1331extern const struct file_operations afs_mntpt_file_operations;
1da177e4 1332
d18610b0 1333extern struct vfsmount *afs_d_automount(struct path *);
08e0e7c8 1334extern void afs_mntpt_kill_timer(void);
1da177e4 1335
1da177e4
LT
1336/*
1337 * proc.c
1338 */
b6cfbeca 1339#ifdef CONFIG_PROC_FS
f044c884
DH
1340extern int __net_init afs_proc_init(struct afs_net *);
1341extern void __net_exit afs_proc_cleanup(struct afs_net *);
5b86d4ff
DH
1342extern int afs_proc_cell_setup(struct afs_cell *);
1343extern void afs_proc_cell_remove(struct afs_cell *);
6f8880d8 1344extern void afs_put_sysnames(struct afs_sysnames *);
b6cfbeca
DH
1345#else
1346static inline int afs_proc_init(struct afs_net *net) { return 0; }
1347static inline void afs_proc_cleanup(struct afs_net *net) {}
1348static inline int afs_proc_cell_setup(struct afs_cell *cell) { return 0; }
1349static inline void afs_proc_cell_remove(struct afs_cell *cell) {}
1350static inline void afs_put_sysnames(struct afs_sysnames *sysnames) {}
1351#endif
1da177e4 1352
d2ddc776
DH
1353/*
1354 * rotate.c
1355 */
495f2ae9 1356void afs_clear_server_states(struct afs_operation *op);
a310082f 1357extern bool afs_select_fileserver(struct afs_operation *);
e49c7b2f 1358extern void afs_dump_edestaddrreq(const struct afs_operation *);
d2ddc776 1359
08e0e7c8
DH
1360/*
1361 * rxrpc.c
1362 */
f044c884 1363extern struct workqueue_struct *afs_async_calls;
8324f0bc 1364
f044c884
DH
1365extern int __net_init afs_open_socket(struct afs_net *);
1366extern void __net_exit afs_close_socket(struct afs_net *);
1367extern void afs_charge_preallocation(struct work_struct *);
341f741f 1368extern void afs_put_call(struct afs_call *);
610a79ff 1369void afs_deferred_put_call(struct afs_call *call);
98f9fda2 1370void afs_make_call(struct afs_call *call, gfp_t gfp);
eddf51f2 1371void afs_deliver_to_call(struct afs_call *call);
98f9fda2 1372void afs_wait_for_call_to_complete(struct afs_call *call);
f044c884
DH
1373extern struct afs_call *afs_alloc_flat_call(struct afs_net *,
1374 const struct afs_call_type *,
08e0e7c8
DH
1375 size_t, size_t);
1376extern void afs_flat_call_destructor(struct afs_call *);
08e0e7c8 1377extern void afs_send_empty_reply(struct afs_call *);
b908fe6b 1378extern void afs_send_simple_reply(struct afs_call *, const void *, size_t);
12bdcf33 1379extern int afs_extract_data(struct afs_call *, bool);
7126ead9 1380extern int afs_protocol_error(struct afs_call *, enum afs_eproto_cause);
08e0e7c8 1381
eddf51f2
DH
1382static inline struct afs_call *afs_get_call(struct afs_call *call,
1383 enum afs_call_trace why)
1384{
1385 int r;
1386
1387 __refcount_inc(&call->ref, &r);
1388
1389 trace_afs_call(call->debug_id, why, r + 1,
1390 atomic_read(&call->net->nr_outstanding_calls),
1391 __builtin_return_address(0));
1392 return call;
1393}
1394
9750be93
DH
1395static inline void afs_see_call(struct afs_call *call, enum afs_call_trace why)
1396{
1397 int r = refcount_read(&call->ref);
1398
1399 trace_afs_call(call->debug_id, why, r,
1400 atomic_read(&call->net->nr_outstanding_calls),
1401 __builtin_return_address(0));
1402}
1403
e49c7b2f
DH
1404static inline void afs_make_op_call(struct afs_operation *op, struct afs_call *call,
1405 gfp_t gfp)
20b8391f 1406{
f49b594d
DH
1407 struct afs_addr_list *alist = op->estate->addresses;
1408
e38f299e
DH
1409 op->call = call;
1410 op->type = call->type;
1411 call->op = op;
1412 call->key = op->key;
1413 call->intr = !(op->flags & AFS_OPERATION_UNINTR);
f49b594d 1414 call->peer = rxrpc_kernel_get_peer(alist->addrs[op->addr_index].peer);
e38f299e 1415 call->service_id = op->server->service_id;
98f9fda2 1416 afs_make_call(call, gfp);
20b8391f
DH
1417}
1418
12bdcf33
DH
1419static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t size)
1420{
f105da1a 1421 call->iov_len = size;
12bdcf33
DH
1422 call->kvec[0].iov_base = buf;
1423 call->kvec[0].iov_len = size;
de4eda9d 1424 iov_iter_kvec(&call->def_iter, ITER_DEST, call->kvec, 1, size);
12bdcf33
DH
1425}
1426
1427static inline void afs_extract_to_tmp(struct afs_call *call)
1428{
f105da1a 1429 call->iov_len = sizeof(call->tmp);
12bdcf33
DH
1430 afs_extract_begin(call, &call->tmp, sizeof(call->tmp));
1431}
1432
1433static inline void afs_extract_to_tmp64(struct afs_call *call)
1434{
f105da1a 1435 call->iov_len = sizeof(call->tmp64);
12bdcf33
DH
1436 afs_extract_begin(call, &call->tmp64, sizeof(call->tmp64));
1437}
1438
1439static inline void afs_extract_discard(struct afs_call *call, size_t size)
1440{
f105da1a 1441 call->iov_len = size;
de4eda9d 1442 iov_iter_discard(&call->def_iter, ITER_DEST, size);
12bdcf33
DH
1443}
1444
1445static inline void afs_extract_to_buf(struct afs_call *call, size_t size)
1446{
f105da1a 1447 call->iov_len = size;
12bdcf33
DH
1448 afs_extract_begin(call, call->buffer, size);
1449}
1450
d001648e 1451static inline int afs_transfer_reply(struct afs_call *call)
372ee163 1452{
12bdcf33 1453 return afs_extract_data(call, false);
372ee163
DH
1454}
1455
98bf40cd
DH
1456static inline bool afs_check_call_state(struct afs_call *call,
1457 enum afs_call_state state)
1458{
1459 return READ_ONCE(call->state) == state;
1460}
1461
1462static inline bool afs_set_call_state(struct afs_call *call,
1463 enum afs_call_state from,
1464 enum afs_call_state to)
1465{
1466 bool ok = false;
1467
1468 spin_lock_bh(&call->state_lock);
1469 if (call->state == from) {
1470 call->state = to;
1471 trace_afs_call_state(call, from, to, 0, 0);
1472 ok = true;
1473 }
1474 spin_unlock_bh(&call->state_lock);
1475 return ok;
1476}
1477
1478static inline void afs_set_call_complete(struct afs_call *call,
1479 int error, u32 remote_abort)
1480{
1481 enum afs_call_state state;
1482 bool ok = false;
1483
1484 spin_lock_bh(&call->state_lock);
1485 state = call->state;
1486 if (state != AFS_CALL_COMPLETE) {
1487 call->abort_code = remote_abort;
1488 call->error = error;
1489 call->state = AFS_CALL_COMPLETE;
1490 trace_afs_call_state(call, state, AFS_CALL_COMPLETE,
1491 error, remote_abort);
1492 ok = true;
1493 }
1494 spin_unlock_bh(&call->state_lock);
dde9f095 1495 if (ok) {
98bf40cd 1496 trace_afs_call_done(call);
dde9f095
DH
1497
1498 /* Asynchronous calls have two refs to release - one from the alloc and
1499 * one queued with the work item - and we can't just deallocate the
1500 * call because the work item may be queued again.
1501 */
1502 if (call->drop_ref)
1503 afs_put_call(call);
1504 }
98bf40cd
DH
1505}
1506
00d3b7a4
DH
1507/*
1508 * security.c
1509 */
be080a6f 1510extern void afs_put_permits(struct afs_permits *);
00d3b7a4 1511extern void afs_clear_permits(struct afs_vnode *);
a58823ac
DH
1512extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int,
1513 struct afs_status_cb *);
00d3b7a4 1514extern struct key *afs_request_key(struct afs_cell *);
8b6a666a 1515extern struct key *afs_request_key_rcu(struct afs_cell *);
0fafdc9f 1516extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *);
4609e1f1 1517extern int afs_permission(struct mnt_idmap *, struct inode *, int);
be080a6f 1518extern void __exit afs_clean_up_permit_cache(void);
00d3b7a4 1519
08e0e7c8
DH
1520/*
1521 * server.c
1522 */
1523extern spinlock_t afs_server_peer_lock;
1524
40e8b52f 1525struct afs_server *afs_find_server(const struct rxrpc_peer *peer);
81006805 1526extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *, u32);
45218193 1527extern struct afs_server *afs_get_server(struct afs_server *, enum afs_server_trace);
4882ba78
DH
1528struct afs_server *afs_use_server(struct afs_server *server, bool activate,
1529 enum afs_server_trace reason);
1530void afs_unuse_server(struct afs_net *net, struct afs_server *server,
1531 enum afs_server_trace reason);
1532void afs_unuse_server_notime(struct afs_net *net, struct afs_server *server,
1533 enum afs_server_trace reason);
45218193 1534extern void afs_put_server(struct afs_net *, struct afs_server *, enum afs_server_trace);
4882ba78 1535void afs_purge_servers(struct afs_cell *cell);
f6cbb368 1536extern void afs_fs_probe_timer(struct timer_list *);
4882ba78 1537void __net_exit afs_wait_for_servers(struct afs_net *net);
f49b594d 1538bool afs_check_server_record(struct afs_operation *op, struct afs_server *server, struct key *key);
08e0e7c8 1539
4882ba78
DH
1540static inline void afs_see_server(struct afs_server *server, enum afs_server_trace trace)
1541{
1542 int r = refcount_read(&server->ref);
1543 int a = atomic_read(&server->active);
1544
1545 trace_afs_server(server->debug_id, r, a, trace);
1546
1547}
1548
f6cbb368
DH
1549static inline void afs_inc_servers_outstanding(struct afs_net *net)
1550{
1551 atomic_inc(&net->servers_outstanding);
1552}
1553
1554static inline void afs_dec_servers_outstanding(struct afs_net *net)
1555{
1556 if (atomic_dec_and_test(&net->servers_outstanding))
1557 wake_up_var(&net->servers_outstanding);
1558}
1559
1560static inline bool afs_is_probing_server(struct afs_server *server)
1561{
1562 return list_empty(&server->probe_link);
1563}
1564
00d3b7a4 1565/*
d2ddc776 1566 * server_list.c
00d3b7a4 1567 */
d2ddc776
DH
1568static inline struct afs_server_list *afs_get_serverlist(struct afs_server_list *slist)
1569{
1570 refcount_inc(&slist->usage);
1571 return slist;
1572}
00d3b7a4 1573
d2ddc776 1574extern void afs_put_serverlist(struct afs_net *, struct afs_server_list *);
ca0e79a4
DH
1575struct afs_server_list *afs_alloc_server_list(struct afs_volume *volume,
1576 struct key *key,
1577 struct afs_vldb_entry *vldb);
d2ddc776 1578extern bool afs_annotate_server_list(struct afs_server_list *, struct afs_server_list *);
ca0e79a4
DH
1579void afs_attach_volume_to_servers(struct afs_volume *volume, struct afs_server_list *slist);
1580void afs_reattach_volume_to_servers(struct afs_volume *volume, struct afs_server_list *slist,
1581 struct afs_server_list *old);
1582void afs_detach_volume_from_servers(struct afs_volume *volume, struct afs_server_list *slist);
08e0e7c8
DH
1583
1584/*
d2ddc776 1585 * super.c
08e0e7c8 1586 */
d2ddc776 1587extern int __init afs_fs_init(void);
5b86d4ff 1588extern void afs_fs_exit(void);
08e0e7c8 1589
dfa0a449
DH
1590/*
1591 * validation.c
1592 */
453924de 1593bool afs_check_validity(const struct afs_vnode *vnode);
16069e13 1594int afs_update_volume_state(struct afs_operation *op);
dfa0a449
DH
1595int afs_validate(struct afs_vnode *vnode, struct key *key);
1596
08e0e7c8 1597/*
d2ddc776 1598 * vlclient.c
08e0e7c8 1599 */
0a5143f2
DH
1600extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *,
1601 const char *, int);
1602extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *, const uuid_t *);
98f9fda2
DH
1603struct afs_call *afs_vl_get_capabilities(struct afs_net *net,
1604 struct afs_addr_list *alist,
1605 unsigned int addr_index,
1606 struct key *key,
1607 struct afs_vlserver *server,
1608 unsigned int server_index);
0a5143f2 1609extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *, const uuid_t *);
c3e9f888 1610extern char *afs_yfsvl_get_cell_name(struct afs_vl_cursor *);
0a5143f2 1611
8a070a96
DH
1612/*
1613 * vl_alias.c
1614 */
1615extern int afs_cell_detect_alias(struct afs_cell *, struct key *);
1616
3bf0fb6f
DH
1617/*
1618 * vl_probe.c
1619 */
1620extern void afs_vlserver_probe_result(struct afs_call *);
1621extern int afs_send_vl_probes(struct afs_net *, struct key *, struct afs_vlserver_list *);
1622extern int afs_wait_for_vl_probes(struct afs_vlserver_list *, unsigned long);
1623
0a5143f2
DH
1624/*
1625 * vl_rotate.c
1626 */
1627extern bool afs_begin_vlserver_operation(struct afs_vl_cursor *,
1628 struct afs_cell *, struct key *);
1629extern bool afs_select_vlserver(struct afs_vl_cursor *);
1630extern bool afs_select_current_vlserver(struct afs_vl_cursor *);
1631extern int afs_end_vlserver_operation(struct afs_vl_cursor *);
1632
1633/*
1634 * vlserver_list.c
1635 */
1636static inline struct afs_vlserver *afs_get_vlserver(struct afs_vlserver *vlserver)
1637{
c56f9ec8 1638 refcount_inc(&vlserver->ref);
0a5143f2
DH
1639 return vlserver;
1640}
1641
1642static inline struct afs_vlserver_list *afs_get_vlserverlist(struct afs_vlserver_list *vllist)
1643{
1644 if (vllist)
c56f9ec8 1645 refcount_inc(&vllist->ref);
0a5143f2
DH
1646 return vllist;
1647}
1648
1649extern struct afs_vlserver *afs_alloc_vlserver(const char *, size_t, unsigned short);
1650extern void afs_put_vlserver(struct afs_net *, struct afs_vlserver *);
1651extern struct afs_vlserver_list *afs_alloc_vlserver_list(unsigned int);
1652extern void afs_put_vlserverlist(struct afs_net *, struct afs_vlserver_list *);
1653extern struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *,
1654 const void *, size_t);
08e0e7c8
DH
1655
1656/*
1657 * volume.c
1658 */
13fcc683 1659extern struct afs_volume *afs_create_volume(struct afs_fs_context *);
523d27cd 1660extern int afs_activate_volume(struct afs_volume *);
d2ddc776 1661extern void afs_deactivate_volume(struct afs_volume *);
9a6b294a 1662bool afs_try_get_volume(struct afs_volume *volume, enum afs_volume_trace reason);
cca37d45 1663extern struct afs_volume *afs_get_volume(struct afs_volume *, enum afs_volume_trace);
445f9b69 1664void afs_put_volume(struct afs_volume *volume, enum afs_volume_trace reason);
a310082f 1665extern int afs_check_volume_status(struct afs_volume *, struct afs_operation *);
08e0e7c8 1666
31143d5d
DH
1667/*
1668 * write.c
1669 */
ed22e1db
DH
1670void afs_prepare_write(struct netfs_io_subrequest *subreq);
1671void afs_issue_write(struct netfs_io_subrequest *subreq);
1672void afs_begin_writeback(struct netfs_io_request *wreq);
1ecb146f 1673void afs_retry_request(struct netfs_io_request *wreq, struct netfs_io_stream *stream);
31143d5d 1674extern int afs_writepages(struct address_space *, struct writeback_control *);
02c24a82 1675extern int afs_fsync(struct file *, loff_t, loff_t, int);
0722f186 1676extern vm_fault_t afs_page_mkwrite(struct vm_fault *vmf);
4343d008 1677extern void afs_prune_wb_keys(struct afs_vnode *);
31143d5d 1678
d3e3b7ea
DH
1679/*
1680 * xattr.c
1681 */
f710c2e4 1682extern const struct xattr_handler * const afs_xattr_handlers[];
31143d5d 1683
30062bd1
DH
1684/*
1685 * yfsclient.c
1686 */
e49c7b2f
DH
1687extern void yfs_fs_fetch_data(struct afs_operation *);
1688extern void yfs_fs_create_file(struct afs_operation *);
1689extern void yfs_fs_make_dir(struct afs_operation *);
1690extern void yfs_fs_remove_file2(struct afs_operation *);
1691extern void yfs_fs_remove_file(struct afs_operation *);
1692extern void yfs_fs_remove_dir(struct afs_operation *);
1693extern void yfs_fs_link(struct afs_operation *);
1694extern void yfs_fs_symlink(struct afs_operation *);
1695extern void yfs_fs_rename(struct afs_operation *);
1696extern void yfs_fs_store_data(struct afs_operation *);
1697extern void yfs_fs_setattr(struct afs_operation *);
1698extern void yfs_fs_get_volume_status(struct afs_operation *);
1699extern void yfs_fs_set_lock(struct afs_operation *);
1700extern void yfs_fs_extend_lock(struct afs_operation *);
1701extern void yfs_fs_release_lock(struct afs_operation *);
1702extern void yfs_fs_fetch_status(struct afs_operation *);
1703extern void yfs_fs_inline_bulk_status(struct afs_operation *);
d2ddc776 1704
ae46578b
DH
1705struct yfs_acl {
1706 struct afs_acl *acl; /* Dir/file/symlink ACL */
1707 struct afs_acl *vol_acl; /* Whole volume ACL */
1708 u32 inherit_flag; /* True if ACL is inherited from parent dir */
1709 u32 num_cleaned; /* Number of ACEs removed due to subject removal */
1710 unsigned int flags;
1711#define YFS_ACL_WANT_ACL 0x01 /* Set if caller wants ->acl */
1712#define YFS_ACL_WANT_VOL_ACL 0x02 /* Set if caller wants ->vol_acl */
1713};
1714
1715extern void yfs_free_opaque_acl(struct yfs_acl *);
e49c7b2f
DH
1716extern void yfs_fs_fetch_opaque_acl(struct afs_operation *);
1717extern void yfs_fs_store_opaque_acl2(struct afs_operation *);
ae46578b 1718
d2ddc776
DH
1719/*
1720 * Miscellaneous inline functions.
1721 */
1722static inline struct afs_vnode *AFS_FS_I(struct inode *inode)
1723{
874c8ca1 1724 return container_of(inode, struct afs_vnode, netfs.inode);
d2ddc776
DH
1725}
1726
1727static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode)
1728{
874c8ca1 1729 return &vnode->netfs.inode;
d2ddc776
DH
1730}
1731
e49c7b2f
DH
1732/*
1733 * Note that a dentry got changed. We need to set d_fsdata to the data version
1734 * number derived from the result of the operation. It doesn't matter if
1735 * d_fsdata goes backwards as we'll just revalidate.
1736 */
1737static inline void afs_update_dentry_version(struct afs_operation *op,
1738 struct afs_vnode_param *dir_vp,
1739 struct dentry *dentry)
1740{
aa453bec 1741 if (!op->cumul_error.error)
e49c7b2f
DH
1742 dentry->d_fsdata =
1743 (void *)(unsigned long)dir_vp->scb.status.data_version;
1744}
1745
9d37e1ca
DH
1746/*
1747 * Set the file size and block count. Estimate the number of 512 bytes blocks
1748 * used, rounded up to nearest 1K for consistency with other AFS clients.
1749 */
1750static inline void afs_set_i_size(struct afs_vnode *vnode, u64 size)
1751{
874c8ca1
DH
1752 i_size_write(&vnode->netfs.inode, size);
1753 vnode->netfs.inode.i_blocks = ((size + 1023) >> 10) << 1;
9d37e1ca
DH
1754}
1755
b6489a49
DH
1756/*
1757 * Check for a conflicting operation on a directory that we just unlinked from.
1758 * If someone managed to sneak a link or an unlink in on the file we just
1759 * unlinked, we won't be able to trust nlink on an AFS file (but not YFS).
1760 */
1761static inline void afs_check_dir_conflict(struct afs_operation *op,
1762 struct afs_vnode_param *dvp)
1763{
1764 if (dvp->dv_before + dvp->dv_delta != dvp->scb.status.data_version)
1765 op->flags |= AFS_OPERATION_DIR_CONFLICT;
1766}
1767
f51375cd
DH
1768static inline int afs_io_error(struct afs_call *call, enum afs_io_error where)
1769{
1770 trace_afs_io_error(call->debug_id, -EIO, where);
1771 return -EIO;
1772}
1773
1774static inline int afs_bad(struct afs_vnode *vnode, enum afs_file_error where)
1775{
1776 trace_afs_file_error(vnode, -EIO, where);
1777 return -EIO;
1778}
d2ddc776 1779
9e705016
DH
1780/*
1781 * Set the callback promise on a vnode.
1782 */
1783static inline void afs_set_cb_promise(struct afs_vnode *vnode, time64_t expires_at,
1784 enum afs_cb_promise_trace trace)
1785{
1786 atomic64_set(&vnode->cb_expires_at, expires_at);
1787 trace_afs_cb_promise(vnode, trace);
1788}
1789
1790/*
1791 * Clear the callback promise on a vnode, returning true if it was promised.
1792 */
1793static inline bool afs_clear_cb_promise(struct afs_vnode *vnode,
1794 enum afs_cb_promise_trace trace)
1795{
1796 trace_afs_cb_promise(vnode, trace);
1797 return atomic64_xchg(&vnode->cb_expires_at, AFS_NO_CB_PROMISE) != AFS_NO_CB_PROMISE;
1798}
1799
1800/*
1801 * Mark a directory as being invalid.
1802 */
1803static inline void afs_invalidate_dir(struct afs_vnode *dvnode,
1804 enum afs_dir_invalid_trace trace)
1805{
1806 if (test_and_clear_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) {
1807 trace_afs_dir_invalid(dvnode, trace);
1808 afs_stat_v(dvnode, n_inval);
1809 }
1810}
1811
08e0e7c8
DH
1812/*****************************************************************************/
1813/*
1814 * debug tracing
1815 */
1816extern unsigned afs_debug;
1817
1818#define dbgprintk(FMT,...) \
ad16df84 1819 printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
08e0e7c8 1820
530b6412
HH
1821#define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
1822#define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
08e0e7c8
DH
1823#define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__)
1824
1825
1826#if defined(__KDEBUG)
1827#define _enter(FMT,...) kenter(FMT,##__VA_ARGS__)
1828#define _leave(FMT,...) kleave(FMT,##__VA_ARGS__)
1829#define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__)
1830
1831#elif defined(CONFIG_AFS_DEBUG)
1832#define AFS_DEBUG_KENTER 0x01
1833#define AFS_DEBUG_KLEAVE 0x02
1834#define AFS_DEBUG_KDEBUG 0x04
1835
1836#define _enter(FMT,...) \
1837do { \
1838 if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \
1839 kenter(FMT,##__VA_ARGS__); \
1840} while (0)
1841
1842#define _leave(FMT,...) \
1843do { \
1844 if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \
1845 kleave(FMT,##__VA_ARGS__); \
1846} while (0)
1847
1848#define _debug(FMT,...) \
1849do { \
1850 if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \
1851 kdebug(FMT,##__VA_ARGS__); \
1852} while (0)
1853
1854#else
12fdff3f
DH
1855#define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
1856#define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
1857#define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__)
08e0e7c8
DH
1858#endif
1859
1860/*
1861 * debug assertion checking
1862 */
1863#if 1 // defined(__KDEBUGALL)
1864
1865#define ASSERT(X) \
1866do { \
1867 if (unlikely(!(X))) { \
1868 printk(KERN_ERR "\n"); \
1869 printk(KERN_ERR "AFS: Assertion failed\n"); \
1870 BUG(); \
1871 } \
1872} while(0)
1873
1874#define ASSERTCMP(X, OP, Y) \
1875do { \
1876 if (unlikely(!((X) OP (Y)))) { \
1877 printk(KERN_ERR "\n"); \
1878 printk(KERN_ERR "AFS: Assertion failed\n"); \
1879 printk(KERN_ERR "%lu " #OP " %lu is false\n", \
1880 (unsigned long)(X), (unsigned long)(Y)); \
1881 printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
1882 (unsigned long)(X), (unsigned long)(Y)); \
1883 BUG(); \
1884 } \
1885} while(0)
1886
416351f2
DH
1887#define ASSERTRANGE(L, OP1, N, OP2, H) \
1888do { \
1889 if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \
1890 printk(KERN_ERR "\n"); \
1891 printk(KERN_ERR "AFS: Assertion failed\n"); \
1892 printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \
1893 (unsigned long)(L), (unsigned long)(N), \
1894 (unsigned long)(H)); \
1895 printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \
1896 (unsigned long)(L), (unsigned long)(N), \
1897 (unsigned long)(H)); \
1898 BUG(); \
1899 } \
1900} while(0)
1901
08e0e7c8
DH
1902#define ASSERTIF(C, X) \
1903do { \
1904 if (unlikely((C) && !(X))) { \
1905 printk(KERN_ERR "\n"); \
1906 printk(KERN_ERR "AFS: Assertion failed\n"); \
1907 BUG(); \
1908 } \
1909} while(0)
1910
1911#define ASSERTIFCMP(C, X, OP, Y) \
1912do { \
1913 if (unlikely((C) && !((X) OP (Y)))) { \
1914 printk(KERN_ERR "\n"); \
1915 printk(KERN_ERR "AFS: Assertion failed\n"); \
1916 printk(KERN_ERR "%lu " #OP " %lu is false\n", \
1917 (unsigned long)(X), (unsigned long)(Y)); \
1918 printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
1919 (unsigned long)(X), (unsigned long)(Y)); \
1920 BUG(); \
1921 } \
1922} while(0)
1923
1924#else
1925
1926#define ASSERT(X) \
1927do { \
1928} while(0)
1929
1930#define ASSERTCMP(X, OP, Y) \
1931do { \
1932} while(0)
1933
416351f2
DH
1934#define ASSERTRANGE(L, OP1, N, OP2, H) \
1935do { \
1936} while(0)
1937
08e0e7c8
DH
1938#define ASSERTIF(C, X) \
1939do { \
1940} while(0)
1941
1942#define ASSERTIFCMP(C, X, OP, Y) \
1943do { \
1944} while(0)
1945
1946#endif /* __KDEBUGALL */