This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / fs / fscache / fscache-int.h
1 /* fscache-int.h: internal definitions
2  *
3  * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells (dhowells@redhat.com)
5  *
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.
10  */
11
12 #ifndef _FSCACHE_INT_H
13 #define _FSCACHE_INT_H
14
15 #include <linux/fscache-cache.h>
16 #include <linux/timer.h>
17 #include <linux/bio.h>
18
19 extern kmem_cache_t *fscache_cookie_jar;
20
21 extern struct fscache_cookie fscache_fsdef_index;
22 extern struct fscache_cookie_def fscache_fsdef_netfs_def;
23
24 extern void fscache_cookie_init_once(void *_cookie, kmem_cache_t *cachep, unsigned long flags);
25
26 /*
27  * prevent the cache from being withdrawn whilst an operation is in progress
28  * - returns false if the cache is being withdrawn already or if the cache is
29  *   waiting to withdraw itself
30  * - returns true if the cache was not being withdrawn
31  * - fscache_withdraw_cache() will wait using down_write() until all ops are
32  *   complete
33  */
34 static inline int fscache_operation_lock(struct fscache_object *object)
35 {
36         return down_read_trylock(&object->cache->withdrawal_sem);
37 }
38
39 /*
40  * release the operation lock
41  */
42 static inline void fscache_operation_unlock(struct fscache_object *object)
43 {
44         up_read(&object->cache->withdrawal_sem);
45 }
46
47
48 /*****************************************************************************/
49 /*
50  * debug tracing
51  */
52 #define dbgprintk(FMT,...) \
53         printk("[%-6.6s] "FMT"\n",current->comm ,##__VA_ARGS__)
54 #define _dbprintk(FMT,...) do { } while(0)
55
56 #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__FUNCTION__ ,##__VA_ARGS__)
57 #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__FUNCTION__ ,##__VA_ARGS__)
58 #define kdebug(FMT,...) dbgprintk(FMT ,##__VA_ARGS__)
59
60 #define kjournal(FMT,...) _dbprintk(FMT ,##__VA_ARGS__)
61
62 #define dbgfree(ADDR)  _dbprintk("%p:%d: FREEING %p",__FILE__,__LINE__,ADDR)
63
64 #define dbgpgalloc(PAGE)                                                \
65 do {                                                                    \
66         _dbprintk("PGALLOC %s:%d: %p {%lx,%lu}\n",                      \
67                   __FILE__,__LINE__,                                    \
68                   (PAGE),(PAGE)->mapping->host->i_ino,(PAGE)->index     \
69                   );                                                    \
70 } while(0)
71
72 #define dbgpgfree(PAGE)                                         \
73 do {                                                            \
74         if ((PAGE))                                             \
75                 _dbprintk("PGFREE %s:%d: %p {%lx,%lu}\n",       \
76                           __FILE__,__LINE__,                    \
77                           (PAGE),                               \
78                           (PAGE)->mapping->host->i_ino,         \
79                           (PAGE)->index                         \
80                           );                                    \
81 } while(0)
82
83 #ifdef __KDEBUG
84 #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__)
85 #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__)
86 #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__)
87 #else
88 #define _enter(FMT,...) do { } while(0)
89 #define _leave(FMT,...) do { } while(0)
90 #define _debug(FMT,...) do { } while(0)
91 #endif
92
93 #endif /* _FSCACHE_INT_H */