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 bool want_reply_time; /* T if want reply_time */
135 u16 service_id; /* Actual service ID (after upgrade) */
136 unsigned int debug_id; /* Trace ID */
137 u32 operation_ID; /* operation ID for an incoming call */
138 u32 count; /* count for use in unmarshalling */
139 union { /* place to extract temporary data */
143 } __attribute__((packed));
146 afs_dataversion_t expected_version; /* Updated version expected from store */
147 afs_dataversion_t expected_version_2; /* 2nd updated version expected from store */
148 ktime_t reply_time; /* Time of first reply packet */
151 struct afs_call_type {
153 unsigned int op; /* Really enum afs_fs_operation */
155 /* deliver request or reply data to an call
156 * - returning an error will cause the call to be aborted
158 int (*deliver)(struct afs_call *call);
160 /* clean up a call */
161 void (*destructor)(struct afs_call *call);
164 void (*work)(struct work_struct *work);
168 * Key available for writeback on a file.
173 struct list_head vnode_link; /* Link in vnode->wb_keys */
177 * AFS open file information record. Pointed to by file->private_data.
180 struct key *key; /* The key this file was opened with */
181 struct afs_wb_key *wb; /* Writeback key record for this file */
184 static inline struct key *afs_file_key(struct file *file)
186 struct afs_file *af = file->private_data;
192 * Record of an outstanding read operation on a vnode.
195 loff_t pos; /* Where to start reading */
196 loff_t len; /* How much we're asking for */
197 loff_t actual_len; /* How much we're actually getting */
198 loff_t remain; /* Amount remaining */
199 loff_t file_size; /* File size returned by server */
200 afs_dataversion_t data_version; /* Version number returned by server */
202 unsigned int index; /* Which page we're reading into */
203 unsigned int nr_pages;
204 unsigned int offset; /* offset into current page */
205 void (*page_done)(struct afs_call *, struct afs_read *);
207 struct page *array[];
211 * AFS superblock private data
212 * - there's one superblock per volume
214 struct afs_super_info {
215 struct net *net_ns; /* Network namespace */
216 struct afs_cell *cell; /* The cell in which the volume resides */
217 struct afs_volume *volume; /* volume record */
218 bool dyn_root; /* True if dynamic root */
221 static inline struct afs_super_info *AFS_FS_S(struct super_block *sb)
223 return sb->s_fs_info;
226 extern struct file_system_type afs_fs_type;
229 * Set of substitutes for @sys.
231 struct afs_sysnames {
232 #define AFS_NR_SYSNAME 16
233 char *subs[AFS_NR_SYSNAME];
240 * AFS network namespace record.
243 struct net *net; /* Backpointer to the owning net namespace */
244 struct afs_uuid uuid;
245 bool live; /* F if this namespace is being removed */
247 /* AF_RXRPC I/O stuff */
248 struct socket *socket;
249 struct afs_call *spare_incoming_call;
250 struct work_struct charge_preallocation_work;
251 struct mutex socket_mutex;
252 atomic_t nr_outstanding_calls;
253 atomic_t nr_superblocks;
256 struct rb_root cells;
257 struct afs_cell __rcu *ws_cell;
258 struct work_struct cells_manager;
259 struct timer_list cells_timer;
260 atomic_t cells_outstanding;
261 seqlock_t cells_lock;
263 struct mutex proc_cells_lock;
264 struct hlist_head proc_cells;
266 /* Known servers. Theoretically each fileserver can only be in one
267 * cell, but in practice, people create aliases and subsets and there's
268 * no easy way to distinguish them.
270 seqlock_t fs_lock; /* For fs_servers */
271 struct rb_root fs_servers; /* afs_server (by server UUID or address) */
272 struct list_head fs_updates; /* afs_server (by update_at) */
273 struct hlist_head fs_proc; /* procfs servers list */
275 struct hlist_head fs_addresses4; /* afs_server (by lowest IPv4 addr) */
276 struct hlist_head fs_addresses6; /* afs_server (by lowest IPv6 addr) */
277 seqlock_t fs_addr_lock; /* For fs_addresses[46] */
279 struct work_struct fs_manager;
280 struct timer_list fs_timer;
281 atomic_t servers_outstanding;
283 /* File locking renewal management */
284 struct mutex lock_manager_mutex;
287 struct super_block *dynroot_sb; /* Dynamic root mount superblock */
288 struct proc_dir_entry *proc_afs; /* /proc/net/afs directory */
289 struct afs_sysnames *sysnames;
290 rwlock_t sysnames_lock;
292 /* Statistics counters */
293 atomic_t n_lookup; /* Number of lookups done */
294 atomic_t n_reval; /* Number of dentries needing revalidation */
295 atomic_t n_inval; /* Number of invalidations by the server */
296 atomic_t n_relpg; /* Number of invalidations by releasepage */
297 atomic_t n_read_dir; /* Number of directory pages read */
298 atomic_t n_dir_cr; /* Number of directory entry creation edits */
299 atomic_t n_dir_rm; /* Number of directory entry removal edits */
300 atomic_t n_stores; /* Number of store ops */
301 atomic_long_t n_store_bytes; /* Number of bytes stored */
302 atomic_long_t n_fetch_bytes; /* Number of bytes fetched */
303 atomic_t n_fetches; /* Number of data fetch ops */
306 extern const char afs_init_sysname[];
308 enum afs_cell_state {
312 AFS_CELL_DEACTIVATING,
320 * This is a tricky concept to get right as it is possible to create aliases
321 * simply by pointing AFSDB/SRV records for two names at the same set of VL
322 * servers; it is also possible to do things like setting up two sets of VL
323 * servers, one of which provides a superset of the volumes provided by the
324 * other (for internal/external division, for example).
326 * Cells only exist in the sense that (a) a cell's name maps to a set of VL
327 * servers and (b) a cell's name is used by the client to select the key to use
328 * for authentication and encryption. The cell name is not typically used in
331 * There is no easy way to determine if two cells are aliases or one is a
337 struct rb_node net_node; /* Node in net->cells */
340 struct key *anonymous_key; /* anonymous user key for this cell */
341 struct work_struct manager; /* Manager for init/deinit/dns */
342 struct hlist_node proc_link; /* /proc cell list link */
343 #ifdef CONFIG_AFS_FSCACHE
344 struct fscache_cookie *cache; /* caching cookie */
346 time64_t dns_expiry; /* Time AFSDB/SRV record expires */
347 time64_t last_inactive; /* Time of last drop of usage count */
350 #define AFS_CELL_FL_NOT_READY 0 /* The cell record is not ready for use */
351 #define AFS_CELL_FL_NO_GC 1 /* The cell was added manually, don't auto-gc */
352 #define AFS_CELL_FL_NOT_FOUND 2 /* Permanent DNS error */
353 #define AFS_CELL_FL_DNS_FAIL 3 /* Failed to access DNS */
354 #define AFS_CELL_FL_NO_LOOKUP_YET 4 /* Not completed first DNS lookup yet */
355 enum afs_cell_state state;
358 /* Active fileserver interaction state. */
359 struct list_head proc_volumes; /* procfs volume list */
362 /* VL server list. */
363 rwlock_t vl_servers_lock; /* Lock on vl_servers */
364 struct afs_vlserver_list __rcu *vl_servers;
366 u8 name_len; /* Length of name */
367 char name[64 + 1]; /* Cell name, case-flattened and NUL-padded */
371 * Volume Location server record.
373 struct afs_vlserver {
375 struct afs_addr_list __rcu *addresses; /* List of addresses for this VL server */
377 #define AFS_VLSERVER_FL_PROBED 0 /* The VL server has been probed */
378 #define AFS_VLSERVER_FL_PROBING 1 /* VL server is being probed */
379 rwlock_t lock; /* Lock on addresses */
381 u16 name_len; /* Length of name */
383 char name[]; /* Server name, case-flattened */
387 * Weighted list of Volume Location servers.
389 struct afs_vlserver_entry {
390 u16 priority; /* Preference (as SRV) */
391 u16 weight; /* Weight (as SRV) */
392 enum dns_record_source source:8;
393 enum dns_lookup_status status:8;
394 struct afs_vlserver *server;
397 struct afs_vlserver_list {
401 u8 index; /* Server currently in use */
402 enum dns_record_source source:8;
403 enum dns_lookup_status status:8;
405 struct afs_vlserver_entry servers[];
411 * This is pointed to by cell->vldb_entries, indexed by name.
413 struct afs_vldb_entry {
414 afs_volid_t vid[3]; /* Volume IDs for R/W, R/O and Bak volumes */
417 #define AFS_VLDB_HAS_RW 0 /* - R/W volume exists */
418 #define AFS_VLDB_HAS_RO 1 /* - R/O volume exists */
419 #define AFS_VLDB_HAS_BAK 2 /* - Backup volume exists */
420 #define AFS_VLDB_QUERY_VALID 3 /* - Record is valid */
421 #define AFS_VLDB_QUERY_ERROR 4 /* - VL server returned error */
423 uuid_t fs_server[AFS_NMAXNSERVERS];
424 u8 fs_mask[AFS_NMAXNSERVERS];
425 #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */
426 #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */
427 #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */
429 u8 nr_servers; /* Number of server records */
431 u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */
435 * Record of fileserver with which we're actively communicating.
440 uuid_t uuid; /* Server ID */
441 struct afs_uuid _uuid;
444 struct afs_addr_list __rcu *addresses;
445 struct rb_node uuid_rb; /* Link in net->servers */
446 struct hlist_node addr4_link; /* Link in net->fs_addresses4 */
447 struct hlist_node addr6_link; /* Link in net->fs_addresses6 */
448 struct hlist_node proc_link; /* Link in net->fs_proc */
449 struct afs_server *gc_next; /* Next server in manager's list */
450 time64_t put_time; /* Time at which last put */
451 time64_t update_at; /* Time at which to next update the record */
453 #define AFS_SERVER_FL_NEW 0 /* New server, don't inc cb_s_break */
454 #define AFS_SERVER_FL_NOT_READY 1 /* The record is not ready for use */
455 #define AFS_SERVER_FL_NOT_FOUND 2 /* VL server says no such server */
456 #define AFS_SERVER_FL_VL_FAIL 3 /* Failed to access VL server */
457 #define AFS_SERVER_FL_UPDATING 4
458 #define AFS_SERVER_FL_PROBED 5 /* The fileserver has been probed */
459 #define AFS_SERVER_FL_PROBING 6 /* Fileserver is being probed */
460 #define AFS_SERVER_FL_NO_IBULK 7 /* Fileserver doesn't support FS.InlineBulkStatus */
461 #define AFS_SERVER_FL_MAY_HAVE_CB 8 /* May have callbacks on this fileserver */
463 u32 addr_version; /* Address list version */
465 /* file service access */
466 rwlock_t fs_lock; /* access lock */
468 /* callback promise management */
469 struct hlist_head cb_volumes; /* List of volume interests on this server */
470 unsigned cb_s_break; /* Break-everything counter. */
471 rwlock_t cb_break_lock; /* Volume finding lock */
475 * Volume collation in the server's callback interest list.
477 struct afs_vol_interest {
478 struct hlist_node srv_link; /* Link in server->cb_volumes */
479 struct hlist_head cb_interests; /* List of callback interests on the server */
480 afs_volid_t vid; /* Volume ID to match */
485 * Interest by a superblock on a server.
487 struct afs_cb_interest {
488 struct hlist_node cb_vlink; /* Link in vol_interest->cb_interests */
489 struct afs_vol_interest *vol_interest;
490 struct afs_server *server; /* Server on which this interest resides */
491 struct super_block *sb; /* Superblock on which inodes reside */
492 afs_volid_t vid; /* Volume ID to match */
497 * Replaceable server list.
499 struct afs_server_entry {
500 struct afs_server *server;
501 struct afs_cb_interest *cb_interest;
504 struct afs_server_list {
506 unsigned short nr_servers;
507 unsigned short index; /* Server currently in use */
508 unsigned short vnovol_mask; /* Servers to be skipped due to VNOVOL */
509 unsigned int seq; /* Set to ->servers_seq when installed */
511 struct afs_server_entry servers[];
515 * Live AFS volume management.
518 afs_volid_t vid; /* volume ID */
520 time64_t update_at; /* Time at which to next update */
521 struct afs_cell *cell; /* Cell to which belongs (pins ref) */
522 struct list_head proc_link; /* Link in cell->vl_proc */
524 #define AFS_VOLUME_NEEDS_UPDATE 0 /* - T if an update needs performing */
525 #define AFS_VOLUME_UPDATING 1 /* - T if an update is in progress */
526 #define AFS_VOLUME_WAIT 2 /* - T if users must wait for update */
527 #define AFS_VOLUME_DELETED 3 /* - T if volume appears deleted */
528 #define AFS_VOLUME_OFFLINE 4 /* - T if volume offline notice given */
529 #define AFS_VOLUME_BUSY 5 /* - T if volume busy notice given */
530 #ifdef CONFIG_AFS_FSCACHE
531 struct fscache_cookie *cache; /* caching cookie */
533 struct afs_server_list *servers; /* List of servers on which volume resides */
534 rwlock_t servers_lock; /* Lock for ->servers */
535 unsigned int servers_seq; /* Incremented each time ->servers changes */
537 unsigned cb_v_break; /* Break-everything counter. */
538 rwlock_t cb_break_lock;
540 afs_voltype_t type; /* type of volume */
542 char type_force; /* force volume type (suppress R/O -> R/W) */
544 u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */
547 enum afs_lock_state {
548 AFS_VNODE_LOCK_NONE, /* The vnode has no lock on the server */
549 AFS_VNODE_LOCK_WAITING_FOR_CB, /* We're waiting for the server to break the callback */
550 AFS_VNODE_LOCK_SETTING, /* We're asking the server for a lock */
551 AFS_VNODE_LOCK_GRANTED, /* We have a lock on the server */
552 AFS_VNODE_LOCK_EXTENDING, /* We're extending a lock on the server */
553 AFS_VNODE_LOCK_NEED_UNLOCK, /* We need to unlock on the server */
554 AFS_VNODE_LOCK_UNLOCKING, /* We're telling the server to unlock */
558 * AFS inode private data.
560 * Note that afs_alloc_inode() *must* reset anything that could incorrectly
561 * leak from one inode to another.
564 struct inode vfs_inode; /* the VFS's inode record */
566 struct afs_volume *volume; /* volume on which vnode resides */
567 struct afs_fid fid; /* the file identifier for this inode */
568 struct afs_file_status status; /* AFS status info for this file */
569 afs_dataversion_t invalid_before; /* Child dentries are invalid before this */
570 #ifdef CONFIG_AFS_FSCACHE
571 struct fscache_cookie *cache; /* caching cookie */
573 struct afs_permits __rcu *permit_cache; /* cache of permits so far obtained */
574 struct mutex io_lock; /* Lock for serialising I/O on this mutex */
575 struct rw_semaphore validate_lock; /* lock for validating this vnode */
576 spinlock_t wb_lock; /* lock for wb_keys */
577 spinlock_t lock; /* waitqueue/flags lock */
579 #define AFS_VNODE_CB_PROMISED 0 /* Set if vnode has a callback promise */
580 #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */
581 #define AFS_VNODE_DIR_VALID 2 /* Set if dir contents are valid */
582 #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */
583 #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */
584 #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */
585 #define AFS_VNODE_AUTOCELL 6 /* set if Vnode is an auto mount point */
586 #define AFS_VNODE_PSEUDODIR 7 /* set if Vnode is a pseudo directory */
587 #define AFS_VNODE_NEW_CONTENT 8 /* Set if file has new content (create/trunc-0) */
589 struct list_head wb_keys; /* List of keys available for writeback */
590 struct list_head pending_locks; /* locks waiting to be granted */
591 struct list_head granted_locks; /* locks granted on this file */
592 struct delayed_work lock_work; /* work to be done in locking */
593 struct key *lock_key; /* Key to be used in lock ops */
594 enum afs_lock_state lock_state : 8;
595 afs_lock_type_t lock_type : 8;
597 /* outstanding callback notification on this file */
598 struct afs_cb_interest *cb_interest; /* Server on which this resides */
599 unsigned int cb_s_break; /* Mass break counter on ->server */
600 unsigned int cb_v_break; /* Mass break counter on ->volume */
601 unsigned int cb_break; /* Break counter on vnode */
602 seqlock_t cb_lock; /* Lock for ->cb_interest, ->status, ->cb_*break */
604 time64_t cb_expires_at; /* time at which callback expires */
605 unsigned cb_version; /* callback version */
606 afs_callback_type_t cb_type; /* type of callback */
609 static inline struct fscache_cookie *afs_vnode_cache(struct afs_vnode *vnode)
611 #ifdef CONFIG_AFS_FSCACHE
619 * cached security record for one user's attempt to access a vnode
622 struct key *key; /* RxRPC ticket holding a security context */
623 afs_access_t access; /* CallerAccess value for this key */
627 * Immutable cache of CallerAccess records from attempts to access vnodes.
628 * These may be shared between multiple vnodes.
632 struct hlist_node hash_node; /* Link in hash */
633 unsigned long h; /* Hash value for this permit list */
635 unsigned short nr_permits; /* Number of records */
636 bool invalidated; /* Invalidated due to key change */
637 struct afs_permit permits[]; /* List of permits sorted by key pointer */
641 * record of one of a system's set of network interfaces
643 struct afs_interface {
644 struct in_addr address; /* IPv4 address bound to interface */
645 struct in_addr netmask; /* netmask applied to address */
646 unsigned mtu; /* MTU of interface */
650 * Cursor for iterating over a server's address list.
652 struct afs_addr_cursor {
653 struct afs_addr_list *alist; /* Current address list (pins ref) */
654 struct sockaddr_rxrpc *addr;
656 unsigned short start; /* Starting point in alist->addrs[] */
657 unsigned short index; /* Wrapping offset from start to current addr */
659 bool begun; /* T if we've begun iteration */
660 bool responded; /* T if the current address responded */
664 * Cursor for iterating over a set of volume location servers.
666 struct afs_vl_cursor {
667 struct afs_addr_cursor ac;
668 struct afs_cell *cell; /* The cell we're querying */
669 struct afs_vlserver_list *server_list; /* Current server list (pins ref) */
670 struct key *key; /* Key for the server */
671 unsigned char start; /* Initial index in server list */
672 unsigned char index; /* Number of servers tried beyond start */
674 unsigned short flags;
675 #define AFS_VL_CURSOR_STOP 0x0001 /* Set to cease iteration */
676 #define AFS_VL_CURSOR_RETRY 0x0002 /* Set to do a retry */
677 #define AFS_VL_CURSOR_RETRIED 0x0004 /* Set if started a retry */
681 * Cursor for iterating over a set of fileservers.
683 struct afs_fs_cursor {
684 struct afs_addr_cursor ac;
685 struct afs_vnode *vnode;
686 struct afs_server_list *server_list; /* Current server list (pins ref) */
687 struct afs_cb_interest *cbi; /* Server on which this resides (pins ref) */
688 struct key *key; /* Key for the server */
689 unsigned int cb_break; /* cb_break + cb_s_break before the call */
690 unsigned int cb_break_2; /* cb_break + cb_s_break (2nd vnode) */
691 unsigned char start; /* Initial index in server list */
692 unsigned char index; /* Number of servers tried beyond start */
694 unsigned short flags;
695 #define AFS_FS_CURSOR_STOP 0x0001 /* Set to cease iteration */
696 #define AFS_FS_CURSOR_VBUSY 0x0002 /* Set if seen VBUSY */
697 #define AFS_FS_CURSOR_VMOVED 0x0004 /* Set if seen VMOVED */
698 #define AFS_FS_CURSOR_VNOVOL 0x0008 /* Set if seen VNOVOL */
699 #define AFS_FS_CURSOR_CUR_ONLY 0x0010 /* Set if current server only (file lock held) */
700 #define AFS_FS_CURSOR_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */
704 * Cache auxiliary data.
706 struct afs_vnode_cache_aux {
710 #include <trace/events/afs.h>
712 /*****************************************************************************/
716 static inline struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist)
719 refcount_inc(&alist->usage);
722 extern struct afs_addr_list *afs_alloc_addrlist(unsigned int,
725 extern void afs_put_addrlist(struct afs_addr_list *);
726 extern struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *,
727 const char *, size_t, char,
728 unsigned short, unsigned short);
729 extern struct afs_vlserver_list *afs_dns_query(struct afs_cell *, time64_t *);
730 extern bool afs_iterate_addresses(struct afs_addr_cursor *);
731 extern int afs_end_cursor(struct afs_addr_cursor *);
733 extern void afs_merge_fs_addr4(struct afs_addr_list *, __be32, u16);
734 extern void afs_merge_fs_addr6(struct afs_addr_list *, __be32 *, u16);
739 #ifdef CONFIG_AFS_FSCACHE
740 extern struct fscache_netfs afs_cache_netfs;
741 extern struct fscache_cookie_def afs_cell_cache_index_def;
742 extern struct fscache_cookie_def afs_volume_cache_index_def;
743 extern struct fscache_cookie_def afs_vnode_cache_index_def;
745 #define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL)
746 #define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL)
747 #define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL)
753 extern void afs_init_callback_state(struct afs_server *);
754 extern void afs_break_callback(struct afs_vnode *);
755 extern void afs_break_callbacks(struct afs_server *, size_t, struct afs_callback_break*);
757 extern int afs_register_server_cb_interest(struct afs_vnode *,
758 struct afs_server_list *, unsigned int);
759 extern void afs_put_cb_interest(struct afs_net *, struct afs_cb_interest *);
760 extern void afs_clear_callback_interests(struct afs_net *, struct afs_server_list *);
762 static inline struct afs_cb_interest *afs_get_cb_interest(struct afs_cb_interest *cbi)
765 refcount_inc(&cbi->usage);
769 static inline unsigned int afs_calc_vnode_cb_break(struct afs_vnode *vnode)
771 return vnode->cb_break + vnode->cb_s_break + vnode->cb_v_break;
774 static inline unsigned int afs_cb_break_sum(struct afs_vnode *vnode,
775 struct afs_cb_interest *cbi)
777 return vnode->cb_break + cbi->server->cb_s_break + vnode->volume->cb_v_break;
783 extern int afs_cell_init(struct afs_net *, const char *);
784 extern struct afs_cell *afs_lookup_cell_rcu(struct afs_net *, const char *, unsigned);
785 extern struct afs_cell *afs_lookup_cell(struct afs_net *, const char *, unsigned,
787 extern struct afs_cell *afs_get_cell(struct afs_cell *);
788 extern void afs_put_cell(struct afs_net *, struct afs_cell *);
789 extern void afs_manage_cells(struct work_struct *);
790 extern void afs_cells_timer(struct timer_list *);
791 extern void __net_exit afs_cell_purge(struct afs_net *);
796 extern bool afs_cm_incoming_call(struct afs_call *);
801 extern const struct file_operations afs_dir_file_operations;
802 extern const struct inode_operations afs_dir_inode_operations;
803 extern const struct address_space_operations afs_dir_aops;
804 extern const struct dentry_operations afs_fs_dentry_operations;
806 extern void afs_d_release(struct dentry *);
811 extern void afs_edit_dir_add(struct afs_vnode *, struct qstr *, struct afs_fid *,
812 enum afs_edit_dir_reason);
813 extern void afs_edit_dir_remove(struct afs_vnode *, struct qstr *, enum afs_edit_dir_reason);
818 extern const struct file_operations afs_dynroot_file_operations;
819 extern const struct inode_operations afs_dynroot_inode_operations;
820 extern const struct dentry_operations afs_dynroot_dentry_operations;
822 extern struct inode *afs_try_auto_mntpt(struct dentry *, struct inode *);
823 extern int afs_dynroot_mkdir(struct afs_net *, struct afs_cell *);
824 extern void afs_dynroot_rmdir(struct afs_net *, struct afs_cell *);
825 extern int afs_dynroot_populate(struct super_block *);
826 extern void afs_dynroot_depopulate(struct super_block *);
831 extern const struct address_space_operations afs_fs_aops;
832 extern const struct inode_operations afs_file_inode_operations;
833 extern const struct file_operations afs_file_operations;
835 extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *);
836 extern void afs_put_wb_key(struct afs_wb_key *);
837 extern int afs_open(struct inode *, struct file *);
838 extern int afs_release(struct inode *, struct file *);
839 extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *);
840 extern int afs_page_filler(void *, struct page *);
841 extern void afs_put_read(struct afs_read *);
846 extern struct workqueue_struct *afs_lock_manager;
848 extern void afs_lock_work(struct work_struct *);
849 extern void afs_lock_may_be_available(struct afs_vnode *);
850 extern int afs_lock(struct file *, int, struct file_lock *);
851 extern int afs_flock(struct file *, int, struct file_lock *);
856 #define AFS_VNODE_NOT_YET_SET 0x01
857 #define AFS_VNODE_META_CHANGED 0x02
858 #define AFS_VNODE_DATA_CHANGED 0x04
859 extern void afs_update_inode_from_status(struct afs_vnode *, struct afs_file_status *,
860 const afs_dataversion_t *, u8);
862 extern int afs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_volsync *, bool);
863 extern int afs_fs_give_up_callbacks(struct afs_net *, struct afs_server *);
864 extern int afs_fs_fetch_data(struct afs_fs_cursor *, struct afs_read *);
865 extern int afs_fs_create(struct afs_fs_cursor *, const char *, umode_t, u64,
866 struct afs_fid *, struct afs_file_status *, struct afs_callback *);
867 extern int afs_fs_remove(struct afs_fs_cursor *, const char *, bool, u64);
868 extern int afs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64);
869 extern int afs_fs_symlink(struct afs_fs_cursor *, const char *, const char *, u64,
870 struct afs_fid *, struct afs_file_status *);
871 extern int afs_fs_rename(struct afs_fs_cursor *, const char *,
872 struct afs_vnode *, const char *, u64, u64);
873 extern int afs_fs_store_data(struct afs_fs_cursor *, struct address_space *,
874 pgoff_t, pgoff_t, unsigned, unsigned);
875 extern int afs_fs_setattr(struct afs_fs_cursor *, struct iattr *);
876 extern int afs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *);
877 extern int afs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t);
878 extern int afs_fs_extend_lock(struct afs_fs_cursor *);
879 extern int afs_fs_release_lock(struct afs_fs_cursor *);
880 extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *,
881 struct afs_addr_cursor *, struct key *);
882 extern int afs_fs_get_capabilities(struct afs_net *, struct afs_server *,
883 struct afs_addr_cursor *, struct key *);
884 extern int afs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *,
885 struct afs_fid *, struct afs_file_status *,
886 struct afs_callback *, unsigned int,
887 struct afs_volsync *);
888 extern int afs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *,
889 struct afs_fid *, struct afs_file_status *,
890 struct afs_callback *, struct afs_volsync *);
895 extern int afs_fetch_status(struct afs_vnode *, struct key *, bool);
896 extern int afs_iget5_test(struct inode *, void *);
897 extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool);
898 extern struct inode *afs_iget(struct super_block *, struct key *,
899 struct afs_fid *, struct afs_file_status *,
900 struct afs_callback *,
901 struct afs_cb_interest *);
902 extern void afs_zap_data(struct afs_vnode *);
903 extern int afs_validate(struct afs_vnode *, struct key *);
904 extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int);
905 extern int afs_setattr(struct dentry *, struct iattr *);
906 extern void afs_evict_inode(struct inode *);
907 extern int afs_drop_inode(struct inode *);
912 extern struct workqueue_struct *afs_wq;
913 extern int afs_net_id;
915 static inline struct afs_net *afs_net(struct net *net)
917 return net_generic(net, afs_net_id);
920 static inline struct afs_net *afs_sb2net(struct super_block *sb)
922 return afs_net(AFS_FS_S(sb)->net_ns);
925 static inline struct afs_net *afs_d2net(struct dentry *dentry)
927 return afs_sb2net(dentry->d_sb);
930 static inline struct afs_net *afs_i2net(struct inode *inode)
932 return afs_sb2net(inode->i_sb);
935 static inline struct afs_net *afs_v2net(struct afs_vnode *vnode)
937 return afs_i2net(&vnode->vfs_inode);
940 static inline struct afs_net *afs_sock2net(struct sock *sk)
942 return net_generic(sock_net(sk), afs_net_id);
945 static inline void __afs_stat(atomic_t *s)
950 #define afs_stat_v(vnode, n) __afs_stat(&afs_v2net(vnode)->n)
955 extern int afs_abort_to_error(u32);
960 extern const struct inode_operations afs_mntpt_inode_operations;
961 extern const struct inode_operations afs_autocell_inode_operations;
962 extern const struct file_operations afs_mntpt_file_operations;
964 extern struct vfsmount *afs_d_automount(struct path *);
965 extern void afs_mntpt_kill_timer(void);
970 extern int afs_get_ipv4_interfaces(struct afs_net *, struct afs_interface *,
976 #ifdef CONFIG_PROC_FS
977 extern int __net_init afs_proc_init(struct afs_net *);
978 extern void __net_exit afs_proc_cleanup(struct afs_net *);
979 extern int afs_proc_cell_setup(struct afs_cell *);
980 extern void afs_proc_cell_remove(struct afs_cell *);
981 extern void afs_put_sysnames(struct afs_sysnames *);
983 static inline int afs_proc_init(struct afs_net *net) { return 0; }
984 static inline void afs_proc_cleanup(struct afs_net *net) {}
985 static inline int afs_proc_cell_setup(struct afs_cell *cell) { return 0; }
986 static inline void afs_proc_cell_remove(struct afs_cell *cell) {}
987 static inline void afs_put_sysnames(struct afs_sysnames *sysnames) {}
993 extern bool afs_begin_vnode_operation(struct afs_fs_cursor *, struct afs_vnode *,
995 extern bool afs_select_fileserver(struct afs_fs_cursor *);
996 extern bool afs_select_current_fileserver(struct afs_fs_cursor *);
997 extern int afs_end_vnode_operation(struct afs_fs_cursor *);
1002 extern struct workqueue_struct *afs_async_calls;
1004 extern int __net_init afs_open_socket(struct afs_net *);
1005 extern void __net_exit afs_close_socket(struct afs_net *);
1006 extern void afs_charge_preallocation(struct work_struct *);
1007 extern void afs_put_call(struct afs_call *);
1008 extern int afs_queue_call_work(struct afs_call *);
1009 extern long afs_make_call(struct afs_addr_cursor *, struct afs_call *, gfp_t, bool);
1010 extern struct afs_call *afs_alloc_flat_call(struct afs_net *,
1011 const struct afs_call_type *,
1013 extern void afs_flat_call_destructor(struct afs_call *);
1014 extern void afs_send_empty_reply(struct afs_call *);
1015 extern void afs_send_simple_reply(struct afs_call *, const void *, size_t);
1016 extern int afs_extract_data(struct afs_call *, bool);
1017 extern int afs_protocol_error(struct afs_call *, int, enum afs_eproto_cause);
1019 static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t size)
1021 call->kvec[0].iov_base = buf;
1022 call->kvec[0].iov_len = size;
1023 iov_iter_kvec(&call->iter, READ, call->kvec, 1, size);
1026 static inline void afs_extract_to_tmp(struct afs_call *call)
1028 afs_extract_begin(call, &call->tmp, sizeof(call->tmp));
1031 static inline void afs_extract_to_tmp64(struct afs_call *call)
1033 afs_extract_begin(call, &call->tmp64, sizeof(call->tmp64));
1036 static inline void afs_extract_discard(struct afs_call *call, size_t size)
1038 iov_iter_discard(&call->iter, READ, size);
1041 static inline void afs_extract_to_buf(struct afs_call *call, size_t size)
1043 afs_extract_begin(call, call->buffer, size);
1046 static inline int afs_transfer_reply(struct afs_call *call)
1048 return afs_extract_data(call, false);
1051 static inline bool afs_check_call_state(struct afs_call *call,
1052 enum afs_call_state state)
1054 return READ_ONCE(call->state) == state;
1057 static inline bool afs_set_call_state(struct afs_call *call,
1058 enum afs_call_state from,
1059 enum afs_call_state to)
1063 spin_lock_bh(&call->state_lock);
1064 if (call->state == from) {
1066 trace_afs_call_state(call, from, to, 0, 0);
1069 spin_unlock_bh(&call->state_lock);
1073 static inline void afs_set_call_complete(struct afs_call *call,
1074 int error, u32 remote_abort)
1076 enum afs_call_state state;
1079 spin_lock_bh(&call->state_lock);
1080 state = call->state;
1081 if (state != AFS_CALL_COMPLETE) {
1082 call->abort_code = remote_abort;
1083 call->error = error;
1084 call->state = AFS_CALL_COMPLETE;
1085 trace_afs_call_state(call, state, AFS_CALL_COMPLETE,
1086 error, remote_abort);
1089 spin_unlock_bh(&call->state_lock);
1091 trace_afs_call_done(call);
1097 extern void afs_put_permits(struct afs_permits *);
1098 extern void afs_clear_permits(struct afs_vnode *);
1099 extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int);
1100 extern void afs_zap_permits(struct rcu_head *);
1101 extern struct key *afs_request_key(struct afs_cell *);
1102 extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *);
1103 extern int afs_permission(struct inode *, int);
1104 extern void __exit afs_clean_up_permit_cache(void);
1109 extern spinlock_t afs_server_peer_lock;
1111 static inline struct afs_server *afs_get_server(struct afs_server *server)
1113 atomic_inc(&server->usage);
1117 extern struct afs_server *afs_find_server(struct afs_net *,
1118 const struct sockaddr_rxrpc *);
1119 extern struct afs_server *afs_find_server_by_uuid(struct afs_net *, const uuid_t *);
1120 extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *);
1121 extern void afs_put_server(struct afs_net *, struct afs_server *);
1122 extern void afs_manage_servers(struct work_struct *);
1123 extern void afs_servers_timer(struct timer_list *);
1124 extern void __net_exit afs_purge_servers(struct afs_net *);
1125 extern bool afs_probe_fileserver(struct afs_fs_cursor *);
1126 extern bool afs_check_server_record(struct afs_fs_cursor *, struct afs_server *);
1131 static inline struct afs_server_list *afs_get_serverlist(struct afs_server_list *slist)
1133 refcount_inc(&slist->usage);
1137 extern void afs_put_serverlist(struct afs_net *, struct afs_server_list *);
1138 extern struct afs_server_list *afs_alloc_server_list(struct afs_cell *, struct key *,
1139 struct afs_vldb_entry *,
1141 extern bool afs_annotate_server_list(struct afs_server_list *, struct afs_server_list *);
1146 extern int __init afs_fs_init(void);
1147 extern void afs_fs_exit(void);
1152 extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *,
1154 extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *, const uuid_t *);
1155 extern int afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *, struct key *);
1156 extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *, const uuid_t *);
1161 extern bool afs_begin_vlserver_operation(struct afs_vl_cursor *,
1162 struct afs_cell *, struct key *);
1163 extern bool afs_select_vlserver(struct afs_vl_cursor *);
1164 extern bool afs_select_current_vlserver(struct afs_vl_cursor *);
1165 extern int afs_end_vlserver_operation(struct afs_vl_cursor *);
1170 static inline struct afs_vlserver *afs_get_vlserver(struct afs_vlserver *vlserver)
1172 atomic_inc(&vlserver->usage);
1176 static inline struct afs_vlserver_list *afs_get_vlserverlist(struct afs_vlserver_list *vllist)
1179 atomic_inc(&vllist->usage);
1183 extern struct afs_vlserver *afs_alloc_vlserver(const char *, size_t, unsigned short);
1184 extern void afs_put_vlserver(struct afs_net *, struct afs_vlserver *);
1185 extern struct afs_vlserver_list *afs_alloc_vlserver_list(unsigned int);
1186 extern void afs_put_vlserverlist(struct afs_net *, struct afs_vlserver_list *);
1187 extern struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *,
1188 const void *, size_t);
1193 static inline struct afs_volume *__afs_get_volume(struct afs_volume *volume)
1196 atomic_inc(&volume->usage);
1200 extern struct afs_volume *afs_create_volume(struct afs_mount_params *);
1201 extern void afs_activate_volume(struct afs_volume *);
1202 extern void afs_deactivate_volume(struct afs_volume *);
1203 extern void afs_put_volume(struct afs_cell *, struct afs_volume *);
1204 extern int afs_check_volume_status(struct afs_volume *, struct key *);
1209 extern int afs_set_page_dirty(struct page *);
1210 extern int afs_write_begin(struct file *file, struct address_space *mapping,
1211 loff_t pos, unsigned len, unsigned flags,
1212 struct page **pagep, void **fsdata);
1213 extern int afs_write_end(struct file *file, struct address_space *mapping,
1214 loff_t pos, unsigned len, unsigned copied,
1215 struct page *page, void *fsdata);
1216 extern int afs_writepage(struct page *, struct writeback_control *);
1217 extern int afs_writepages(struct address_space *, struct writeback_control *);
1218 extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *);
1219 extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *);
1220 extern int afs_fsync(struct file *, loff_t, loff_t, int);
1221 extern vm_fault_t afs_page_mkwrite(struct vm_fault *vmf);
1222 extern void afs_prune_wb_keys(struct afs_vnode *);
1223 extern int afs_launder_page(struct page *);
1228 extern const struct xattr_handler *afs_xattr_handlers[];
1229 extern ssize_t afs_listxattr(struct dentry *, char *, size_t);
1233 * Miscellaneous inline functions.
1235 static inline struct afs_vnode *AFS_FS_I(struct inode *inode)
1237 return container_of(inode, struct afs_vnode, vfs_inode);
1240 static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode)
1242 return &vnode->vfs_inode;
1245 static inline void afs_vnode_commit_status(struct afs_fs_cursor *fc,
1246 struct afs_vnode *vnode,
1247 unsigned int cb_break)
1249 if (fc->ac.error == 0)
1250 afs_cache_permit(vnode, fc->key, cb_break);
1253 static inline void afs_check_for_remote_deletion(struct afs_fs_cursor *fc,
1254 struct afs_vnode *vnode)
1256 if (fc->ac.error == -ENOENT) {
1257 set_bit(AFS_VNODE_DELETED, &vnode->flags);
1258 afs_break_callback(vnode);
1262 static inline int afs_io_error(struct afs_call *call, enum afs_io_error where)
1264 trace_afs_io_error(call->debug_id, -EIO, where);
1268 static inline int afs_bad(struct afs_vnode *vnode, enum afs_file_error where)
1270 trace_afs_file_error(vnode, -EIO, where);
1274 /*****************************************************************************/
1278 extern unsigned afs_debug;
1280 #define dbgprintk(FMT,...) \
1281 printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
1283 #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
1284 #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
1285 #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__)
1288 #if defined(__KDEBUG)
1289 #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__)
1290 #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__)
1291 #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__)
1293 #elif defined(CONFIG_AFS_DEBUG)
1294 #define AFS_DEBUG_KENTER 0x01
1295 #define AFS_DEBUG_KLEAVE 0x02
1296 #define AFS_DEBUG_KDEBUG 0x04
1298 #define _enter(FMT,...) \
1300 if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \
1301 kenter(FMT,##__VA_ARGS__); \
1304 #define _leave(FMT,...) \
1306 if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \
1307 kleave(FMT,##__VA_ARGS__); \
1310 #define _debug(FMT,...) \
1312 if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \
1313 kdebug(FMT,##__VA_ARGS__); \
1317 #define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
1318 #define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
1319 #define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__)
1323 * debug assertion checking
1325 #if 1 // defined(__KDEBUGALL)
1329 if (unlikely(!(X))) { \
1330 printk(KERN_ERR "\n"); \
1331 printk(KERN_ERR "AFS: Assertion failed\n"); \
1336 #define ASSERTCMP(X, OP, Y) \
1338 if (unlikely(!((X) OP (Y)))) { \
1339 printk(KERN_ERR "\n"); \
1340 printk(KERN_ERR "AFS: Assertion failed\n"); \
1341 printk(KERN_ERR "%lu " #OP " %lu is false\n", \
1342 (unsigned long)(X), (unsigned long)(Y)); \
1343 printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
1344 (unsigned long)(X), (unsigned long)(Y)); \
1349 #define ASSERTRANGE(L, OP1, N, OP2, H) \
1351 if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \
1352 printk(KERN_ERR "\n"); \
1353 printk(KERN_ERR "AFS: Assertion failed\n"); \
1354 printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \
1355 (unsigned long)(L), (unsigned long)(N), \
1356 (unsigned long)(H)); \
1357 printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \
1358 (unsigned long)(L), (unsigned long)(N), \
1359 (unsigned long)(H)); \
1364 #define ASSERTIF(C, X) \
1366 if (unlikely((C) && !(X))) { \
1367 printk(KERN_ERR "\n"); \
1368 printk(KERN_ERR "AFS: Assertion failed\n"); \
1373 #define ASSERTIFCMP(C, X, OP, Y) \
1375 if (unlikely((C) && !((X) OP (Y)))) { \
1376 printk(KERN_ERR "\n"); \
1377 printk(KERN_ERR "AFS: Assertion failed\n"); \
1378 printk(KERN_ERR "%lu " #OP " %lu is false\n", \
1379 (unsigned long)(X), (unsigned long)(Y)); \
1380 printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
1381 (unsigned long)(X), (unsigned long)(Y)); \
1392 #define ASSERTCMP(X, OP, Y) \
1396 #define ASSERTRANGE(L, OP1, N, OP2, H) \
1400 #define ASSERTIF(C, X) \
1404 #define ASSERTIFCMP(C, X, OP, Y) \
1408 #endif /* __KDEBUGALL */