1 /* fscache-int.h: internal definitions
3 * Copyright (C) 2004 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 #ifndef _FSCACHE_INT_H
13 #define _FSCACHE_INT_H
15 #include <linux/fscache-cache.h>
16 #include <linux/timer.h>
17 #include <linux/bio.h>
19 extern kmem_cache_t *fscache_cookie_jar;
21 extern struct fscache_cookie fscache_fsdef_index;
22 extern struct fscache_cookie_def fscache_fsdef_netfs_def;
24 extern void fscache_cookie_init_once(void *_cookie, kmem_cache_t *cachep, unsigned long flags);
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
34 static inline int fscache_operation_lock(struct fscache_object *object)
36 return down_read_trylock(&object->cache->withdrawal_sem);
40 * release the operation lock
42 static inline void fscache_operation_unlock(struct fscache_object *object)
44 up_read(&object->cache->withdrawal_sem);
48 /*****************************************************************************/
52 #define dbgprintk(FMT,...) \
53 printk("[%-6.6s] "FMT"\n",current->comm ,##__VA_ARGS__)
54 #define _dbprintk(FMT,...) do { } while(0)
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__)
60 #define kjournal(FMT,...) _dbprintk(FMT ,##__VA_ARGS__)
62 #define dbgfree(ADDR) _dbprintk("%p:%d: FREEING %p",__FILE__,__LINE__,ADDR)
64 #define dbgpgalloc(PAGE) \
66 _dbprintk("PGALLOC %s:%d: %p {%lx,%lu}\n", \
68 (PAGE),(PAGE)->mapping->host->i_ino,(PAGE)->index \
72 #define dbgpgfree(PAGE) \
75 _dbprintk("PGFREE %s:%d: %p {%lx,%lu}\n", \
78 (PAGE)->mapping->host->i_ino, \
84 #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__)
85 #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__)
86 #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__)
88 #define _enter(FMT,...) do { } while(0)
89 #define _leave(FMT,...) do { } while(0)
90 #define _debug(FMT,...) do { } while(0)
93 #endif /* _FSCACHE_INT_H */