-
Notifications
You must be signed in to change notification settings - Fork 1
/
cache.h
90 lines (70 loc) · 2.08 KB
/
cache.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* cache.h
*
* Copyright (C) 2013
* Maxime Lorrillere <[email protected]>
* LIP6 - Laboratoire d'Informatique de Paris 6
*/
#ifndef REMOTECACHE_CACHE_H
#define REMOTECACHE_CACHE_H
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/uuid.h>
#include <linux/shrinker.h>
#include <linux/mm.h>
#include <linux/pagemap.h>
#include <linux/radix-tree.h>
#include <linux/hashtable.h>
#include "remotecache.h"
struct page;
struct remotecache;
struct remotecache_inode {
struct kref kref;
struct hlist_node hash;
struct list_head list; /* reclaim list */
union {
struct remotecache *cache;
struct remotecache *md;
};
ino_t ino;
struct radix_tree_root pages_tree;
spinlock_t lock;
};
#define REMOTECACHE_INODES_HASH_ORDER 10
struct remotecache {
struct kref kref;
struct list_head list; /* links for cache lists */
struct remotecache_session *session; /* parent session */
uuid_le uuid; /* cache UUID (currently not used) */
int pool_id; /* Compat with cleancache */
DECLARE_HASHTABLE(inodes_hash, REMOTECACHE_INODES_HASH_ORDER);
spinlock_t lock; /* lock to protect inodes_hash */
atomic_t size; /* cache size */
};
void remotecache_init(struct remotecache *cache);
void remotecache_release(struct kref *ref);
static inline void remotecache_get(struct remotecache *cache)
{
kref_get(&cache->kref);
}
static inline void remotecache_put(struct remotecache *cache)
{
kref_put(&cache->kref, remotecache_release);
}
static inline void remotecache_inode_get(struct remotecache_inode *i)
{
kref_get(&i->kref);
}
void remotecache_inode_release(struct kref *ref);
static inline void remotecache_inode_put(struct remotecache_inode *i)
{
kref_put(&i->kref, remotecache_inode_release);
}
struct remotecache_inode *remotecache_inode_alloc(gfp_t gfp_mask);
void __remotecache_insert_inode(struct remotecache *cache,
struct remotecache_inode *i);
void __remotecache_remove_inode(struct remotecache_inode *i);
struct remotecache_inode *__remotecache_lookup_inode(
struct remotecache *, ino_t);
void remotecache_page_release(struct page *p);
#endif /* REMOTECACHE_CACHE_H */