aboutsummaryrefslogtreecommitdiffstats
path: root/mm/zbud.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/zbud.c')
-rw-r--r--mm/zbud.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/mm/zbud.c b/mm/zbud.c
index 2ee4e4520493..f3bf6f7627d8 100644
--- a/mm/zbud.c
+++ b/mm/zbud.c
@@ -97,6 +97,10 @@ struct zbud_pool {
97 struct list_head lru; 97 struct list_head lru;
98 u64 pages_nr; 98 u64 pages_nr;
99 struct zbud_ops *ops; 99 struct zbud_ops *ops;
100#ifdef CONFIG_ZPOOL
101 struct zpool *zpool;
102 struct zpool_ops *zpool_ops;
103#endif
100}; 104};
101 105
102/* 106/*
@@ -123,7 +127,10 @@ struct zbud_header {
123 127
124static int zbud_zpool_evict(struct zbud_pool *pool, unsigned long handle) 128static int zbud_zpool_evict(struct zbud_pool *pool, unsigned long handle)
125{ 129{
126 return zpool_evict(pool, handle); 130 if (pool->zpool && pool->zpool_ops && pool->zpool_ops->evict)
131 return pool->zpool_ops->evict(pool->zpool, handle);
132 else
133 return -ENOENT;
127} 134}
128 135
129static struct zbud_ops zbud_zpool_ops = { 136static struct zbud_ops zbud_zpool_ops = {
@@ -131,9 +138,17 @@ static struct zbud_ops zbud_zpool_ops = {
131}; 138};
132 139
133static void *zbud_zpool_create(char *name, gfp_t gfp, 140static void *zbud_zpool_create(char *name, gfp_t gfp,
134 struct zpool_ops *zpool_ops) 141 struct zpool_ops *zpool_ops,
142 struct zpool *zpool)
135{ 143{
136 return zbud_create_pool(gfp, zpool_ops ? &zbud_zpool_ops : NULL); 144 struct zbud_pool *pool;
145
146 pool = zbud_create_pool(gfp, zpool_ops ? &zbud_zpool_ops : NULL);
147 if (pool) {
148 pool->zpool = zpool;
149 pool->zpool_ops = zpool_ops;
150 }
151 return pool;
137} 152}
138 153
139static void zbud_zpool_destroy(void *pool) 154static void zbud_zpool_destroy(void *pool)
@@ -292,7 +307,7 @@ struct zbud_pool *zbud_create_pool(gfp_t gfp, struct zbud_ops *ops)
292 struct zbud_pool *pool; 307 struct zbud_pool *pool;
293 int i; 308 int i;
294 309
295 pool = kmalloc(sizeof(struct zbud_pool), gfp); 310 pool = kzalloc(sizeof(struct zbud_pool), gfp);
296 if (!pool) 311 if (!pool)
297 return NULL; 312 return NULL;
298 spin_lock_init(&pool->lock); 313 spin_lock_init(&pool->lock);