Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
422 | giacomo | 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 | atomic_t e_used; |
||
39 | struct block_device *e_bdev; |
||
40 | sector_t e_block; |
||
41 | struct list_head e_block_list; |
||
42 | struct mb_cache_entry_index e_indexes[0]; |
||
43 | }; |
||
44 | |||
45 | /* Functions on caches */ |
||
46 | |||
47 | struct mb_cache * mb_cache_create(const char *, struct mb_cache_op *, size_t, |
||
48 | int, int); |
||
49 | void mb_cache_shrink(struct mb_cache *, struct block_device *); |
||
50 | void mb_cache_destroy(struct mb_cache *); |
||
51 | |||
52 | /* Functions on cache entries */ |
||
53 | |||
54 | struct mb_cache_entry *mb_cache_entry_alloc(struct mb_cache *); |
||
55 | int mb_cache_entry_insert(struct mb_cache_entry *, struct block_device *, |
||
56 | sector_t, unsigned int[]); |
||
57 | void mb_cache_entry_rehash(struct mb_cache_entry *, unsigned int[]); |
||
58 | void mb_cache_entry_release(struct mb_cache_entry *); |
||
59 | void mb_cache_entry_takeout(struct mb_cache_entry *); |
||
60 | void mb_cache_entry_free(struct mb_cache_entry *); |
||
61 | struct mb_cache_entry *mb_cache_entry_dup(struct mb_cache_entry *); |
||
62 | struct mb_cache_entry *mb_cache_entry_get(struct mb_cache *, |
||
63 | struct block_device *, |
||
64 | sector_t); |
||
65 | #if !defined(MB_CACHE_INDEXES_COUNT) || (MB_CACHE_INDEXES_COUNT > 0) |
||
66 | struct mb_cache_entry *mb_cache_entry_find_first(struct mb_cache *cache, int, |
||
67 | struct block_device *, |
||
68 | unsigned int); |
||
69 | struct mb_cache_entry *mb_cache_entry_find_next(struct mb_cache_entry *, int, |
||
70 | struct block_device *, |
||
71 | unsigned int); |
||
72 | #endif |