Resurrect patches to support Proper
[linux-2.6.git] / include / linux / mbcache.h
1 /*
2   File: linux/mbcache.h
3
4   (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
5 */
6
7 /* Hardwire the number of additional indexes */
8 #define MB_CACHE_INDEXES_COUNT 1
9
10 struct mb_cache_entry;
11
12 struct mb_cache_op {
13         int (*free)(struct mb_cache_entry *, int);
14 };
15
16 struct mb_cache {
17         struct list_head                c_cache_list;
18         const char                      *c_name;
19         struct mb_cache_op              c_op;
20         atomic_t                        c_entry_count;
21         int                             c_bucket_bits;
22 #ifndef MB_CACHE_INDEXES_COUNT
23         int                             c_indexes_count;
24 #endif
25         kmem_cache_t                    *c_entry_cache;
26         struct list_head                *c_block_hash;
27         struct list_head                *c_indexes_hash[0];
28 };
29
30 struct mb_cache_entry_index {
31         struct list_head                o_list;
32         unsigned int                    o_key;
33 };
34
35 struct mb_cache_entry {
36         struct list_head                e_lru_list;
37         struct mb_cache                 *e_cache;
38         unsigned short                  e_used;
39         unsigned short                  e_queued;
40         struct block_device             *e_bdev;
41         sector_t                        e_block;
42         struct list_head                e_block_list;
43         struct mb_cache_entry_index     e_indexes[0];
44 };
45
46 /* Functions on caches */
47
48 struct mb_cache * mb_cache_create(const char *, struct mb_cache_op *, size_t,
49                                   int, int);
50 void mb_cache_shrink(struct mb_cache *, struct block_device *);
51 void mb_cache_destroy(struct mb_cache *);
52
53 /* Functions on cache entries */
54
55 struct mb_cache_entry *mb_cache_entry_alloc(struct mb_cache *);
56 int mb_cache_entry_insert(struct mb_cache_entry *, struct block_device *,
57                           sector_t, unsigned int[]);
58 void mb_cache_entry_rehash(struct mb_cache_entry *, unsigned int[]);
59 void mb_cache_entry_release(struct mb_cache_entry *);
60 void mb_cache_entry_free(struct mb_cache_entry *);
61 struct mb_cache_entry *mb_cache_entry_get(struct mb_cache *,
62                                           struct block_device *,
63                                           sector_t);
64 #if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0)
65 struct mb_cache_entry *mb_cache_entry_find_first(struct mb_cache *cache, int,
66                                                  struct block_device *, 
67                                                  unsigned int);
68 struct mb_cache_entry *mb_cache_entry_find_next(struct mb_cache_entry *, int,
69                                                 struct block_device *, 
70                                                 unsigned int);
71 #endif