3 * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
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.
12 #include <linux/compiler.h>
13 #include <linux/kernel.h>
14 #include <linux/ktime.h>
16 #include <linux/pagemap.h>
17 #include <linux/rxrpc.h>
18 #include <linux/key.h>
19 #include <linux/workqueue.h>
20 #include <linux/sched.h>
21 #include <linux/fscache.h>
22 #include <linux/backing-dev.h>
23 #include <linux/uuid.h>
24 #include <linux/mm_types.h>
25 #include <linux/dns_resolver.h>
26 #include <net/net_namespace.h>
27 #include <net/netns/generic.h>
29 #include <net/af_rxrpc.h>
34 #define AFS_CELL_MAX_ADDRS 15
39 struct afs_mount_params {
40 bool rwpath; /* T if the parent should be considered R/W */
41 bool force; /* T to force cell type */
42 bool autocell; /* T if set auto mount operation */
43 bool dyn_root; /* T if dynamic root */
44 afs_voltype_t type; /* type of volume requested */
45 int volnamesz; /* size of volume name */
46 const char *volname; /* name of volume to mount */
47 struct net *net_ns; /* Network namespace in effect */
48 struct afs_net *net; /* the AFS net namespace stuff */
49 struct afs_cell *cell; /* cell in which to find volume */
50 struct afs_volume *volume; /* volume record */
51 struct key *key; /* key to use for secure mounting */
54 struct afs_iget_data {
56 struct afs_volume *volume; /* volume on which resides */
60 AFS_CALL_CL_REQUESTING, /* Client: Request is being sent */
61 AFS_CALL_CL_AWAIT_REPLY, /* Client: Awaiting reply */
62 AFS_CALL_CL_PROC_REPLY, /* Client: rxrpc call complete; processing reply */
63 AFS_CALL_SV_AWAIT_OP_ID, /* Server: Awaiting op ID */
64 AFS_CALL_SV_AWAIT_REQUEST, /* Server: Awaiting request data */
65 AFS_CALL_SV_REPLYING, /* Server: Replying */
66 AFS_CALL_SV_AWAIT_ACK, /* Server: Awaiting final ACK */
67 AFS_CALL_COMPLETE, /* Completed or failed */
71 * List of server addresses.
73 struct afs_addr_list {
74 struct rcu_head rcu; /* Must be first */
76 u32 version; /* Version */
77 unsigned char max_addrs;
78 unsigned char nr_addrs;
79 unsigned char index; /* Address currently in use */
80 unsigned char nr_ipv4; /* Number of IPv4 addresses */
81 enum dns_record_source source:8;
82 enum dns_lookup_status status:8;
83 unsigned long probed; /* Mask of servers that have been probed */
84 unsigned long yfs; /* Mask of servers that are YFS */
85 struct sockaddr_rxrpc addrs[];
86 #define AFS_MAX_ADDRESSES ((unsigned int)(sizeof(unsigned long) * 8))
90 * a record of an in-progress RxRPC call
93 const struct afs_call_type *type; /* type of call */
94 wait_queue_head_t waitq; /* processes awaiting completion */
95 struct work_struct async_work; /* async I/O processor */
96 struct work_struct work; /* actual work processor */
97 struct rxrpc_call *rxcall; /* RxRPC call handle */
98 struct key *key; /* security for this call */
99 struct afs_net *net; /* The network namespace */
100 struct afs_server *cm_server; /* Server affected by incoming CM call */
101 struct afs_cb_interest *cbi; /* Callback interest for server used */
102 void *request; /* request data (first part) */
103 struct address_space *mapping; /* Pages being written from */
104 struct iov_iter iter; /* Buffer iterator */
105 struct iov_iter *_iter; /* Iterator currently in use */
106 union { /* Convenience for ->iter */
108 struct bio_vec bvec[1];
110 void *buffer; /* reply receive buffer */
111 void *reply[4]; /* Where to put the reply */
112 pgoff_t first; /* first page in mapping to deal with */
113 pgoff_t last; /* last page in mapping to deal with */
115 enum afs_call_state state;
116 spinlock_t state_lock;
117 int error; /* error code */
118 u32 abort_code; /* Remote abort ID or 0 */
119 unsigned request_size; /* size of request data */
120 unsigned reply_max; /* maximum size of reply */
121 unsigned first_offset; /* offset into mapping[first] */
122 unsigned int cb_break; /* cb_break + cb_s_break before the call */
124 unsigned last_to; /* amount of mapping[last] */
125 unsigned count2; /* count used in unmarshalling */
127 unsigned char unmarshall; /* unmarshalling phase */
128 bool incoming; /* T if incoming call */
129 bool send_pages; /* T if data from mapping should be sent */
130 bool need_attention; /* T if RxRPC poked us */
131 bool async; /* T if asynchronous */
132 bool ret_reply0; /* T if should return reply[0] on success */
133 bool upgrade; /* T to request service upgrade */
134 u16 service_id; /* Actual service ID (after upgrade) */
135 unsigned int debug_id; /* Trace ID */
136 u32 operation_ID; /* operation ID for an incoming call */
137 u32 count; /* count for use in unmarshalling */
138 union { /* place to extract temporary data */
142 } __attribute__((packed));
145 afs_dataversion_t expected_version; /* Updated version expected from store */
146 afs_dataversion_t expected_version_2; /* 2nd updated version expected from store */
149 struct afs_call_type {
151 unsigned int op; /* Really enum afs_fs_operation */
153 /* deliver request or reply data to an call
154 * - returning an error will cause the call to be aborted
156 int (*deliver)(struct afs_call *call);
158 /* clean up a call */
159 void (*destructor)(struct afs_call *call);
162 void (*work)(struct work_struct *work);
166 * Key available for writeback on a file.
171 struct list_head vnode_link; /* Link in vnode->wb_keys */
175 * AFS open file information record. Pointed to by file->private_data.
178 struct key *key; /* The key this file was opened with */
179 struct afs_wb_key *wb; /* Writeback key record for this file */
182 static inline struct key *afs_file_key(struct file *file)
184 struct afs_file *af = file->private_data;
190 * Record of an outstanding read operation on a vnode.
193 loff_t pos; /* Where to start reading */
194 loff_t len; /* How much we're asking for */
195 loff_t actual_len; /* How much we're actually getting */
196 loff_t remain; /* Amount remaining */
197 loff_t file_size; /* File size returned by server */
198 afs_dataversion_t data_version; /* Version number returned by server */
200 unsigned int index; /* Which page we're reading into */
201 unsigned int nr_pages;
202 unsigned int offset; /* offset into current page */
203 void (*page_done)(struct afs_call *, struct afs_read *);
205 struct page *array[];
209 * AFS superblock private data
210 * - there's one superblock per volume
212 struct afs_super_info {
213 struct net *net_ns; /* Network namespace */
214 struct afs_cell *cell; /* The cell in which the volume resides */
215 struct afs_volume *volume; /* volume record */
216 bool dyn_root; /* True if dynamic root */
219 static inline struct afs_super_info *AFS_FS_S(struct super_block *sb)
221 return sb->s_fs_info;
224 extern struct file_system_type afs_fs_type;
227 * Set of substitutes for @sys.
229 struct afs_sysnames {
230 #define AFS_NR_SYSNAME 16
231 char *subs[AFS_NR_SYSNAME];
238 * AFS network namespace record.
241 struct net *net; /* Backpointer to the owning net namespace */
242 struct afs_uuid uuid;
243 bool live; /* F if this namespace is being removed */
245 /* AF_RXRPC I/O stuff */
246 struct socket *socket;
247 struct afs_call *spare_incoming_call;
248 struct work_struct charge_preallocation_work;
249 struct mutex socket_mutex;
250 atomic_t nr_outstanding_calls;
251 atomic_t nr_superblocks;
254 struct rb_root cells;
255 struct afs_cell __rcu *ws_cell;
256 struct work_struct cells_manager;
257 struct timer_list cells_timer;
258 atomic_t cells_outstanding;
259 seqlock_t cells_lock;
261 struct mutex proc_cells_lock;
262 struct hlist_head proc_cells;
264 /* Known servers. Theoretically each fileserver can only be in one
265 * cell, but in practice, people create aliases and subsets and there's
266 * no easy way to distinguish them.
268 seqlock_t fs_lock; /* For fs_servers */
269 struct rb_root fs_servers; /* afs_server (by server UUID or address) */
270 struct list_head fs_updates; /* afs_server (by update_at) */
271 struct hlist_head fs_proc; /* procfs servers list */
273 struct hlist_head fs_addresses4; /* afs_server (by lowest IPv4 addr) */
274 struct hlist_head fs_addresses6; /* afs_server (by lowest IPv6 addr) */
275 seqlock_t fs_addr_lock; /* For fs_addresses[46] */
277 struct work_struct fs_manager;
278 struct timer_list fs_timer;
279 atomic_t servers_outstanding;
281 /* File locking renewal management */
282 struct mutex lock_manager_mutex;
285 struct super_block *dynroot_sb; /* Dynamic root mount superblock */
286 struct proc_dir_entry *proc_afs; /* /proc/net/afs directory */
287 struct afs_sysnames *sysnames;
288 rwlock_t sysnames_lock;
290 /* Statistics counters */
291 atomic_t n_lookup; /* Number of lookups done */
292 atomic_t n_reval; /* Number of dentries needing revalidation */
293 atomic_t n_inval; /* Number of invalidations by the server */
294 atomic_t n_relpg; /* Number of invalidations by releasepage */
295 atomic_t n_read_dir; /* Number of directory pages read */
296 atomic_t n_dir_cr; /* Number of directory entry creation edits */
297 atomic_t n_dir_rm; /* Number of directory entry removal edits */
298 atomic_t n_stores; /* Number of store ops */
299 atomic_long_t n_store_bytes; /* Number of bytes stored */
300 atomic_long_t n_fetch_bytes; /* Number of bytes fetched */
301 atomic_t n_fetches; /* Number of data fetch ops */
304 extern const char afs_init_sysname[];
306 enum afs_cell_state {
310 AFS_CELL_DEACTIVATING,
318 * This is a tricky concept to get right as it is possible to create aliases
319 * simply by pointing AFSDB/SRV records for two names at the same set of VL
320 * servers; it is also possible to do things like setting up two sets of VL
321 * servers, one of which provides a superset of the volumes provided by the
322 * other (for internal/external division, for example).
324 * Cells only exist in the sense that (a) a cell's name maps to a set of VL
325 * servers and (b) a cell's name is used by the client to select the key to use
326 * for authentication and encryption. The cell name is not typically used in
329 * There is no easy way to determine if two cells are aliases or one is a
335 struct rb_node net_node; /* Node in net->cells */
338 struct key *anonymous_key; /* anonymous user key for this cell */
339 struct work_struct manager; /* Manager for init/deinit/dns */
340 struct hlist_node proc_link; /* /proc cell list link */
341 #ifdef CONFIG_AFS_FSCACHE
342 struct fscache_cookie *cache; /* caching cookie */
344 time64_t dns_expiry; /* Time AFSDB/SRV record expires */
345 time64_t last_inactive; /* Time of last drop of usage count */
348 #define AFS_CELL_FL_NOT_READY 0 /* The cell record is not ready for use */
349 #define AFS_CELL_FL_NO_GC 1 /* The cell was added manually, don't auto-gc */
350 #define AFS_CELL_FL_NOT_FOUND 2 /* Permanent DNS error */
351 #define AFS_CELL_FL_DNS_FAIL 3 /* Failed to access DNS */
352 #define AFS_CELL_FL_NO_LOOKUP_YET 4 /* Not completed first DNS lookup yet */
353 enum afs_cell_state state;
356 /* Active fileserver interaction state. */
357 struct list_head proc_volumes; /* procfs volume list */
360 /* VL server list. */
361 rwlock_t vl_servers_lock; /* Lock on vl_servers */
362 struct afs_vlserver_list __rcu *vl_servers;
364 u8 name_len; /* Length of name */
365 char name[64 + 1]; /* Cell name, case-flattened and NUL-padded */
369 * Volume Location server record.
371 struct afs_vlserver {
373 struct afs_addr_list __rcu *addresses; /* List of addresses for this VL server */
375 #define AFS_VLSERVER_FL_PROBED 0 /* The VL server has been probed */
376 #define AFS_VLSERVER_FL_PROBING 1 /* VL server is being probed */
377 rwlock_t lock; /* Lock on addresses */
379 u16 name_len; /* Length of name */
381 char name[]; /* Server name, case-flattened */
385 * Weighted list of Volume Location servers.
387 struct afs_vlserver_entry {
388 u16 priority; /* Preference (as SRV) */
389 u16 weight; /* Weight (as SRV) */
390 enum dns_record_source source:8;
391 enum dns_lookup_status status:8;
392 struct afs_vlserver *server;
395 struct afs_vlserver_list {
399 u8 index; /* Server currently in use */
400 enum dns_record_source source:8;
401 enum dns_lookup_status status:8;
403 struct afs_vlserver_entry servers[];
409 * This is pointed to by cell->vldb_entries, indexed by name.
411 struct afs_vldb_entry {
412 afs_volid_t vid[3]; /* Volume IDs for R/W, R/O and Bak volumes */
415 #define AFS_VLDB_HAS_RW 0 /* - R/W volume exists */
416 #define AFS_VLDB_HAS_RO 1 /* - R/O volume exists */
417 #define AFS_VLDB_HAS_BAK 2 /* - Backup volume exists */
418 #define AFS_VLDB_QUERY_VALID 3 /* - Record is valid */
419 #define AFS_VLDB_QUERY_ERROR 4 /* - VL server returned error */
421 uuid_t fs_server[AFS_NMAXNSERVERS];
422 u8 fs_mask[AFS_NMAXNSERVERS];
423 #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */
424 #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */
425 #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */
427 u8 nr_servers; /* Number of server records */
429 u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */
433 * Record of fileserver with which we're actively communicating.
438 uuid_t uuid; /* Server ID */
439 struct afs_uuid _uuid;
442 struct afs_addr_list __rcu *addresses;
443 struct rb_node uuid_rb; /* Link in net->servers */
444 struct hlist_node addr4_link; /* Link in net->fs_addresses4 */
445 struct hlist_node addr6_link; /* Link in net->fs_addresses6 */
446 struct hlist_node proc_link; /* Link in net->fs_proc */
447 struct afs_server *gc_next; /* Next server in manager's list */
448 time64_t put_time; /* Time at which last put */
449 time64_t update_at; /* Time at which to next update the record */
451 #define AFS_SERVER_FL_NEW 0 /* New server, don't inc cb_s_break */
452 #define AFS_SERVER_FL_NOT_READY 1 /* The record is not ready for use */
453 #define AFS_SERVER_FL_NOT_FOUND 2 /* VL server says no such server */
454 #define AFS_SERVER_FL_VL_FAIL 3 /* Failed to access VL server */
455 #define AFS_SERVER_FL_UPDATING 4
456 #define AFS_SERVER_FL_PROBED 5 /* The fileserver has been probed */
457 #define AFS_SERVER_FL_PROBING 6 /* Fileserver is being probed */
458 #define AFS_SERVER_FL_NO_IBULK 7 /* Fileserver doesn't support FS.InlineBulkStatus */
459 #define AFS_SERVER_FL_MAY_HAVE_CB 8 /* May have callbacks on this fileserver */
461 u32 addr_version; /* Address list version */
463 /* file service access */
464 rwlock_t fs_lock; /* access lock */
466 /* callback promise management */
467 struct hlist_head cb_volumes; /* List of volume interests on this server */
468 unsigned cb_s_break; /* Break-everything counter. */
469 rwlock_t cb_break_lock; /* Volume finding lock */
473 * Volume collation in the server's callback interest list.
475 struct afs_vol_interest {
476 struct hlist_node srv_link; /* Link in server->cb_volumes */
477 struct hlist_head cb_interests; /* List of callback interests on the server */
478 afs_volid_t vid; /* Volume ID to match */
483 * Interest by a superblock on a server.
485 struct afs_cb_interest {
486 struct hlist_node cb_vlink; /* Link in vol_interest->cb_interests */
487 struct afs_vol_interest *vol_interest;
488 struct afs_server *server; /* Server on which this interest resides */
489 struct super_block *sb; /* Superblock on which inodes reside */
490 afs_volid_t vid; /* Volume ID to match */
495 * Replaceable server list.
497 struct afs_server_entry {
498 struct afs_server *server;
499 struct afs_cb_interest *cb_interest;
502 struct afs_server_list {
504 unsigned short nr_servers;
505 unsigned short index; /* Server currently in use */
506 unsigned short vnovol_mask; /* Servers to be skipped due to VNOVOL */
507 unsigned int seq; /* Set to ->servers_seq when installed */
509 struct afs_server_entry servers[];
513 * Live AFS volume management.
516 afs_volid_t vid; /* volume ID */
518 time64_t update_at; /* Time at which to next update */
519 struct afs_cell *cell; /* Cell to which belongs (pins ref) */
520 struct list_head proc_link; /* Link in cell->vl_proc */
522 #define AFS_VOLUME_NEEDS_UPDATE 0 /* - T if an update needs performing */
523 #define AFS_VOLUME_UPDATING 1 /* - T if an update is in progress */
524 #define AFS_VOLUME_WAIT 2 /* - T if users must wait for update */
525 #define AFS_VOLUME_DELETED 3 /* - T if volume appears deleted */
526 #define AFS_VOLUME_OFFLINE 4 /* - T if volume offline notice given */
527 #define AFS_VOLUME_BUSY 5 /* - T if volume busy notice given */
528 #ifdef CONFIG_AFS_FSCACHE
529 struct fscache_cookie *cache; /* caching cookie */
531 struct afs_server_list *servers; /* List of servers on which volume resides */
532 rwlock_t servers_lock; /* Lock for ->servers */
533 unsigned int servers_seq; /* Incremented each time ->servers changes */
535 unsigned cb_v_break; /* Break-everything counter. */
536 rwlock_t cb_break_lock;
538 afs_voltype_t type; /* type of volume */
540 char type_force; /* force volume type (suppress R/O -> R/W) */
542 u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */
545 enum afs_lock_state {
546 AFS_VNODE_LOCK_NONE, /* The vnode has no lock on the server */
547 AFS_VNODE_LOCK_WAITING_FOR_CB, /* We're waiting for the server to break the callback */
548 AFS_VNODE_LOCK_SETTING, /* We're asking the server for a lock */
549 AFS_VNODE_LOCK_GRANTED, /* We have a lock on the server */
550 AFS_VNODE_LOCK_EXTENDING, /* We're extending a lock on the server */
551 AFS_VNODE_LOCK_NEED_UNLOCK, /* We need to unlock on the server */
552 AFS_VNODE_LOCK_UNLOCKING, /* We're telling the server to unlock */
556 * AFS inode private data.
558 * Note that afs_alloc_inode() *must* reset anything that could incorrectly
559 * leak from one inode to another.
562 struct inode vfs_inode; /* the VFS's inode record */
564 struct afs_volume *volume; /* volume on which vnode resides */
565 struct afs_fid fid; /* the file identifier for this inode */
566 struct afs_file_status status; /* AFS status info for this file */
567 afs_dataversion_t invalid_before; /* Child dentries are invalid before this */
568 #ifdef CONFIG_AFS_FSCACHE
569 struct fscache_cookie *cache; /* caching cookie */
571 struct afs_permits __rcu *permit_cache; /* cache of permits so far obtained */
572 struct mutex io_lock; /* Lock for serialising I/O on this mutex */
573 struct rw_semaphore validate_lock; /* lock for validating this vnode */
574 spinlock_t wb_lock; /* lock for wb_keys */
575 spinlock_t lock; /* waitqueue/flags lock */
577 #define AFS_VNODE_CB_PROMISED 0 /* Set if vnode has a callback promise */
578 #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */
579 #define AFS_VNODE_DIR_VALID 2 /* Set if dir contents are valid */
580 #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */
581 #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */
582 #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */
583 #define AFS_VNODE_AUTOCELL 6 /* set if Vnode is an auto mount point */
584 #define AFS_VNODE_PSEUDODIR 7 /* set if Vnode is a pseudo directory */
585 #define AFS_VNODE_NEW_CONTENT 8 /* Set if file has new content (create/trunc-0) */
587 struct list_head wb_keys; /* List of keys available for writeback */
588 struct list_head pending_locks; /* locks waiting to be granted */
589 struct list_head granted_locks; /* locks granted on this file */
590 struct delayed_work lock_work; /* work to be done in locking */
591 struct key *lock_key; /* Key to be used in lock ops */
592 enum afs_lock_state lock_state : 8;
593 afs_lock_type_t lock_type : 8;
595 /* outstanding callback notification on this file */
596 struct afs_cb_interest *cb_interest; /* Server on which this resides */
597 unsigned int cb_s_break; /* Mass break counter on ->server */
598 unsigned int cb_v_break; /* Mass break counter on ->volume */
599 unsigned int cb_break; /* Break counter on vnode */
600 seqlock_t cb_lock; /* Lock for ->cb_interest, ->status, ->cb_*break */
602 time64_t cb_expires_at; /* time at which callback expires */
603 unsigned cb_version; /* callback version */
604 afs_callback_type_t cb_type; /* type of callback */
607 static inline struct fscache_cookie *afs_vnode_cache(struct afs_vnode *vnode)
609 #ifdef CONFIG_AFS_FSCACHE
617 * cached security record for one user's attempt to access a vnode
620 struct key *key; /* RxRPC ticket holding a security context */
621 afs_access_t access; /* CallerAccess value for this key */
625 * Immutable cache of CallerAccess records from attempts to access vnodes.
626 * These may be shared between multiple vnodes.
630 struct hlist_node hash_node; /* Link in hash */
631 unsigned long h; /* Hash value for this permit list */
633 unsigned short nr_permits; /* Number of records */
634 bool invalidated; /* Invalidated due to key change */
635 struct afs_permit permits[]; /* List of permits sorted by key pointer */
639 * record of one of a system's set of network interfaces
641 struct afs_interface {
642 struct in_addr address; /* IPv4 address bound to interface */
643 struct in_addr netmask; /* netmask applied to address */
644 unsigned mtu; /* MTU of interface */
648 * Cursor for iterating over a server's address list.
650 struct afs_addr_cursor {
651 struct afs_addr_list *alist; /* Current address list (pins ref) */
652 struct sockaddr_rxrpc *addr;
654 unsigned short start; /* Starting point in alist->addrs[] */
655 unsigned short index; /* Wrapping offset from start to current addr */
657 bool begun; /* T if we've begun iteration */
658 bool responded; /* T if the current address responded */
662 * Cursor for iterating over a set of volume location servers.
664 struct afs_vl_cursor {
665 struct afs_addr_cursor ac;
666 struct afs_cell *cell; /* The cell we're querying */
667 struct afs_vlserver_list *server_list; /* Current server list (pins ref) */
668 struct key *key; /* Key for the server */
669 unsigned char start; /* Initial index in server list */
670 unsigned char index; /* Number of servers tried beyond start */
672 unsigned short flags;
673 #define AFS_VL_CURSOR_STOP 0x0001 /* Set to cease iteration */
674 #define AFS_VL_CURSOR_RETRY 0x0002 /* Set to do a retry */
675 #define AFS_VL_CURSOR_RETRIED 0x0004 /* Set if started a retry */
679 * Cursor for iterating over a set of fileservers.
681 struct afs_fs_cursor {
682 struct afs_addr_cursor ac;
683 struct afs_vnode *vnode;
684 struct afs_server_list *server_list; /* Current server list (pins ref) */
685 struct afs_cb_interest *cbi; /* Server on which this resides (pins ref) */
686 struct key *key; /* Key for the server */
687 unsigned int cb_break; /* cb_break + cb_s_break before the call */
688 unsigned int cb_break_2; /* cb_break + cb_s_break (2nd vnode) */
689 unsigned char start; /* Initial index in server list */
690 unsigned char index; /* Number of servers tried beyond start */
692 unsigned short flags;
693 #define AFS_FS_CURSOR_STOP 0x0001 /* Set to cease iteration */
694 #define AFS_FS_CURSOR_VBUSY 0x0002 /* Set if seen VBUSY */
695 #define AFS_FS_CURSOR_VMOVED 0x0004 /* Set if seen VMOVED */
696 #define AFS_FS_CURSOR_VNOVOL 0x0008 /* Set if seen VNOVOL */
697 #define AFS_FS_CURSOR_CUR_ONLY 0x0010 /* Set if current server only (file lock held) */
698 #define AFS_FS_CURSOR_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */
702 * Cache auxiliary data.
704 struct afs_vnode_cache_aux {
708 #include <trace/events/afs.h>
710 /*****************************************************************************/
714 static inline struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist)
717 refcount_inc(&alist->usage);
720 extern struct afs_addr_list *afs_alloc_addrlist(unsigned int,
723 extern void afs_put_addrlist(struct afs_addr_list *);
724 extern struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *,
725 const char *, size_t, char,
726 unsigned short, unsigned short);
727 extern struct afs_vlserver_list *afs_dns_query(struct afs_cell *, time64_t *);
728 extern bool afs_iterate_addresses(struct afs_addr_cursor *);
729 extern int afs_end_cursor(struct afs_addr_cursor *);
731 extern void afs_merge_fs_addr4(struct afs_addr_list *, __be32, u16);
732 extern void afs_merge_fs_addr6(struct afs_addr_list *, __be32 *, u16);
737 #ifdef CONFIG_AFS_FSCACHE
738 extern struct fscache_netfs afs_cache_netfs;
739 extern struct fscache_cookie_def afs_cell_cache_index_def;
740 extern struct fscache_cookie_def afs_volume_cache_index_def;
741 extern struct fscache_cookie_def afs_vnode_cache_index_def;
743 #define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL)
744 #define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL)
745 #define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL)
751 extern void afs_init_callback_state(struct afs_server *);
752 extern void afs_break_callback(struct afs_vnode *);
753 extern void afs_break_callbacks(struct afs_server *, size_t, struct afs_callback_break*);
755 extern int afs_register_server_cb_interest(struct afs_vnode *,
756 struct afs_server_list *, unsigned int);
757 extern void afs_put_cb_interest(struct afs_net *, struct afs_cb_interest *);
758 extern void afs_clear_callback_interests(struct afs_net *, struct afs_server_list *);
760 static inline struct afs_cb_interest *afs_get_cb_interest(struct afs_cb_interest *cbi)
763 refcount_inc(&cbi->usage);
767 static inline unsigned int afs_calc_vnode_cb_break(struct afs_vnode *vnode)
769 return vnode->cb_break + vnode->cb_s_break + vnode->cb_v_break;
772 static inline unsigned int afs_cb_break_sum(struct afs_vnode *vnode,
773 struct afs_cb_interest *cbi)
775 return vnode->cb_break + cbi->server->cb_s_break + vnode->volume->cb_v_break;
781 extern int afs_cell_init(struct afs_net *, const char *);
782 extern struct afs_cell *afs_lookup_cell_rcu(struct afs_net *, const char *, unsigned);
783 extern struct afs_cell *afs_lookup_cell(struct afs_net *, const char *, unsigned,
785 extern struct afs_cell *afs_get_cell(struct afs_cell *);
786 extern void afs_put_cell(struct afs_net *, struct afs_cell *);
787 extern void afs_manage_cells(struct work_struct *);
788 extern void afs_cells_timer(struct timer_list *);
789 extern void __net_exit afs_cell_purge(struct afs_net *);
794 extern bool afs_cm_incoming_call(struct afs_call *);
799 extern const struct file_operations afs_dir_file_operations;
800 extern const struct inode_operations afs_dir_inode_operations;
801 extern const struct address_space_operations afs_dir_aops;
802 extern const struct dentry_operations afs_fs_dentry_operations;
804 extern void afs_d_release(struct dentry *);
809 extern void afs_edit_dir_add(struct afs_vnode *, struct qstr *, struct afs_fid *,
810 enum afs_edit_dir_reason);
811 extern void afs_edit_dir_remove(struct afs_vnode *, struct qstr *, enum afs_edit_dir_reason);
816 extern const struct file_operations afs_dynroot_file_operations;
817 extern const struct inode_operations afs_dynroot_inode_operations;
818 extern const struct dentry_operations afs_dynroot_dentry_operations;
820 extern struct inode *afs_try_auto_mntpt(struct dentry *, struct inode *);
821 extern int afs_dynroot_mkdir(struct afs_net *, struct afs_cell *);
822 extern void afs_dynroot_rmdir(struct afs_net *, struct afs_cell *);
823 extern int afs_dynroot_populate(struct super_block *);
824 extern void afs_dynroot_depopulate(struct super_block *);
829 extern const struct address_space_operations afs_fs_aops;
830 extern const struct inode_operations afs_file_inode_operations;
831 extern const struct file_operations afs_file_operations;
833 extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *);
834 extern void afs_put_wb_key(struct afs_wb_key *);
835 extern int afs_open(struct inode *, struct file *);
836 extern int afs_release(struct inode *, struct file *);
837 extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *);
838 extern int afs_page_filler(void *, struct page *);
839 extern void afs_put_read(struct afs_read *);
844 extern struct workqueue_struct *afs_lock_manager;
846 extern void afs_lock_work(struct work_struct *);
847 extern void afs_lock_may_be_available(struct afs_vnode *);
848 extern int afs_lock(struct file *, int, struct file_lock *);
849 extern int afs_flock(struct file *, int, struct file_lock *);
854 #define AFS_VNODE_NOT_YET_SET 0x01
855 #define AFS_VNODE_META_CHANGED 0x02
856 #define AFS_VNODE_DATA_CHANGED 0x04
857 extern void afs_update_inode_from_status(struct afs_vnode *, struct afs_file_status *,
858 const afs_dataversion_t *, u8);
860 extern int afs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_volsync *, bool);
861 extern int afs_fs_give_up_callbacks(struct afs_net *, struct afs_server *);
862 extern int afs_fs_fetch_data(struct afs_fs_cursor *, struct afs_read *);
863 extern int afs_fs_create(struct afs_fs_cursor *, const char *, umode_t, u64,
864 struct afs_fid *, struct afs_file_status *, struct afs_callback *);
865 extern int afs_fs_remove(struct afs_fs_cursor *, const char *, bool, u64);
866 extern int afs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64);
867 extern int afs_fs_symlink(struct afs_fs_cursor *, const char *, const char *, u64,
868 struct afs_fid *, struct afs_file_status *);
869 extern int afs_fs_rename(struct afs_fs_cursor *, const char *,
870 struct afs_vnode *, const char *, u64, u64);
871 extern int afs_fs_store_data(struct afs_fs_cursor *, struct address_space *,
872 pgoff_t, pgoff_t, unsigned, unsigned);
873 extern int afs_fs_setattr(struct afs_fs_cursor *, struct iattr *);
874 extern int afs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *);
875 extern int afs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t);
876 extern int afs_fs_extend_lock(struct afs_fs_cursor *);
877 extern int afs_fs_release_lock(struct afs_fs_cursor *);
878 extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *,
879 struct afs_addr_cursor *, struct key *);
880 extern int afs_fs_get_capabilities(struct afs_net *, struct afs_server *,
881 struct afs_addr_cursor *, struct key *);
882 extern int afs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *,
883 struct afs_fid *, struct afs_file_status *,
884 struct afs_callback *, unsigned int,
885 struct afs_volsync *);
886 extern int afs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *,
887 struct afs_fid *, struct afs_file_status *,
888 struct afs_callback *, struct afs_volsync *);
893 extern int afs_fetch_status(struct afs_vnode *, struct key *, bool);
894 extern int afs_iget5_test(struct inode *, void *);
895 extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool);
896 extern struct inode *afs_iget(struct super_block *, struct key *,
897 struct afs_fid *, struct afs_file_status *,
898 struct afs_callback *,
899 struct afs_cb_interest *);
900 extern void afs_zap_data(struct afs_vnode *);
901 extern int afs_validate(struct afs_vnode *, struct key *);
902 extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int);
903 extern int afs_setattr(struct dentry *, struct iattr *);
904 extern void afs_evict_inode(struct inode *);
905 extern int afs_drop_inode(struct inode *);
910 extern struct workqueue_struct *afs_wq;
911 extern int afs_net_id;
913 static inline struct afs_net *afs_net(struct net *net)
915 return net_generic(net, afs_net_id);
918 static inline struct afs_net *afs_sb2net(struct super_block *sb)
920 return afs_net(AFS_FS_S(sb)->net_ns);
923 static inline struct afs_net *afs_d2net(struct dentry *dentry)
925 return afs_sb2net(dentry->d_sb);
928 static inline struct afs_net *afs_i2net(struct inode *inode)
930 return afs_sb2net(inode->i_sb);
933 static inline struct afs_net *afs_v2net(struct afs_vnode *vnode)
935 return afs_i2net(&vnode->vfs_inode);
938 static inline struct afs_net *afs_sock2net(struct sock *sk)
940 return net_generic(sock_net(sk), afs_net_id);
943 static inline void __afs_stat(atomic_t *s)
948 #define afs_stat_v(vnode, n) __afs_stat(&afs_v2net(vnode)->n)
953 extern int afs_abort_to_error(u32);
958 extern const struct inode_operations afs_mntpt_inode_operations;
959 extern const struct inode_operations afs_autocell_inode_operations;
960 extern const struct file_operations afs_mntpt_file_operations;
962 extern struct vfsmount *afs_d_automount(struct path *);
963 extern void afs_mntpt_kill_timer(void);
968 extern int afs_get_ipv4_interfaces(struct afs_net *, struct afs_interface *,
974 #ifdef CONFIG_PROC_FS
975 extern int __net_init afs_proc_init(struct afs_net *);
976 extern void __net_exit afs_proc_cleanup(struct afs_net *);
977 extern int afs_proc_cell_setup(struct afs_cell *);
978 extern void afs_proc_cell_remove(struct afs_cell *);
979 extern void afs_put_sysnames(struct afs_sysnames *);
981 static inline int afs_proc_init(struct afs_net *net) { return 0; }
982 static inline void afs_proc_cleanup(struct afs_net *net) {}
983 static inline int afs_proc_cell_setup(struct afs_cell *cell) { return 0; }
984 static inline void afs_proc_cell_remove(struct afs_cell *cell) {}
985 static inline void afs_put_sysnames(struct afs_sysnames *sysnames) {}
991 extern bool afs_begin_vnode_operation(struct afs_fs_cursor *, struct afs_vnode *,
993 extern bool afs_select_fileserver(struct afs_fs_cursor *);
994 extern bool afs_select_current_fileserver(struct afs_fs_cursor *);
995 extern int afs_end_vnode_operation(struct afs_fs_cursor *);
1000 extern struct workqueue_struct *afs_async_calls;
1002 extern int __net_init afs_open_socket(struct afs_net *);
1003 extern void __net_exit afs_close_socket(struct afs_net *);
1004 extern void afs_charge_preallocation(struct work_struct *);
1005 extern void afs_put_call(struct afs_call *);
1006 extern int afs_queue_call_work(struct afs_call *);
1007 extern long afs_make_call(struct afs_addr_cursor *, struct afs_call *, gfp_t, bool);
1008 extern struct afs_call *afs_alloc_flat_call(struct afs_net *,
1009 const struct afs_call_type *,
1011 extern void afs_flat_call_destructor(struct afs_call *);
1012 extern void afs_send_empty_reply(struct afs_call *);
1013 extern void afs_send_simple_reply(struct afs_call *, const void *, size_t);
1014 extern int afs_extract_data(struct afs_call *, bool);
1015 extern int afs_protocol_error(struct afs_call *, int, enum afs_eproto_cause);
1017 static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t size)
1019 call->kvec[0].iov_base = buf;
1020 call->kvec[0].iov_len = size;
1021 iov_iter_kvec(&call->iter, READ, call->kvec, 1, size);
1024 static inline void afs_extract_to_tmp(struct afs_call *call)
1026 afs_extract_begin(call, &call->tmp, sizeof(call->tmp));
1029 static inline void afs_extract_to_tmp64(struct afs_call *call)
1031 afs_extract_begin(call, &call->tmp64, sizeof(call->tmp64));
1034 static inline void afs_extract_discard(struct afs_call *call, size_t size)
1036 iov_iter_discard(&call->iter, READ, size);
1039 static inline void afs_extract_to_buf(struct afs_call *call, size_t size)
1041 afs_extract_begin(call, call->buffer, size);
1044 static inline int afs_transfer_reply(struct afs_call *call)
1046 return afs_extract_data(call, false);
1049 static inline bool afs_check_call_state(struct afs_call *call,
1050 enum afs_call_state state)
1052 return READ_ONCE(call->state) == state;
1055 static inline bool afs_set_call_state(struct afs_call *call,
1056 enum afs_call_state from,
1057 enum afs_call_state to)
1061 spin_lock_bh(&call->state_lock);
1062 if (call->state == from) {
1064 trace_afs_call_state(call, from, to, 0, 0);
1067 spin_unlock_bh(&call->state_lock);
1071 static inline void afs_set_call_complete(struct afs_call *call,
1072 int error, u32 remote_abort)
1074 enum afs_call_state state;
1077 spin_lock_bh(&call->state_lock);
1078 state = call->state;
1079 if (state != AFS_CALL_COMPLETE) {
1080 call->abort_code = remote_abort;
1081 call->error = error;
1082 call->state = AFS_CALL_COMPLETE;
1083 trace_afs_call_state(call, state, AFS_CALL_COMPLETE,
1084 error, remote_abort);
1087 spin_unlock_bh(&call->state_lock);
1089 trace_afs_call_done(call);
1095 extern void afs_put_permits(struct afs_permits *);
1096 extern void afs_clear_permits(struct afs_vnode *);
1097 extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int);
1098 extern void afs_zap_permits(struct rcu_head *);
1099 extern struct key *afs_request_key(struct afs_cell *);
1100 extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *);
1101 extern int afs_permission(struct inode *, int);
1102 extern void __exit afs_clean_up_permit_cache(void);
1107 extern spinlock_t afs_server_peer_lock;
1109 static inline struct afs_server *afs_get_server(struct afs_server *server)
1111 atomic_inc(&server->usage);
1115 extern struct afs_server *afs_find_server(struct afs_net *,
1116 const struct sockaddr_rxrpc *);
1117 extern struct afs_server *afs_find_server_by_uuid(struct afs_net *, const uuid_t *);
1118 extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *);
1119 extern void afs_put_server(struct afs_net *, struct afs_server *);
1120 extern void afs_manage_servers(struct work_struct *);
1121 extern void afs_servers_timer(struct timer_list *);
1122 extern void __net_exit afs_purge_servers(struct afs_net *);
1123 extern bool afs_probe_fileserver(struct afs_fs_cursor *);
1124 extern bool afs_check_server_record(struct afs_fs_cursor *, struct afs_server *);
1129 static inline struct afs_server_list *afs_get_serverlist(struct afs_server_list *slist)
1131 refcount_inc(&slist->usage);
1135 extern void afs_put_serverlist(struct afs_net *, struct afs_server_list *);
1136 extern struct afs_server_list *afs_alloc_server_list(struct afs_cell *, struct key *,
1137 struct afs_vldb_entry *,
1139 extern bool afs_annotate_server_list(struct afs_server_list *, struct afs_server_list *);
1144 extern int __init afs_fs_init(void);
1145 extern void afs_fs_exit(void);
1150 extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *,
1152 extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *, const uuid_t *);
1153 extern int afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *, struct key *);
1154 extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *, const uuid_t *);
1159 extern bool afs_begin_vlserver_operation(struct afs_vl_cursor *,
1160 struct afs_cell *, struct key *);
1161 extern bool afs_select_vlserver(struct afs_vl_cursor *);
1162 extern bool afs_select_current_vlserver(struct afs_vl_cursor *);
1163 extern int afs_end_vlserver_operation(struct afs_vl_cursor *);
1168 static inline struct afs_vlserver *afs_get_vlserver(struct afs_vlserver *vlserver)
1170 atomic_inc(&vlserver->usage);
1174 static inline struct afs_vlserver_list *afs_get_vlserverlist(struct afs_vlserver_list *vllist)
1177 atomic_inc(&vllist->usage);
1181 extern struct afs_vlserver *afs_alloc_vlserver(const char *, size_t, unsigned short);
1182 extern void afs_put_vlserver(struct afs_net *, struct afs_vlserver *);
1183 extern struct afs_vlserver_list *afs_alloc_vlserver_list(unsigned int);
1184 extern void afs_put_vlserverlist(struct afs_net *, struct afs_vlserver_list *);
1185 extern struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *,
1186 const void *, size_t);
1191 static inline struct afs_volume *__afs_get_volume(struct afs_volume *volume)
1194 atomic_inc(&volume->usage);
1198 extern struct afs_volume *afs_create_volume(struct afs_mount_params *);
1199 extern void afs_activate_volume(struct afs_volume *);
1200 extern void afs_deactivate_volume(struct afs_volume *);
1201 extern void afs_put_volume(struct afs_cell *, struct afs_volume *);
1202 extern int afs_check_volume_status(struct afs_volume *, struct key *);
1207 extern int afs_set_page_dirty(struct page *);
1208 extern int afs_write_begin(struct file *file, struct address_space *mapping,
1209 loff_t pos, unsigned len, unsigned flags,
1210 struct page **pagep, void **fsdata);
1211 extern int afs_write_end(struct file *file, struct address_space *mapping,
1212 loff_t pos, unsigned len, unsigned copied,
1213 struct page *page, void *fsdata);
1214 extern int afs_writepage(struct page *, struct writeback_control *);
1215 extern int afs_writepages(struct address_space *, struct writeback_control *);
1216 extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *);
1217 extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *);
1218 extern int afs_fsync(struct file *, loff_t, loff_t, int);
1219 extern vm_fault_t afs_page_mkwrite(struct vm_fault *vmf);
1220 extern void afs_prune_wb_keys(struct afs_vnode *);
1221 extern int afs_launder_page(struct page *);
1226 extern const struct xattr_handler *afs_xattr_handlers[];
1227 extern ssize_t afs_listxattr(struct dentry *, char *, size_t);
1231 * Miscellaneous inline functions.
1233 static inline struct afs_vnode *AFS_FS_I(struct inode *inode)
1235 return container_of(inode, struct afs_vnode, vfs_inode);
1238 static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode)
1240 return &vnode->vfs_inode;
1243 static inline void afs_vnode_commit_status(struct afs_fs_cursor *fc,
1244 struct afs_vnode *vnode,
1245 unsigned int cb_break)
1247 if (fc->ac.error == 0)
1248 afs_cache_permit(vnode, fc->key, cb_break);
1251 static inline void afs_check_for_remote_deletion(struct afs_fs_cursor *fc,
1252 struct afs_vnode *vnode)
1254 if (fc->ac.error == -ENOENT) {
1255 set_bit(AFS_VNODE_DELETED, &vnode->flags);
1256 afs_break_callback(vnode);
1260 static inline int afs_io_error(struct afs_call *call, enum afs_io_error where)
1262 trace_afs_io_error(call->debug_id, -EIO, where);
1266 static inline int afs_bad(struct afs_vnode *vnode, enum afs_file_error where)
1268 trace_afs_file_error(vnode, -EIO, where);
1272 /*****************************************************************************/
1276 extern unsigned afs_debug;
1278 #define dbgprintk(FMT,...) \
1279 printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
1281 #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
1282 #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
1283 #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__)
1286 #if defined(__KDEBUG)
1287 #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__)
1288 #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__)
1289 #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__)
1291 #elif defined(CONFIG_AFS_DEBUG)
1292 #define AFS_DEBUG_KENTER 0x01
1293 #define AFS_DEBUG_KLEAVE 0x02
1294 #define AFS_DEBUG_KDEBUG 0x04
1296 #define _enter(FMT,...) \
1298 if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \
1299 kenter(FMT,##__VA_ARGS__); \
1302 #define _leave(FMT,...) \
1304 if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \
1305 kleave(FMT,##__VA_ARGS__); \
1308 #define _debug(FMT,...) \
1310 if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \
1311 kdebug(FMT,##__VA_ARGS__); \
1315 #define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
1316 #define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
1317 #define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__)
1321 * debug assertion checking
1323 #if 1 // defined(__KDEBUGALL)
1327 if (unlikely(!(X))) { \
1328 printk(KERN_ERR "\n"); \
1329 printk(KERN_ERR "AFS: Assertion failed\n"); \
1334 #define ASSERTCMP(X, OP, Y) \
1336 if (unlikely(!((X) OP (Y)))) { \
1337 printk(KERN_ERR "\n"); \
1338 printk(KERN_ERR "AFS: Assertion failed\n"); \
1339 printk(KERN_ERR "%lu " #OP " %lu is false\n", \
1340 (unsigned long)(X), (unsigned long)(Y)); \
1341 printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
1342 (unsigned long)(X), (unsigned long)(Y)); \
1347 #define ASSERTRANGE(L, OP1, N, OP2, H) \
1349 if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \
1350 printk(KERN_ERR "\n"); \
1351 printk(KERN_ERR "AFS: Assertion failed\n"); \
1352 printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \
1353 (unsigned long)(L), (unsigned long)(N), \
1354 (unsigned long)(H)); \
1355 printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \
1356 (unsigned long)(L), (unsigned long)(N), \
1357 (unsigned long)(H)); \
1362 #define ASSERTIF(C, X) \
1364 if (unlikely((C) && !(X))) { \
1365 printk(KERN_ERR "\n"); \
1366 printk(KERN_ERR "AFS: Assertion failed\n"); \
1371 #define ASSERTIFCMP(C, X, OP, Y) \
1373 if (unlikely((C) && !((X) OP (Y)))) { \
1374 printk(KERN_ERR "\n"); \
1375 printk(KERN_ERR "AFS: Assertion failed\n"); \
1376 printk(KERN_ERR "%lu " #OP " %lu is false\n", \
1377 (unsigned long)(X), (unsigned long)(Y)); \
1378 printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
1379 (unsigned long)(X), (unsigned long)(Y)); \
1390 #define ASSERTCMP(X, OP, Y) \
1394 #define ASSERTRANGE(L, OP1, N, OP2, H) \
1398 #define ASSERTIF(C, X) \
1402 #define ASSERTIFCMP(C, X, OP, Y) \
1406 #endif /* __KDEBUGALL */