1
2
3
4
5
6
7
8
9
10
11
12#include <linux/compiler.h>
13#include <linux/kernel.h>
14#include <linux/ktime.h>
15#include <linux/fs.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>
28#include <net/sock.h>
29#include <net/af_rxrpc.h>
30
31#include "afs.h"
32#include "afs_vl.h"
33
34#define AFS_CELL_MAX_ADDRS 15
35
36struct pagevec;
37struct afs_call;
38
39struct afs_mount_params {
40 bool rwpath;
41 bool force;
42 bool autocell;
43 bool dyn_root;
44 afs_voltype_t type;
45 int volnamesz;
46 const char *volname;
47 struct net *net_ns;
48 struct afs_net *net;
49 struct afs_cell *cell;
50 struct afs_volume *volume;
51 struct key *key;
52};
53
54struct afs_iget_data {
55 struct afs_fid fid;
56 struct afs_volume *volume;
57};
58
59enum afs_call_state {
60 AFS_CALL_CL_REQUESTING,
61 AFS_CALL_CL_AWAIT_REPLY,
62 AFS_CALL_CL_PROC_REPLY,
63 AFS_CALL_SV_AWAIT_OP_ID,
64 AFS_CALL_SV_AWAIT_REQUEST,
65 AFS_CALL_SV_REPLYING,
66 AFS_CALL_SV_AWAIT_ACK,
67 AFS_CALL_COMPLETE,
68};
69
70
71
72
73struct afs_addr_list {
74 struct rcu_head rcu;
75 refcount_t usage;
76 u32 version;
77 unsigned char max_addrs;
78 unsigned char nr_addrs;
79 unsigned char preferred;
80 unsigned char nr_ipv4;
81 enum dns_record_source source:8;
82 enum dns_lookup_status status:8;
83 unsigned long probed;
84 unsigned long failed;
85 unsigned long responded;
86 struct sockaddr_rxrpc addrs[];
87#define AFS_MAX_ADDRESSES ((unsigned int)(sizeof(unsigned long) * 8))
88};
89
90
91
92
93struct afs_call {
94 const struct afs_call_type *type;
95 struct afs_addr_list *alist;
96 wait_queue_head_t waitq;
97 struct work_struct async_work;
98 struct work_struct work;
99 struct rxrpc_call *rxcall;
100 struct key *key;
101 struct afs_net *net;
102 struct afs_server *cm_server;
103 struct afs_cb_interest *cbi;
104 void *request;
105 struct address_space *mapping;
106 struct iov_iter iter;
107 struct iov_iter *_iter;
108 union {
109 struct kvec kvec[1];
110 struct bio_vec bvec[1];
111 };
112 void *buffer;
113 void *reply[4];
114 pgoff_t first;
115 pgoff_t last;
116 atomic_t usage;
117 enum afs_call_state state;
118 spinlock_t state_lock;
119 int error;
120 u32 abort_code;
121 u32 epoch;
122 unsigned request_size;
123 unsigned reply_max;
124 unsigned first_offset;
125 unsigned int cb_break;
126 union {
127 unsigned last_to;
128 unsigned count2;
129 };
130 unsigned char unmarshall;
131 unsigned char addr_ix;
132 bool incoming;
133 bool send_pages;
134 bool need_attention;
135 bool async;
136 bool ret_reply0;
137 bool upgrade;
138 bool want_reply_time;
139 u16 service_id;
140 unsigned int debug_id;
141 u32 operation_ID;
142 u32 count;
143 union {
144 struct {
145 __be32 tmp_u;
146 __be32 tmp;
147 } __attribute__((packed));
148 __be64 tmp64;
149 };
150 afs_dataversion_t expected_version;
151 afs_dataversion_t expected_version_2;
152 ktime_t reply_time;
153};
154
155struct afs_call_type {
156 const char *name;
157 unsigned int op;
158
159
160
161
162 int (*deliver)(struct afs_call *call);
163
164
165 void (*destructor)(struct afs_call *call);
166
167
168 void (*work)(struct work_struct *work);
169
170
171 void (*done)(struct afs_call *call);
172};
173
174
175
176
177struct afs_wb_key {
178 refcount_t usage;
179 struct key *key;
180 struct list_head vnode_link;
181};
182
183
184
185
186struct afs_file {
187 struct key *key;
188 struct afs_wb_key *wb;
189};
190
191static inline struct key *afs_file_key(struct file *file)
192{
193 struct afs_file *af = file->private_data;
194
195 return af->key;
196}
197
198
199
200
201struct afs_read {
202 loff_t pos;
203 loff_t len;
204 loff_t actual_len;
205 loff_t remain;
206 loff_t file_size;
207 afs_dataversion_t data_version;
208 refcount_t usage;
209 unsigned int index;
210 unsigned int nr_pages;
211 unsigned int offset;
212 void (*page_done)(struct afs_call *, struct afs_read *);
213 struct page **pages;
214 struct page *array[];
215};
216
217
218
219
220
221struct afs_super_info {
222 struct net *net_ns;
223 struct afs_cell *cell;
224 struct afs_volume *volume;
225 bool dyn_root;
226};
227
228static inline struct afs_super_info *AFS_FS_S(struct super_block *sb)
229{
230 return sb->s_fs_info;
231}
232
233extern struct file_system_type afs_fs_type;
234
235
236
237
238struct afs_sysnames {
239#define AFS_NR_SYSNAME 16
240 char *subs[AFS_NR_SYSNAME];
241 refcount_t usage;
242 unsigned short nr;
243 char blank[1];
244};
245
246
247
248
249struct afs_net {
250 struct net *net;
251 struct afs_uuid uuid;
252 bool live;
253
254
255 struct socket *socket;
256 struct afs_call *spare_incoming_call;
257 struct work_struct charge_preallocation_work;
258 struct mutex socket_mutex;
259 atomic_t nr_outstanding_calls;
260 atomic_t nr_superblocks;
261
262
263 struct rb_root cells;
264 struct afs_cell __rcu *ws_cell;
265 struct work_struct cells_manager;
266 struct timer_list cells_timer;
267 atomic_t cells_outstanding;
268 seqlock_t cells_lock;
269
270 struct mutex proc_cells_lock;
271 struct hlist_head proc_cells;
272
273
274
275
276
277 seqlock_t fs_lock;
278 struct rb_root fs_servers;
279 struct list_head fs_updates;
280 struct hlist_head fs_proc;
281
282 struct hlist_head fs_addresses4;
283 struct hlist_head fs_addresses6;
284 seqlock_t fs_addr_lock;
285
286 struct work_struct fs_manager;
287 struct timer_list fs_timer;
288 atomic_t servers_outstanding;
289
290
291 struct mutex lock_manager_mutex;
292
293
294 struct super_block *dynroot_sb;
295 struct proc_dir_entry *proc_afs;
296 struct afs_sysnames *sysnames;
297 rwlock_t sysnames_lock;
298
299
300 atomic_t n_lookup;
301 atomic_t n_reval;
302 atomic_t n_inval;
303 atomic_t n_relpg;
304 atomic_t n_read_dir;
305 atomic_t n_dir_cr;
306 atomic_t n_dir_rm;
307 atomic_t n_stores;
308 atomic_long_t n_store_bytes;
309 atomic_long_t n_fetch_bytes;
310 atomic_t n_fetches;
311};
312
313extern const char afs_init_sysname[];
314
315enum afs_cell_state {
316 AFS_CELL_UNSET,
317 AFS_CELL_ACTIVATING,
318 AFS_CELL_ACTIVE,
319 AFS_CELL_DEACTIVATING,
320 AFS_CELL_INACTIVE,
321 AFS_CELL_FAILED,
322};
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341struct afs_cell {
342 union {
343 struct rcu_head rcu;
344 struct rb_node net_node;
345 };
346 struct afs_net *net;
347 struct key *anonymous_key;
348 struct work_struct manager;
349 struct hlist_node proc_link;
350#ifdef CONFIG_AFS_FSCACHE
351 struct fscache_cookie *cache;
352#endif
353 time64_t dns_expiry;
354 time64_t last_inactive;
355 atomic_t usage;
356 unsigned long flags;
357#define AFS_CELL_FL_NOT_READY 0
358#define AFS_CELL_FL_NO_GC 1
359#define AFS_CELL_FL_NOT_FOUND 2
360#define AFS_CELL_FL_DNS_FAIL 3
361#define AFS_CELL_FL_NO_LOOKUP_YET 4
362 enum afs_cell_state state;
363 short error;
364
365
366 struct list_head proc_volumes;
367 rwlock_t proc_lock;
368
369
370 rwlock_t vl_servers_lock;
371 struct afs_vlserver_list __rcu *vl_servers;
372
373 u8 name_len;
374 char name[64 + 1];
375};
376
377
378
379
380struct afs_vlserver {
381 struct rcu_head rcu;
382 struct afs_addr_list __rcu *addresses;
383 unsigned long flags;
384#define AFS_VLSERVER_FL_PROBED 0
385#define AFS_VLSERVER_FL_PROBING 1
386#define AFS_VLSERVER_FL_IS_YFS 2
387 rwlock_t lock;
388 atomic_t usage;
389
390
391 wait_queue_head_t probe_wq;
392 atomic_t probe_outstanding;
393 spinlock_t probe_lock;
394 struct {
395 unsigned int rtt;
396 u32 abort_code;
397 short error;
398 bool have_result;
399 bool responded:1;
400 bool is_yfs:1;
401 bool not_yfs:1;
402 bool local_failure:1;
403 } probe;
404
405 u16 port;
406 u16 name_len;
407 char name[];
408};
409
410
411
412
413struct afs_vlserver_entry {
414 u16 priority;
415 u16 weight;
416 enum dns_record_source source:8;
417 enum dns_lookup_status status:8;
418 struct afs_vlserver *server;
419};
420
421struct afs_vlserver_list {
422 struct rcu_head rcu;
423 atomic_t usage;
424 u8 nr_servers;
425 u8 index;
426 u8 preferred;
427 enum dns_record_source source:8;
428 enum dns_lookup_status status:8;
429 rwlock_t lock;
430 struct afs_vlserver_entry servers[];
431};
432
433
434
435
436
437
438struct afs_vldb_entry {
439 afs_volid_t vid[3];
440
441 unsigned long flags;
442#define AFS_VLDB_HAS_RW 0
443#define AFS_VLDB_HAS_RO 1
444#define AFS_VLDB_HAS_BAK 2
445#define AFS_VLDB_QUERY_VALID 3
446#define AFS_VLDB_QUERY_ERROR 4
447
448 uuid_t fs_server[AFS_NMAXNSERVERS];
449 u8 fs_mask[AFS_NMAXNSERVERS];
450#define AFS_VOL_VTM_RW 0x01
451#define AFS_VOL_VTM_RO 0x02
452#define AFS_VOL_VTM_BAK 0x04
453 short error;
454 u8 nr_servers;
455 u8 name_len;
456 u8 name[AFS_MAXVOLNAME + 1];
457};
458
459
460
461
462struct afs_server {
463 struct rcu_head rcu;
464 union {
465 uuid_t uuid;
466 struct afs_uuid _uuid;
467 };
468
469 struct afs_addr_list __rcu *addresses;
470 struct rb_node uuid_rb;
471 struct hlist_node addr4_link;
472 struct hlist_node addr6_link;
473 struct hlist_node proc_link;
474 struct afs_server *gc_next;
475 time64_t put_time;
476 time64_t update_at;
477 unsigned long flags;
478#define AFS_SERVER_FL_NEW 0
479#define AFS_SERVER_FL_NOT_READY 1
480#define AFS_SERVER_FL_NOT_FOUND 2
481#define AFS_SERVER_FL_VL_FAIL 3
482#define AFS_SERVER_FL_UPDATING 4
483#define AFS_SERVER_FL_PROBED 5
484#define AFS_SERVER_FL_PROBING 6
485#define AFS_SERVER_FL_NO_IBULK 7
486#define AFS_SERVER_FL_MAY_HAVE_CB 8
487#define AFS_SERVER_FL_IS_YFS 9
488#define AFS_SERVER_FL_NO_RM2 10
489#define AFS_SERVER_FL_HAVE_EPOCH 11
490 atomic_t usage;
491 u32 addr_version;
492 u32 cm_epoch;
493
494
495 rwlock_t fs_lock;
496
497
498 struct hlist_head cb_volumes;
499 unsigned cb_s_break;
500 rwlock_t cb_break_lock;
501
502
503 wait_queue_head_t probe_wq;
504 atomic_t probe_outstanding;
505 spinlock_t probe_lock;
506 struct {
507 unsigned int rtt;
508 u32 abort_code;
509 u32 cm_epoch;
510 short error;
511 bool have_result;
512 bool responded:1;
513 bool is_yfs:1;
514 bool not_yfs:1;
515 bool local_failure:1;
516 bool no_epoch:1;
517 bool cm_probed:1;
518 bool said_rebooted:1;
519 bool said_inconsistent:1;
520 } probe;
521};
522
523
524
525
526struct afs_vol_interest {
527 struct hlist_node srv_link;
528 struct hlist_head cb_interests;
529 afs_volid_t vid;
530 unsigned int usage;
531};
532
533
534
535
536struct afs_cb_interest {
537 struct hlist_node cb_vlink;
538 struct afs_vol_interest *vol_interest;
539 struct afs_server *server;
540 struct super_block *sb;
541 afs_volid_t vid;
542 refcount_t usage;
543};
544
545
546
547
548struct afs_server_entry {
549 struct afs_server *server;
550 struct afs_cb_interest *cb_interest;
551};
552
553struct afs_server_list {
554 refcount_t usage;
555 unsigned char nr_servers;
556 unsigned char preferred;
557 unsigned short vnovol_mask;
558 unsigned int seq;
559 rwlock_t lock;
560 struct afs_server_entry servers[];
561};
562
563
564
565
566struct afs_volume {
567 afs_volid_t vid;
568 atomic_t usage;
569 time64_t update_at;
570 struct afs_cell *cell;
571 struct list_head proc_link;
572 unsigned long flags;
573#define AFS_VOLUME_NEEDS_UPDATE 0
574#define AFS_VOLUME_UPDATING 1
575#define AFS_VOLUME_WAIT 2
576#define AFS_VOLUME_DELETED 3
577#define AFS_VOLUME_OFFLINE 4
578#define AFS_VOLUME_BUSY 5
579#ifdef CONFIG_AFS_FSCACHE
580 struct fscache_cookie *cache;
581#endif
582 struct afs_server_list *servers;
583 rwlock_t servers_lock;
584 unsigned int servers_seq;
585
586 unsigned cb_v_break;
587 rwlock_t cb_break_lock;
588
589 afs_voltype_t type;
590 short error;
591 char type_force;
592 u8 name_len;
593 u8 name[AFS_MAXVOLNAME + 1];
594};
595
596enum afs_lock_state {
597 AFS_VNODE_LOCK_NONE,
598 AFS_VNODE_LOCK_WAITING_FOR_CB,
599 AFS_VNODE_LOCK_SETTING,
600 AFS_VNODE_LOCK_GRANTED,
601 AFS_VNODE_LOCK_EXTENDING,
602 AFS_VNODE_LOCK_NEED_UNLOCK,
603 AFS_VNODE_LOCK_UNLOCKING,
604};
605
606
607
608
609
610
611
612struct afs_vnode {
613 struct inode vfs_inode;
614
615 struct afs_volume *volume;
616 struct afs_fid fid;
617 struct afs_file_status status;
618 afs_dataversion_t invalid_before;
619#ifdef CONFIG_AFS_FSCACHE
620 struct fscache_cookie *cache;
621#endif
622 struct afs_permits __rcu *permit_cache;
623 struct mutex io_lock;
624 struct rw_semaphore validate_lock;
625 spinlock_t wb_lock;
626 spinlock_t lock;
627 unsigned long flags;
628#define AFS_VNODE_CB_PROMISED 0
629#define AFS_VNODE_UNSET 1
630#define AFS_VNODE_DIR_VALID 2
631#define AFS_VNODE_ZAP_DATA 3
632#define AFS_VNODE_DELETED 4
633#define AFS_VNODE_MOUNTPOINT 5
634#define AFS_VNODE_AUTOCELL 6
635#define AFS_VNODE_PSEUDODIR 7
636#define AFS_VNODE_NEW_CONTENT 8
637
638 struct list_head wb_keys;
639 struct list_head pending_locks;
640 struct list_head granted_locks;
641 struct delayed_work lock_work;
642 struct key *lock_key;
643 enum afs_lock_state lock_state : 8;
644 afs_lock_type_t lock_type : 8;
645
646
647 struct afs_cb_interest *cb_interest;
648 unsigned int cb_s_break;
649 unsigned int cb_v_break;
650 unsigned int cb_break;
651 seqlock_t cb_lock;
652
653 time64_t cb_expires_at;
654 unsigned cb_version;
655 afs_callback_type_t cb_type;
656};
657
658static inline struct fscache_cookie *afs_vnode_cache(struct afs_vnode *vnode)
659{
660#ifdef CONFIG_AFS_FSCACHE
661 return vnode->cache;
662#else
663 return NULL;
664#endif
665}
666
667
668
669
670struct afs_permit {
671 struct key *key;
672 afs_access_t access;
673};
674
675
676
677
678
679struct afs_permits {
680 struct rcu_head rcu;
681 struct hlist_node hash_node;
682 unsigned long h;
683 refcount_t usage;
684 unsigned short nr_permits;
685 bool invalidated;
686 struct afs_permit permits[];
687};
688
689
690
691
692struct afs_interface {
693 struct in_addr address;
694 struct in_addr netmask;
695 unsigned mtu;
696};
697
698
699
700
701struct afs_error {
702 short error;
703 bool responded;
704};
705
706
707
708
709struct afs_addr_cursor {
710 struct afs_addr_list *alist;
711 unsigned long tried;
712 signed char index;
713 bool responded;
714 unsigned short nr_iterations;
715 short error;
716 u32 abort_code;
717};
718
719
720
721
722struct afs_vl_cursor {
723 struct afs_addr_cursor ac;
724 struct afs_cell *cell;
725 struct afs_vlserver_list *server_list;
726 struct afs_vlserver *server;
727 struct key *key;
728 unsigned long untried;
729 short index;
730 short error;
731 unsigned short flags;
732#define AFS_VL_CURSOR_STOP 0x0001
733#define AFS_VL_CURSOR_RETRY 0x0002
734#define AFS_VL_CURSOR_RETRIED 0x0004
735 unsigned short nr_iterations;
736};
737
738
739
740
741struct afs_fs_cursor {
742 struct afs_addr_cursor ac;
743 struct afs_vnode *vnode;
744 struct afs_server_list *server_list;
745 struct afs_cb_interest *cbi;
746 struct key *key;
747 unsigned long untried;
748 unsigned int cb_break;
749 unsigned int cb_break_2;
750 short index;
751 short error;
752 unsigned short flags;
753#define AFS_FS_CURSOR_STOP 0x0001
754#define AFS_FS_CURSOR_VBUSY 0x0002
755#define AFS_FS_CURSOR_VMOVED 0x0004
756#define AFS_FS_CURSOR_VNOVOL 0x0008
757#define AFS_FS_CURSOR_CUR_ONLY 0x0010
758#define AFS_FS_CURSOR_NO_VSLEEP 0x0020
759 unsigned short nr_iterations;
760};
761
762
763
764
765struct afs_vnode_cache_aux {
766 u64 data_version;
767} __packed;
768
769#include <trace/events/afs.h>
770
771
772
773
774
775static inline struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist)
776{
777 if (alist)
778 refcount_inc(&alist->usage);
779 return alist;
780}
781extern struct afs_addr_list *afs_alloc_addrlist(unsigned int,
782 unsigned short,
783 unsigned short);
784extern void afs_put_addrlist(struct afs_addr_list *);
785extern struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *,
786 const char *, size_t, char,
787 unsigned short, unsigned short);
788extern struct afs_vlserver_list *afs_dns_query(struct afs_cell *, time64_t *);
789extern bool afs_iterate_addresses(struct afs_addr_cursor *);
790extern int afs_end_cursor(struct afs_addr_cursor *);
791
792extern void afs_merge_fs_addr4(struct afs_addr_list *, __be32, u16);
793extern void afs_merge_fs_addr6(struct afs_addr_list *, __be32 *, u16);
794
795
796
797
798#ifdef CONFIG_AFS_FSCACHE
799extern struct fscache_netfs afs_cache_netfs;
800extern struct fscache_cookie_def afs_cell_cache_index_def;
801extern struct fscache_cookie_def afs_volume_cache_index_def;
802extern struct fscache_cookie_def afs_vnode_cache_index_def;
803#else
804#define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL)
805#define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL)
806#define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL)
807#endif
808
809
810
811
812extern void afs_init_callback_state(struct afs_server *);
813extern void __afs_break_callback(struct afs_vnode *);
814extern void afs_break_callback(struct afs_vnode *);
815extern void afs_break_callbacks(struct afs_server *, size_t, struct afs_callback_break*);
816
817extern int afs_register_server_cb_interest(struct afs_vnode *,
818 struct afs_server_list *, unsigned int);
819extern void afs_put_cb_interest(struct afs_net *, struct afs_cb_interest *);
820extern void afs_clear_callback_interests(struct afs_net *, struct afs_server_list *);
821
822static inline struct afs_cb_interest *afs_get_cb_interest(struct afs_cb_interest *cbi)
823{
824 if (cbi)
825 refcount_inc(&cbi->usage);
826 return cbi;
827}
828
829static inline unsigned int afs_calc_vnode_cb_break(struct afs_vnode *vnode)
830{
831 return vnode->cb_break + vnode->cb_s_break + vnode->cb_v_break;
832}
833
834static inline bool afs_cb_is_broken(unsigned int cb_break,
835 const struct afs_vnode *vnode,
836 const struct afs_cb_interest *cbi)
837{
838 return !cbi || cb_break != (vnode->cb_break +
839 cbi->server->cb_s_break +
840 vnode->volume->cb_v_break);
841}
842
843
844
845
846extern int afs_cell_init(struct afs_net *, const char *);
847extern struct afs_cell *afs_lookup_cell_rcu(struct afs_net *, const char *, unsigned);
848extern struct afs_cell *afs_lookup_cell(struct afs_net *, const char *, unsigned,
849 const char *, bool);
850extern struct afs_cell *afs_get_cell(struct afs_cell *);
851extern void afs_put_cell(struct afs_net *, struct afs_cell *);
852extern void afs_manage_cells(struct work_struct *);
853extern void afs_cells_timer(struct timer_list *);
854extern void __net_exit afs_cell_purge(struct afs_net *);
855
856
857
858
859extern bool afs_cm_incoming_call(struct afs_call *);
860
861
862
863
864extern const struct file_operations afs_dir_file_operations;
865extern const struct inode_operations afs_dir_inode_operations;
866extern const struct address_space_operations afs_dir_aops;
867extern const struct dentry_operations afs_fs_dentry_operations;
868
869extern void afs_d_release(struct dentry *);
870
871
872
873
874extern void afs_edit_dir_add(struct afs_vnode *, struct qstr *, struct afs_fid *,
875 enum afs_edit_dir_reason);
876extern void afs_edit_dir_remove(struct afs_vnode *, struct qstr *, enum afs_edit_dir_reason);
877
878
879
880
881extern const struct file_operations afs_dynroot_file_operations;
882extern const struct inode_operations afs_dynroot_inode_operations;
883extern const struct dentry_operations afs_dynroot_dentry_operations;
884
885extern struct inode *afs_try_auto_mntpt(struct dentry *, struct inode *);
886extern int afs_dynroot_mkdir(struct afs_net *, struct afs_cell *);
887extern void afs_dynroot_rmdir(struct afs_net *, struct afs_cell *);
888extern int afs_dynroot_populate(struct super_block *);
889extern void afs_dynroot_depopulate(struct super_block *);
890
891
892
893
894extern const struct address_space_operations afs_fs_aops;
895extern const struct inode_operations afs_file_inode_operations;
896extern const struct file_operations afs_file_operations;
897
898extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *);
899extern void afs_put_wb_key(struct afs_wb_key *);
900extern int afs_open(struct inode *, struct file *);
901extern int afs_release(struct inode *, struct file *);
902extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *);
903extern int afs_page_filler(void *, struct page *);
904extern void afs_put_read(struct afs_read *);
905
906
907
908
909extern struct workqueue_struct *afs_lock_manager;
910
911extern void afs_lock_work(struct work_struct *);
912extern void afs_lock_may_be_available(struct afs_vnode *);
913extern int afs_lock(struct file *, int, struct file_lock *);
914extern int afs_flock(struct file *, int, struct file_lock *);
915
916
917
918
919#define AFS_VNODE_NOT_YET_SET 0x01
920#define AFS_VNODE_META_CHANGED 0x02
921#define AFS_VNODE_DATA_CHANGED 0x04
922extern void afs_update_inode_from_status(struct afs_vnode *, struct afs_file_status *,
923 const afs_dataversion_t *, u8);
924
925extern int afs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_volsync *, bool);
926extern int afs_fs_give_up_callbacks(struct afs_net *, struct afs_server *);
927extern int afs_fs_fetch_data(struct afs_fs_cursor *, struct afs_read *);
928extern int afs_fs_create(struct afs_fs_cursor *, const char *, umode_t, u64,
929 struct afs_fid *, struct afs_file_status *, struct afs_callback *);
930extern int afs_fs_remove(struct afs_fs_cursor *, struct afs_vnode *, const char *, bool, u64);
931extern int afs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64);
932extern int afs_fs_symlink(struct afs_fs_cursor *, const char *, const char *, u64,
933 struct afs_fid *, struct afs_file_status *);
934extern int afs_fs_rename(struct afs_fs_cursor *, const char *,
935 struct afs_vnode *, const char *, u64, u64);
936extern int afs_fs_store_data(struct afs_fs_cursor *, struct address_space *,
937 pgoff_t, pgoff_t, unsigned, unsigned);
938extern int afs_fs_setattr(struct afs_fs_cursor *, struct iattr *);
939extern int afs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *);
940extern int afs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t);
941extern int afs_fs_extend_lock(struct afs_fs_cursor *);
942extern int afs_fs_release_lock(struct afs_fs_cursor *);
943extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *,
944 struct afs_addr_cursor *, struct key *);
945extern int afs_fs_get_capabilities(struct afs_net *, struct afs_server *,
946 struct afs_addr_cursor *, struct key *, unsigned int, bool);
947extern int afs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *,
948 struct afs_fid *, struct afs_file_status *,
949 struct afs_callback *, unsigned int,
950 struct afs_volsync *);
951extern int afs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *,
952 struct afs_fid *, struct afs_file_status *,
953 struct afs_callback *, struct afs_volsync *);
954
955
956
957
958extern void afs_fileserver_probe_result(struct afs_call *);
959extern int afs_probe_fileservers(struct afs_net *, struct key *, struct afs_server_list *);
960extern int afs_wait_for_fs_probes(struct afs_server_list *, unsigned long);
961
962
963
964
965extern int afs_fetch_status(struct afs_vnode *, struct key *, bool);
966extern int afs_iget5_test(struct inode *, void *);
967extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool);
968extern struct inode *afs_iget(struct super_block *, struct key *,
969 struct afs_fid *, struct afs_file_status *,
970 struct afs_callback *,
971 struct afs_cb_interest *);
972extern void afs_zap_data(struct afs_vnode *);
973extern int afs_validate(struct afs_vnode *, struct key *);
974extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int);
975extern int afs_setattr(struct dentry *, struct iattr *);
976extern void afs_evict_inode(struct inode *);
977extern int afs_drop_inode(struct inode *);
978
979
980
981
982extern struct workqueue_struct *afs_wq;
983extern int afs_net_id;
984
985static inline struct afs_net *afs_net(struct net *net)
986{
987 return net_generic(net, afs_net_id);
988}
989
990static inline struct afs_net *afs_sb2net(struct super_block *sb)
991{
992 return afs_net(AFS_FS_S(sb)->net_ns);
993}
994
995static inline struct afs_net *afs_d2net(struct dentry *dentry)
996{
997 return afs_sb2net(dentry->d_sb);
998}
999
1000static inline struct afs_net *afs_i2net(struct inode *inode)
1001{
1002 return afs_sb2net(inode->i_sb);
1003}
1004
1005static inline struct afs_net *afs_v2net(struct afs_vnode *vnode)
1006{
1007 return afs_i2net(&vnode->vfs_inode);
1008}
1009
1010static inline struct afs_net *afs_sock2net(struct sock *sk)
1011{
1012 return net_generic(sock_net(sk), afs_net_id);
1013}
1014
1015static inline void __afs_stat(atomic_t *s)
1016{
1017 atomic_inc(s);
1018}
1019
1020#define afs_stat_v(vnode, n) __afs_stat(&afs_v2net(vnode)->n)
1021
1022
1023
1024
1025extern int afs_abort_to_error(u32);
1026extern void afs_prioritise_error(struct afs_error *, int, u32);
1027
1028
1029
1030
1031extern const struct inode_operations afs_mntpt_inode_operations;
1032extern const struct inode_operations afs_autocell_inode_operations;
1033extern const struct file_operations afs_mntpt_file_operations;
1034
1035extern struct vfsmount *afs_d_automount(struct path *);
1036extern void afs_mntpt_kill_timer(void);
1037
1038
1039
1040
1041extern int afs_get_ipv4_interfaces(struct afs_net *, struct afs_interface *,
1042 size_t, bool);
1043
1044
1045
1046
1047#ifdef CONFIG_PROC_FS
1048extern int __net_init afs_proc_init(struct afs_net *);
1049extern void __net_exit afs_proc_cleanup(struct afs_net *);
1050extern int afs_proc_cell_setup(struct afs_cell *);
1051extern void afs_proc_cell_remove(struct afs_cell *);
1052extern void afs_put_sysnames(struct afs_sysnames *);
1053#else
1054static inline int afs_proc_init(struct afs_net *net) { return 0; }
1055static inline void afs_proc_cleanup(struct afs_net *net) {}
1056static inline int afs_proc_cell_setup(struct afs_cell *cell) { return 0; }
1057static inline void afs_proc_cell_remove(struct afs_cell *cell) {}
1058static inline void afs_put_sysnames(struct afs_sysnames *sysnames) {}
1059#endif
1060
1061
1062
1063
1064extern bool afs_begin_vnode_operation(struct afs_fs_cursor *, struct afs_vnode *,
1065 struct key *);
1066extern bool afs_select_fileserver(struct afs_fs_cursor *);
1067extern bool afs_select_current_fileserver(struct afs_fs_cursor *);
1068extern int afs_end_vnode_operation(struct afs_fs_cursor *);
1069
1070
1071
1072
1073extern struct workqueue_struct *afs_async_calls;
1074
1075extern int __net_init afs_open_socket(struct afs_net *);
1076extern void __net_exit afs_close_socket(struct afs_net *);
1077extern void afs_charge_preallocation(struct work_struct *);
1078extern void afs_put_call(struct afs_call *);
1079extern long afs_make_call(struct afs_addr_cursor *, struct afs_call *, gfp_t, bool);
1080extern struct afs_call *afs_alloc_flat_call(struct afs_net *,
1081 const struct afs_call_type *,
1082 size_t, size_t);
1083extern void afs_flat_call_destructor(struct afs_call *);
1084extern void afs_send_empty_reply(struct afs_call *);
1085extern void afs_send_simple_reply(struct afs_call *, const void *, size_t);
1086extern int afs_extract_data(struct afs_call *, bool);
1087extern int afs_protocol_error(struct afs_call *, int, enum afs_eproto_cause);
1088
1089static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t size)
1090{
1091 call->kvec[0].iov_base = buf;
1092 call->kvec[0].iov_len = size;
1093 iov_iter_kvec(&call->iter, READ, call->kvec, 1, size);
1094}
1095
1096static inline void afs_extract_to_tmp(struct afs_call *call)
1097{
1098 afs_extract_begin(call, &call->tmp, sizeof(call->tmp));
1099}
1100
1101static inline void afs_extract_to_tmp64(struct afs_call *call)
1102{
1103 afs_extract_begin(call, &call->tmp64, sizeof(call->tmp64));
1104}
1105
1106static inline void afs_extract_discard(struct afs_call *call, size_t size)
1107{
1108 iov_iter_discard(&call->iter, READ, size);
1109}
1110
1111static inline void afs_extract_to_buf(struct afs_call *call, size_t size)
1112{
1113 afs_extract_begin(call, call->buffer, size);
1114}
1115
1116static inline int afs_transfer_reply(struct afs_call *call)
1117{
1118 return afs_extract_data(call, false);
1119}
1120
1121static inline bool afs_check_call_state(struct afs_call *call,
1122 enum afs_call_state state)
1123{
1124 return READ_ONCE(call->state) == state;
1125}
1126
1127static inline bool afs_set_call_state(struct afs_call *call,
1128 enum afs_call_state from,
1129 enum afs_call_state to)
1130{
1131 bool ok = false;
1132
1133 spin_lock_bh(&call->state_lock);
1134 if (call->state == from) {
1135 call->state = to;
1136 trace_afs_call_state(call, from, to, 0, 0);
1137 ok = true;
1138 }
1139 spin_unlock_bh(&call->state_lock);
1140 return ok;
1141}
1142
1143static inline void afs_set_call_complete(struct afs_call *call,
1144 int error, u32 remote_abort)
1145{
1146 enum afs_call_state state;
1147 bool ok = false;
1148
1149 spin_lock_bh(&call->state_lock);
1150 state = call->state;
1151 if (state != AFS_CALL_COMPLETE) {
1152 call->abort_code = remote_abort;
1153 call->error = error;
1154 call->state = AFS_CALL_COMPLETE;
1155 trace_afs_call_state(call, state, AFS_CALL_COMPLETE,
1156 error, remote_abort);
1157 ok = true;
1158 }
1159 spin_unlock_bh(&call->state_lock);
1160 if (ok)
1161 trace_afs_call_done(call);
1162}
1163
1164
1165
1166
1167extern void afs_put_permits(struct afs_permits *);
1168extern void afs_clear_permits(struct afs_vnode *);
1169extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int);
1170extern void afs_zap_permits(struct rcu_head *);
1171extern struct key *afs_request_key(struct afs_cell *);
1172extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *);
1173extern int afs_permission(struct inode *, int);
1174extern void __exit afs_clean_up_permit_cache(void);
1175
1176
1177
1178
1179extern spinlock_t afs_server_peer_lock;
1180
1181static inline struct afs_server *afs_get_server(struct afs_server *server)
1182{
1183 atomic_inc(&server->usage);
1184 return server;
1185}
1186
1187extern struct afs_server *afs_find_server(struct afs_net *,
1188 const struct sockaddr_rxrpc *);
1189extern struct afs_server *afs_find_server_by_uuid(struct afs_net *, const uuid_t *);
1190extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *);
1191extern void afs_put_server(struct afs_net *, struct afs_server *);
1192extern void afs_manage_servers(struct work_struct *);
1193extern void afs_servers_timer(struct timer_list *);
1194extern void __net_exit afs_purge_servers(struct afs_net *);
1195extern bool afs_check_server_record(struct afs_fs_cursor *, struct afs_server *);
1196
1197
1198
1199
1200static inline struct afs_server_list *afs_get_serverlist(struct afs_server_list *slist)
1201{
1202 refcount_inc(&slist->usage);
1203 return slist;
1204}
1205
1206extern void afs_put_serverlist(struct afs_net *, struct afs_server_list *);
1207extern struct afs_server_list *afs_alloc_server_list(struct afs_cell *, struct key *,
1208 struct afs_vldb_entry *,
1209 u8);
1210extern bool afs_annotate_server_list(struct afs_server_list *, struct afs_server_list *);
1211
1212
1213
1214
1215extern int __init afs_fs_init(void);
1216extern void afs_fs_exit(void);
1217
1218
1219
1220
1221extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *,
1222 const char *, int);
1223extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *, const uuid_t *);
1224extern int afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *, struct key *,
1225 struct afs_vlserver *, unsigned int, bool);
1226extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *, const uuid_t *);
1227
1228
1229
1230
1231extern void afs_vlserver_probe_result(struct afs_call *);
1232extern int afs_send_vl_probes(struct afs_net *, struct key *, struct afs_vlserver_list *);
1233extern int afs_wait_for_vl_probes(struct afs_vlserver_list *, unsigned long);
1234
1235
1236
1237
1238extern bool afs_begin_vlserver_operation(struct afs_vl_cursor *,
1239 struct afs_cell *, struct key *);
1240extern bool afs_select_vlserver(struct afs_vl_cursor *);
1241extern bool afs_select_current_vlserver(struct afs_vl_cursor *);
1242extern int afs_end_vlserver_operation(struct afs_vl_cursor *);
1243
1244
1245
1246
1247static inline struct afs_vlserver *afs_get_vlserver(struct afs_vlserver *vlserver)
1248{
1249 atomic_inc(&vlserver->usage);
1250 return vlserver;
1251}
1252
1253static inline struct afs_vlserver_list *afs_get_vlserverlist(struct afs_vlserver_list *vllist)
1254{
1255 if (vllist)
1256 atomic_inc(&vllist->usage);
1257 return vllist;
1258}
1259
1260extern struct afs_vlserver *afs_alloc_vlserver(const char *, size_t, unsigned short);
1261extern void afs_put_vlserver(struct afs_net *, struct afs_vlserver *);
1262extern struct afs_vlserver_list *afs_alloc_vlserver_list(unsigned int);
1263extern void afs_put_vlserverlist(struct afs_net *, struct afs_vlserver_list *);
1264extern struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *,
1265 const void *, size_t);
1266
1267
1268
1269
1270static inline struct afs_volume *__afs_get_volume(struct afs_volume *volume)
1271{
1272 if (volume)
1273 atomic_inc(&volume->usage);
1274 return volume;
1275}
1276
1277extern struct afs_volume *afs_create_volume(struct afs_mount_params *);
1278extern void afs_activate_volume(struct afs_volume *);
1279extern void afs_deactivate_volume(struct afs_volume *);
1280extern void afs_put_volume(struct afs_cell *, struct afs_volume *);
1281extern int afs_check_volume_status(struct afs_volume *, struct key *);
1282
1283
1284
1285
1286extern int afs_set_page_dirty(struct page *);
1287extern int afs_write_begin(struct file *file, struct address_space *mapping,
1288 loff_t pos, unsigned len, unsigned flags,
1289 struct page **pagep, void **fsdata);
1290extern int afs_write_end(struct file *file, struct address_space *mapping,
1291 loff_t pos, unsigned len, unsigned copied,
1292 struct page *page, void *fsdata);
1293extern int afs_writepage(struct page *, struct writeback_control *);
1294extern int afs_writepages(struct address_space *, struct writeback_control *);
1295extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *);
1296extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *);
1297extern int afs_fsync(struct file *, loff_t, loff_t, int);
1298extern vm_fault_t afs_page_mkwrite(struct vm_fault *vmf);
1299extern void afs_prune_wb_keys(struct afs_vnode *);
1300extern int afs_launder_page(struct page *);
1301
1302
1303
1304
1305extern const struct xattr_handler *afs_xattr_handlers[];
1306extern ssize_t afs_listxattr(struct dentry *, char *, size_t);
1307
1308
1309
1310
1311extern int yfs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_volsync *, bool);
1312extern int yfs_fs_fetch_data(struct afs_fs_cursor *, struct afs_read *);
1313extern int yfs_fs_create_file(struct afs_fs_cursor *, const char *, umode_t, u64,
1314 struct afs_fid *, struct afs_file_status *, struct afs_callback *);
1315extern int yfs_fs_make_dir(struct afs_fs_cursor *, const char *, umode_t, u64,
1316 struct afs_fid *, struct afs_file_status *, struct afs_callback *);
1317extern int yfs_fs_remove_file2(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64);
1318extern int yfs_fs_remove(struct afs_fs_cursor *, struct afs_vnode *, const char *, bool, u64);
1319extern int yfs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64);
1320extern int yfs_fs_symlink(struct afs_fs_cursor *, const char *, const char *, u64,
1321 struct afs_fid *, struct afs_file_status *);
1322extern int yfs_fs_rename(struct afs_fs_cursor *, const char *,
1323 struct afs_vnode *, const char *, u64, u64);
1324extern int yfs_fs_store_data(struct afs_fs_cursor *, struct address_space *,
1325 pgoff_t, pgoff_t, unsigned, unsigned);
1326extern int yfs_fs_setattr(struct afs_fs_cursor *, struct iattr *);
1327extern int yfs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *);
1328extern int yfs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t);
1329extern int yfs_fs_extend_lock(struct afs_fs_cursor *);
1330extern int yfs_fs_release_lock(struct afs_fs_cursor *);
1331extern int yfs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *,
1332 struct afs_fid *, struct afs_file_status *,
1333 struct afs_callback *, struct afs_volsync *);
1334extern int yfs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *,
1335 struct afs_fid *, struct afs_file_status *,
1336 struct afs_callback *, unsigned int,
1337 struct afs_volsync *);
1338
1339
1340
1341
1342static inline struct afs_vnode *AFS_FS_I(struct inode *inode)
1343{
1344 return container_of(inode, struct afs_vnode, vfs_inode);
1345}
1346
1347static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode)
1348{
1349 return &vnode->vfs_inode;
1350}
1351
1352static inline void afs_vnode_commit_status(struct afs_fs_cursor *fc,
1353 struct afs_vnode *vnode,
1354 unsigned int cb_break)
1355{
1356 if (fc->ac.error == 0)
1357 afs_cache_permit(vnode, fc->key, cb_break);
1358}
1359
1360static inline void afs_check_for_remote_deletion(struct afs_fs_cursor *fc,
1361 struct afs_vnode *vnode)
1362{
1363 if (fc->ac.error == -ENOENT) {
1364 set_bit(AFS_VNODE_DELETED, &vnode->flags);
1365 afs_break_callback(vnode);
1366 }
1367}
1368
1369static inline int afs_io_error(struct afs_call *call, enum afs_io_error where)
1370{
1371 trace_afs_io_error(call->debug_id, -EIO, where);
1372 return -EIO;
1373}
1374
1375static inline int afs_bad(struct afs_vnode *vnode, enum afs_file_error where)
1376{
1377 trace_afs_file_error(vnode, -EIO, where);
1378 return -EIO;
1379}
1380
1381
1382
1383
1384
1385extern unsigned afs_debug;
1386
1387#define dbgprintk(FMT,...) \
1388 printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
1389
1390#define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
1391#define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
1392#define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__)
1393
1394
1395#if defined(__KDEBUG)
1396#define _enter(FMT,...) kenter(FMT,##__VA_ARGS__)
1397#define _leave(FMT,...) kleave(FMT,##__VA_ARGS__)
1398#define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__)
1399
1400#elif defined(CONFIG_AFS_DEBUG)
1401#define AFS_DEBUG_KENTER 0x01
1402#define AFS_DEBUG_KLEAVE 0x02
1403#define AFS_DEBUG_KDEBUG 0x04
1404
1405#define _enter(FMT,...) \
1406do { \
1407 if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \
1408 kenter(FMT,##__VA_ARGS__); \
1409} while (0)
1410
1411#define _leave(FMT,...) \
1412do { \
1413 if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \
1414 kleave(FMT,##__VA_ARGS__); \
1415} while (0)
1416
1417#define _debug(FMT,...) \
1418do { \
1419 if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \
1420 kdebug(FMT,##__VA_ARGS__); \
1421} while (0)
1422
1423#else
1424#define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
1425#define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
1426#define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__)
1427#endif
1428
1429
1430
1431
1432#if 1
1433
1434#define ASSERT(X) \
1435do { \
1436 if (unlikely(!(X))) { \
1437 printk(KERN_ERR "\n"); \
1438 printk(KERN_ERR "AFS: Assertion failed\n"); \
1439 BUG(); \
1440 } \
1441} while(0)
1442
1443#define ASSERTCMP(X, OP, Y) \
1444do { \
1445 if (unlikely(!((X) OP (Y)))) { \
1446 printk(KERN_ERR "\n"); \
1447 printk(KERN_ERR "AFS: Assertion failed\n"); \
1448 printk(KERN_ERR "%lu " #OP " %lu is false\n", \
1449 (unsigned long)(X), (unsigned long)(Y)); \
1450 printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
1451 (unsigned long)(X), (unsigned long)(Y)); \
1452 BUG(); \
1453 } \
1454} while(0)
1455
1456#define ASSERTRANGE(L, OP1, N, OP2, H) \
1457do { \
1458 if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \
1459 printk(KERN_ERR "\n"); \
1460 printk(KERN_ERR "AFS: Assertion failed\n"); \
1461 printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \
1462 (unsigned long)(L), (unsigned long)(N), \
1463 (unsigned long)(H)); \
1464 printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \
1465 (unsigned long)(L), (unsigned long)(N), \
1466 (unsigned long)(H)); \
1467 BUG(); \
1468 } \
1469} while(0)
1470
1471#define ASSERTIF(C, X) \
1472do { \
1473 if (unlikely((C) && !(X))) { \
1474 printk(KERN_ERR "\n"); \
1475 printk(KERN_ERR "AFS: Assertion failed\n"); \
1476 BUG(); \
1477 } \
1478} while(0)
1479
1480#define ASSERTIFCMP(C, X, OP, Y) \
1481do { \
1482 if (unlikely((C) && !((X) OP (Y)))) { \
1483 printk(KERN_ERR "\n"); \
1484 printk(KERN_ERR "AFS: Assertion failed\n"); \
1485 printk(KERN_ERR "%lu " #OP " %lu is false\n", \
1486 (unsigned long)(X), (unsigned long)(Y)); \
1487 printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
1488 (unsigned long)(X), (unsigned long)(Y)); \
1489 BUG(); \
1490 } \
1491} while(0)
1492
1493#else
1494
1495#define ASSERT(X) \
1496do { \
1497} while(0)
1498
1499#define ASSERTCMP(X, OP, Y) \
1500do { \
1501} while(0)
1502
1503#define ASSERTRANGE(L, OP1, N, OP2, H) \
1504do { \
1505} while(0)
1506
1507#define ASSERTIF(C, X) \
1508do { \
1509} while(0)
1510
1511#define ASSERTIFCMP(C, X, OP, Y) \
1512do { \
1513} while(0)
1514
1515#endif
1516