aboutsummaryrefslogtreecommitdiffstats
path: root/fs/afs/internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/afs/internal.h')
-rw-r--r--fs/afs/internal.h599
1 files changed, 553 insertions, 46 deletions
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index b6dd20a93cce..afc6f0f30259 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -1,6 +1,6 @@
1/* internal AFS stuff 1/* internal AFS stuff
2 * 2 *
3 * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved. 3 * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com) 4 * Written by David Howells (dhowells@redhat.com)
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
@@ -9,48 +9,321 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11 11
12#ifndef AFS_INTERNAL_H
13#define AFS_INTERNAL_H
14
15#include <linux/compiler.h> 12#include <linux/compiler.h>
16#include <linux/kernel.h> 13#include <linux/kernel.h>
17#include <linux/fs.h> 14#include <linux/fs.h>
18#include <linux/pagemap.h> 15#include <linux/pagemap.h>
16#include <linux/skbuff.h>
17#include <linux/rxrpc.h>
18#include "afs.h"
19#include "afs_vl.h"
20
21#define AFS_CELL_MAX_ADDRS 15
22
23struct afs_call;
24
25typedef enum {
26 AFS_VL_NEW, /* new, uninitialised record */
27 AFS_VL_CREATING, /* creating record */
28 AFS_VL_VALID, /* record is pending */
29 AFS_VL_NO_VOLUME, /* no such volume available */
30 AFS_VL_UPDATING, /* update in progress */
31 AFS_VL_VOLUME_DELETED, /* volume was deleted */
32 AFS_VL_UNCERTAIN, /* uncertain state (update failed) */
33} __attribute__((packed)) afs_vlocation_state_t;
19 34
20/* 35/*
21 * debug tracing 36 * definition of how to wait for the completion of an operation
22 */ 37 */
23#define kenter(FMT, a...) printk("==> %s("FMT")\n",__FUNCTION__ , ## a) 38struct afs_wait_mode {
24#define kleave(FMT, a...) printk("<== %s()"FMT"\n",__FUNCTION__ , ## a) 39 /* RxRPC received message notification */
25#define kdebug(FMT, a...) printk(FMT"\n" , ## a) 40 void (*rx_wakeup)(struct afs_call *call);
26#define kproto(FMT, a...) printk("### "FMT"\n" , ## a)
27#define knet(FMT, a...) printk(FMT"\n" , ## a)
28
29#ifdef __KDEBUG
30#define _enter(FMT, a...) kenter(FMT , ## a)
31#define _leave(FMT, a...) kleave(FMT , ## a)
32#define _debug(FMT, a...) kdebug(FMT , ## a)
33#define _proto(FMT, a...) kproto(FMT , ## a)
34#define _net(FMT, a...) knet(FMT , ## a)
35#else
36#define _enter(FMT, a...) do { } while(0)
37#define _leave(FMT, a...) do { } while(0)
38#define _debug(FMT, a...) do { } while(0)
39#define _proto(FMT, a...) do { } while(0)
40#define _net(FMT, a...) do { } while(0)
41#endif
42 41
43static inline void afs_discard_my_signals(void) 42 /* synchronous call waiter and call dispatched notification */
44{ 43 int (*wait)(struct afs_call *call);
45 while (signal_pending(current)) { 44
46 siginfo_t sinfo; 45 /* asynchronous call completion */
46 void (*async_complete)(void *reply, int error);
47};
48
49extern const struct afs_wait_mode afs_sync_call;
50extern const struct afs_wait_mode afs_async_call;
51
52/*
53 * a record of an in-progress RxRPC call
54 */
55struct afs_call {
56 const struct afs_call_type *type; /* type of call */
57 const struct afs_wait_mode *wait_mode; /* completion wait mode */
58 wait_queue_head_t waitq; /* processes awaiting completion */
59 struct work_struct async_work; /* asynchronous work processor */
60 struct work_struct work; /* actual work processor */
61 struct sk_buff_head rx_queue; /* received packets */
62 struct rxrpc_call *rxcall; /* RxRPC call handle */
63 struct key *key; /* security for this call */
64 struct afs_server *server; /* server affected by incoming CM call */
65 void *request; /* request data (first part) */
66 void *request2; /* request data (second part) */
67 void *buffer; /* reply receive buffer */
68 void *reply; /* reply buffer (first part) */
69 void *reply2; /* reply buffer (second part) */
70 void *reply3; /* reply buffer (third part) */
71 enum { /* call state */
72 AFS_CALL_REQUESTING, /* request is being sent for outgoing call */
73 AFS_CALL_AWAIT_REPLY, /* awaiting reply to outgoing call */
74 AFS_CALL_AWAIT_OP_ID, /* awaiting op ID on incoming call */
75 AFS_CALL_AWAIT_REQUEST, /* awaiting request data on incoming call */
76 AFS_CALL_REPLYING, /* replying to incoming call */
77 AFS_CALL_AWAIT_ACK, /* awaiting final ACK of incoming call */
78 AFS_CALL_COMPLETE, /* successfully completed */
79 AFS_CALL_BUSY, /* server was busy */
80 AFS_CALL_ABORTED, /* call was aborted */
81 AFS_CALL_ERROR, /* call failed due to error */
82 } state;
83 int error; /* error code */
84 unsigned request_size; /* size of request data */
85 unsigned reply_max; /* maximum size of reply */
86 unsigned reply_size; /* current size of reply */
87 unsigned short offset; /* offset into received data store */
88 unsigned char unmarshall; /* unmarshalling phase */
89 bool incoming; /* T if incoming call */
90 u16 service_id; /* RxRPC service ID to call */
91 __be16 port; /* target UDP port */
92 __be32 operation_ID; /* operation ID for an incoming call */
93 u32 count; /* count for use in unmarshalling */
94 __be32 tmp; /* place to extract temporary data */
95};
96
97struct afs_call_type {
98 /* deliver request or reply data to an call
99 * - returning an error will cause the call to be aborted
100 */
101 int (*deliver)(struct afs_call *call, struct sk_buff *skb,
102 bool last);
103
104 /* map an abort code to an error number */
105 int (*abort_to_error)(u32 abort_code);
106
107 /* clean up a call */
108 void (*destructor)(struct afs_call *call);
109};
110
111/*
112 * AFS superblock private data
113 * - there's one superblock per volume
114 */
115struct afs_super_info {
116 struct afs_volume *volume; /* volume record */
117 char rwparent; /* T if parent is R/W AFS volume */
118};
47 119
48 spin_lock_irq(&current->sighand->siglock); 120static inline struct afs_super_info *AFS_FS_S(struct super_block *sb)
49 dequeue_signal(current,&current->blocked, &sinfo); 121{
50 spin_unlock_irq(&current->sighand->siglock); 122 return sb->s_fs_info;
51 }
52} 123}
53 124
125extern struct file_system_type afs_fs_type;
126
127/*
128 * entry in the cached cell catalogue
129 */
130struct afs_cache_cell {
131 char name[64]; /* cell name (padded with NULs) */
132 struct in_addr vl_servers[15]; /* cached cell VL servers */
133};
134
135/*
136 * AFS cell record
137 */
138struct afs_cell {
139 atomic_t usage;
140 struct list_head link; /* main cell list link */
141 struct list_head proc_link; /* /proc cell list link */
142 struct proc_dir_entry *proc_dir; /* /proc dir for this cell */
143#ifdef AFS_CACHING_SUPPORT
144 struct cachefs_cookie *cache; /* caching cookie */
145#endif
146
147 /* server record management */
148 rwlock_t servers_lock; /* active server list lock */
149 struct list_head servers; /* active server list */
150
151 /* volume location record management */
152 struct rw_semaphore vl_sem; /* volume management serialisation semaphore */
153 struct list_head vl_list; /* cell's active VL record list */
154 spinlock_t vl_lock; /* vl_list lock */
155 unsigned short vl_naddrs; /* number of VL servers in addr list */
156 unsigned short vl_curr_svix; /* current server index */
157 struct in_addr vl_addrs[AFS_CELL_MAX_ADDRS]; /* cell VL server addresses */
158
159 char name[0]; /* cell name - must go last */
160};
161
162/*
163 * entry in the cached volume location catalogue
164 */
165struct afs_cache_vlocation {
166 uint8_t name[64 + 1]; /* volume name (lowercase, padded with NULs) */
167 uint8_t nservers; /* number of entries used in servers[] */
168 uint8_t vidmask; /* voltype mask for vid[] */
169 uint8_t srvtmask[8]; /* voltype masks for servers[] */
170#define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */
171#define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */
172#define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */
173
174 afs_volid_t vid[3]; /* volume IDs for R/W, R/O and Bak volumes */
175 struct in_addr servers[8]; /* fileserver addresses */
176 time_t rtime; /* last retrieval time */
177};
178
179/*
180 * volume -> vnode hash table entry
181 */
182struct afs_cache_vhash {
183 afs_voltype_t vtype; /* which volume variation */
184 uint8_t hash_bucket; /* which hash bucket this represents */
185} __attribute__((packed));
186
187/*
188 * AFS volume location record
189 */
190struct afs_vlocation {
191 atomic_t usage;
192 time_t time_of_death; /* time at which put reduced usage to 0 */
193 struct list_head link; /* link in cell volume location list */
194 struct list_head grave; /* link in master graveyard list */
195 struct list_head update; /* link in master update list */
196 struct afs_cell *cell; /* cell to which volume belongs */
197#ifdef AFS_CACHING_SUPPORT
198 struct cachefs_cookie *cache; /* caching cookie */
199#endif
200 struct afs_cache_vlocation vldb; /* volume information DB record */
201 struct afs_volume *vols[3]; /* volume access record pointer (index by type) */
202 wait_queue_head_t waitq; /* status change waitqueue */
203 time_t update_at; /* time at which record should be updated */
204 rwlock_t lock; /* access lock */
205 afs_vlocation_state_t state; /* volume location state */
206 unsigned short upd_rej_cnt; /* ENOMEDIUM count during update */
207 unsigned short upd_busy_cnt; /* EBUSY count during update */
208 bool valid; /* T if valid */
209};
210
211/*
212 * AFS fileserver record
213 */
214struct afs_server {
215 atomic_t usage;
216 time_t time_of_death; /* time at which put reduced usage to 0 */
217 struct in_addr addr; /* server address */
218 struct afs_cell *cell; /* cell in which server resides */
219 struct list_head link; /* link in cell's server list */
220 struct list_head grave; /* link in master graveyard list */
221 struct rb_node master_rb; /* link in master by-addr tree */
222 struct rw_semaphore sem; /* access lock */
223
224 /* file service access */
225 struct rb_root fs_vnodes; /* vnodes backed by this server (ordered by FID) */
226 unsigned long fs_act_jif; /* time at which last activity occurred */
227 unsigned long fs_dead_jif; /* time at which no longer to be considered dead */
228 spinlock_t fs_lock; /* access lock */
229 int fs_state; /* 0 or reason FS currently marked dead (-errno) */
230
231 /* callback promise management */
232 struct rb_root cb_promises; /* vnode expiration list (ordered earliest first) */
233 struct delayed_work cb_updater; /* callback updater */
234 struct delayed_work cb_break_work; /* collected break dispatcher */
235 wait_queue_head_t cb_break_waitq; /* space available in cb_break waitqueue */
236 spinlock_t cb_lock; /* access lock */
237 struct afs_callback cb_break[64]; /* ring of callbacks awaiting breaking */
238 atomic_t cb_break_n; /* number of pending breaks */
239 u8 cb_break_head; /* head of callback breaking ring */
240 u8 cb_break_tail; /* tail of callback breaking ring */
241};
242
243/*
244 * AFS volume access record
245 */
246struct afs_volume {
247 atomic_t usage;
248 struct afs_cell *cell; /* cell to which belongs (unrefd ptr) */
249 struct afs_vlocation *vlocation; /* volume location */
250#ifdef AFS_CACHING_SUPPORT
251 struct cachefs_cookie *cache; /* caching cookie */
252#endif
253 afs_volid_t vid; /* volume ID */
254 afs_voltype_t type; /* type of volume */
255 char type_force; /* force volume type (suppress R/O -> R/W) */
256 unsigned short nservers; /* number of server slots filled */
257 unsigned short rjservers; /* number of servers discarded due to -ENOMEDIUM */
258 struct afs_server *servers[8]; /* servers on which volume resides (ordered) */
259 struct rw_semaphore server_sem; /* lock for accessing current server */
260};
261
262/*
263 * vnode catalogue entry
264 */
265struct afs_cache_vnode {
266 afs_vnodeid_t vnode_id; /* vnode ID */
267 unsigned vnode_unique; /* vnode ID uniquifier */
268 afs_dataversion_t data_version; /* data version */
269};
270
271/*
272 * AFS inode private data
273 */
274struct afs_vnode {
275 struct inode vfs_inode; /* the VFS's inode record */
276
277 struct afs_volume *volume; /* volume on which vnode resides */
278 struct afs_server *server; /* server currently supplying this file */
279 struct afs_fid fid; /* the file identifier for this inode */
280 struct afs_file_status status; /* AFS status info for this file */
281#ifdef AFS_CACHING_SUPPORT
282 struct cachefs_cookie *cache; /* caching cookie */
283#endif
284
285 wait_queue_head_t update_waitq; /* status fetch waitqueue */
286 unsigned update_cnt; /* number of outstanding ops that will update the
287 * status */
288 spinlock_t lock; /* waitqueue/flags lock */
289 unsigned long flags;
290#define AFS_VNODE_CB_BROKEN 0 /* set if vnode's callback was broken */
291#define AFS_VNODE_CHANGED 1 /* set if vnode's metadata changed */
292#define AFS_VNODE_MODIFIED 2 /* set if vnode's data modified */
293#define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */
294#define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */
295#define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */
296#define AFS_VNODE_DIR_CHANGED 6 /* set if vnode's parent dir metadata changed */
297#define AFS_VNODE_DIR_MODIFIED 7 /* set if vnode's parent dir data modified */
298
299 /* outstanding callback notification on this file */
300 struct rb_node server_rb; /* link in server->fs_vnodes */
301 struct rb_node cb_promise; /* link in server->cb_promises */
302 struct work_struct cb_broken_work; /* work to be done on callback break */
303 struct mutex cb_broken_lock; /* lock against multiple attempts to fix break */
304// struct list_head cb_hash_link; /* link in master callback hash */
305 time_t cb_expires; /* time at which callback expires */
306 time_t cb_expires_at; /* time used to order cb_promise */
307 unsigned cb_version; /* callback version */
308 unsigned cb_expiry; /* callback expiry time */
309 afs_callback_type_t cb_type; /* type of callback */
310 bool cb_promised; /* true if promise still holds */
311};
312
313/*****************************************************************************/
314/*
315 * callback.c
316 */
317extern void afs_init_callback_state(struct afs_server *);
318extern void afs_broken_callback_work(struct work_struct *);
319extern void afs_break_callbacks(struct afs_server *, size_t,
320 struct afs_callback[]);
321extern void afs_give_up_callback(struct afs_vnode *);
322extern void afs_dispatch_give_up_callbacks(struct work_struct *);
323extern void afs_flush_callback_breaks(struct afs_server *);
324extern int __init afs_callback_update_init(void);
325extern void __exit afs_callback_update_kill(void);
326
54/* 327/*
55 * cell.c 328 * cell.c
56 */ 329 */
@@ -60,6 +333,19 @@ extern struct list_head afs_proc_cells;
60extern struct cachefs_index_def afs_cache_cell_index_def; 333extern struct cachefs_index_def afs_cache_cell_index_def;
61#endif 334#endif
62 335
336#define afs_get_cell(C) do { atomic_inc(&(C)->usage); } while(0)
337extern int afs_cell_init(char *);
338extern struct afs_cell *afs_cell_create(const char *, char *);
339extern struct afs_cell *afs_cell_lookup(const char *, unsigned);
340extern struct afs_cell *afs_grab_cell(struct afs_cell *);
341extern void afs_put_cell(struct afs_cell *);
342extern void afs_cell_purge(void);
343
344/*
345 * cmservice.c
346 */
347extern bool afs_cm_incoming_call(struct afs_call *);
348
63/* 349/*
64 * dir.c 350 * dir.c
65 */ 351 */
@@ -77,9 +363,22 @@ extern int afs_cache_get_page_cookie(struct page *, struct cachefs_page **);
77#endif 363#endif
78 364
79/* 365/*
366 * fsclient.c
367 */
368extern int afs_fs_fetch_file_status(struct afs_server *,
369 struct afs_vnode *,
370 struct afs_volsync *,
371 const struct afs_wait_mode *);
372extern int afs_fs_give_up_callbacks(struct afs_server *,
373 const struct afs_wait_mode *);
374extern int afs_fs_fetch_data(struct afs_server *, struct afs_vnode *, off_t,
375 size_t, struct page *, struct afs_volsync *,
376 const struct afs_wait_mode *);
377
378/*
80 * inode.c 379 * inode.c
81 */ 380 */
82extern int afs_iget(struct super_block *, struct afs_fid *, struct inode **); 381extern struct inode *afs_iget(struct super_block *, struct afs_fid *);
83extern int afs_inode_getattr(struct vfsmount *, struct dentry *, 382extern int afs_inode_getattr(struct vfsmount *, struct dentry *,
84 struct kstat *); 383 struct kstat *);
85extern void afs_clear_inode(struct inode *); 384extern void afs_clear_inode(struct inode *);
@@ -92,15 +391,20 @@ extern struct cachefs_netfs afs_cache_netfs;
92#endif 391#endif
93 392
94/* 393/*
394 * misc.c
395 */
396extern int afs_abort_to_error(u32);
397
398/*
95 * mntpt.c 399 * mntpt.c
96 */ 400 */
97extern const struct inode_operations afs_mntpt_inode_operations; 401extern const struct inode_operations afs_mntpt_inode_operations;
98extern const struct file_operations afs_mntpt_file_operations; 402extern const struct file_operations afs_mntpt_file_operations;
99extern struct afs_timer afs_mntpt_expiry_timer;
100extern struct afs_timer_ops afs_mntpt_expiry_timer_ops;
101extern unsigned long afs_mntpt_expiry_timeout; 403extern unsigned long afs_mntpt_expiry_timeout;
102 404
103extern int afs_mntpt_check_symlink(struct afs_vnode *); 405extern int afs_mntpt_check_symlink(struct afs_vnode *);
406extern void afs_mntpt_kill_timer(void);
407extern void afs_umount_begin(struct vfsmount *, int);
104 408
105/* 409/*
106 * super.c 410 * super.c
@@ -108,16 +412,6 @@ extern int afs_mntpt_check_symlink(struct afs_vnode *);
108extern int afs_fs_init(void); 412extern int afs_fs_init(void);
109extern void afs_fs_exit(void); 413extern void afs_fs_exit(void);
110 414
111#define AFS_CB_HASH_COUNT (PAGE_SIZE / sizeof(struct list_head))
112
113extern struct list_head afs_cb_hash_tbl[];
114extern spinlock_t afs_cb_hash_lock;
115
116#define afs_cb_hash(SRV, FID) \
117 afs_cb_hash_tbl[((unsigned long)(SRV) + \
118 (FID)->vid + (FID)->vnode + (FID)->unique) & \
119 (AFS_CB_HASH_COUNT - 1)]
120
121/* 415/*
122 * proc.c 416 * proc.c
123 */ 417 */
@@ -126,4 +420,217 @@ extern void afs_proc_cleanup(void);
126extern int afs_proc_cell_setup(struct afs_cell *); 420extern int afs_proc_cell_setup(struct afs_cell *);
127extern void afs_proc_cell_remove(struct afs_cell *); 421extern void afs_proc_cell_remove(struct afs_cell *);
128 422
129#endif /* AFS_INTERNAL_H */ 423/*
424 * rxrpc.c
425 */
426extern int afs_open_socket(void);
427extern void afs_close_socket(void);
428extern int afs_make_call(struct in_addr *, struct afs_call *, gfp_t,
429 const struct afs_wait_mode *);
430extern struct afs_call *afs_alloc_flat_call(const struct afs_call_type *,
431 size_t, size_t);
432extern void afs_flat_call_destructor(struct afs_call *);
433extern void afs_transfer_reply(struct afs_call *, struct sk_buff *);
434extern void afs_send_empty_reply(struct afs_call *);
435extern int afs_extract_data(struct afs_call *, struct sk_buff *, bool, void *,
436 size_t);
437
438/*
439 * server.c
440 */
441extern spinlock_t afs_server_peer_lock;
442
443#define afs_get_server(S) do { atomic_inc(&(S)->usage); } while(0)
444
445extern struct afs_server *afs_lookup_server(struct afs_cell *,
446 const struct in_addr *);
447extern struct afs_server *afs_find_server(const struct in_addr *);
448extern void afs_put_server(struct afs_server *);
449extern void __exit afs_purge_servers(void);
450
451/*
452 * vlclient.c
453 */
454#ifdef AFS_CACHING_SUPPORT
455extern struct cachefs_index_def afs_vlocation_cache_index_def;
456#endif
457
458extern int afs_vl_get_entry_by_name(struct in_addr *, const char *,
459 struct afs_cache_vlocation *,
460 const struct afs_wait_mode *);
461extern int afs_vl_get_entry_by_id(struct in_addr *, afs_volid_t, afs_voltype_t,
462 struct afs_cache_vlocation *,
463 const struct afs_wait_mode *);
464
465/*
466 * vlocation.c
467 */
468#define afs_get_vlocation(V) do { atomic_inc(&(V)->usage); } while(0)
469
470extern int __init afs_vlocation_update_init(void);
471extern struct afs_vlocation *afs_vlocation_lookup(struct afs_cell *,
472 const char *, size_t);
473extern void afs_put_vlocation(struct afs_vlocation *);
474extern void __exit afs_vlocation_purge(void);
475
476/*
477 * vnode.c
478 */
479#ifdef AFS_CACHING_SUPPORT
480extern struct cachefs_index_def afs_vnode_cache_index_def;
481#endif
482
483extern struct afs_timer_ops afs_vnode_cb_timed_out_ops;
484
485static inline struct afs_vnode *AFS_FS_I(struct inode *inode)
486{
487 return container_of(inode, struct afs_vnode, vfs_inode);
488}
489
490static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode)
491{
492 return &vnode->vfs_inode;
493}
494
495extern int afs_vnode_fetch_status(struct afs_vnode *);
496extern int afs_vnode_fetch_data(struct afs_vnode *vnode, off_t, size_t,
497 struct page *);
498
499/*
500 * volume.c
501 */
502#ifdef AFS_CACHING_SUPPORT
503extern struct cachefs_index_def afs_volume_cache_index_def;
504#endif
505
506#define afs_get_volume(V) do { atomic_inc(&(V)->usage); } while(0)
507
508extern void afs_put_volume(struct afs_volume *);
509extern struct afs_volume *afs_volume_lookup(const char *, struct afs_cell *,
510 int);
511extern struct afs_server *afs_volume_pick_fileserver(struct afs_vnode *);
512extern int afs_volume_release_fileserver(struct afs_vnode *,
513 struct afs_server *, int);
514
515/*****************************************************************************/
516/*
517 * debug tracing
518 */
519extern unsigned afs_debug;
520
521#define dbgprintk(FMT,...) \
522 printk("[%x%-6.6s] "FMT"\n", smp_processor_id(), current->comm ,##__VA_ARGS__)
523
524/* make sure we maintain the format strings, even when debugging is disabled */
525static inline __attribute__((format(printf,1,2)))
526void _dbprintk(const char *fmt, ...)
527{
528}
529
530#define kenter(FMT,...) dbgprintk("==> %s("FMT")",__FUNCTION__ ,##__VA_ARGS__)
531#define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__FUNCTION__ ,##__VA_ARGS__)
532#define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__)
533
534
535#if defined(__KDEBUG)
536#define _enter(FMT,...) kenter(FMT,##__VA_ARGS__)
537#define _leave(FMT,...) kleave(FMT,##__VA_ARGS__)
538#define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__)
539
540#elif defined(CONFIG_AFS_DEBUG)
541#define AFS_DEBUG_KENTER 0x01
542#define AFS_DEBUG_KLEAVE 0x02
543#define AFS_DEBUG_KDEBUG 0x04
544
545#define _enter(FMT,...) \
546do { \
547 if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \
548 kenter(FMT,##__VA_ARGS__); \
549} while (0)
550
551#define _leave(FMT,...) \
552do { \
553 if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \
554 kleave(FMT,##__VA_ARGS__); \
555} while (0)
556
557#define _debug(FMT,...) \
558do { \
559 if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \
560 kdebug(FMT,##__VA_ARGS__); \
561} while (0)
562
563#else
564#define _enter(FMT,...) _dbprintk("==> %s("FMT")",__FUNCTION__ ,##__VA_ARGS__)
565#define _leave(FMT,...) _dbprintk("<== %s()"FMT"",__FUNCTION__ ,##__VA_ARGS__)
566#define _debug(FMT,...) _dbprintk(" "FMT ,##__VA_ARGS__)
567#endif
568
569/*
570 * debug assertion checking
571 */
572#if 1 // defined(__KDEBUGALL)
573
574#define ASSERT(X) \
575do { \
576 if (unlikely(!(X))) { \
577 printk(KERN_ERR "\n"); \
578 printk(KERN_ERR "AFS: Assertion failed\n"); \
579 BUG(); \
580 } \
581} while(0)
582
583#define ASSERTCMP(X, OP, Y) \
584do { \
585 if (unlikely(!((X) OP (Y)))) { \
586 printk(KERN_ERR "\n"); \
587 printk(KERN_ERR "AFS: Assertion failed\n"); \
588 printk(KERN_ERR "%lu " #OP " %lu is false\n", \
589 (unsigned long)(X), (unsigned long)(Y)); \
590 printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
591 (unsigned long)(X), (unsigned long)(Y)); \
592 BUG(); \
593 } \
594} while(0)
595
596#define ASSERTIF(C, X) \
597do { \
598 if (unlikely((C) && !(X))) { \
599 printk(KERN_ERR "\n"); \
600 printk(KERN_ERR "AFS: Assertion failed\n"); \
601 BUG(); \
602 } \
603} while(0)
604
605#define ASSERTIFCMP(C, X, OP, Y) \
606do { \
607 if (unlikely((C) && !((X) OP (Y)))) { \
608 printk(KERN_ERR "\n"); \
609 printk(KERN_ERR "AFS: Assertion failed\n"); \
610 printk(KERN_ERR "%lu " #OP " %lu is false\n", \
611 (unsigned long)(X), (unsigned long)(Y)); \
612 printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
613 (unsigned long)(X), (unsigned long)(Y)); \
614 BUG(); \
615 } \
616} while(0)
617
618#else
619
620#define ASSERT(X) \
621do { \
622} while(0)
623
624#define ASSERTCMP(X, OP, Y) \
625do { \
626} while(0)
627
628#define ASSERTIF(C, X) \
629do { \
630} while(0)
631
632#define ASSERTIFCMP(C, X, OP, Y) \
633do { \
634} while(0)
635
636#endif /* __KDEBUGALL */