Lines Matching refs:zpool

3  * zpool memory storage api
19 #include <linux/zpool.h>
21 struct zpool {
38 * zpool_register_driver() - register a zpool implementation.
51 * zpool_unregister_driver() - unregister a zpool implementation.
106 * @type: The type of the zpool to check (e.g. zbud, zsmalloc)
127 request_module("zpool-%s", type);
140 * zpool_create_pool() - Create a new zpool
141 * @type: The type of the zpool to create (e.g. zbud, zsmalloc)
142 * @name: The name of the zpool (e.g. zram0, zswap)
146 * This creates a new zpool of the specified type. The gfp flags will be
148 * ops param is NULL, then the created zpool will not be evictable.
154 * Returns: New zpool on success, NULL on failure.
156 struct zpool *zpool_create_pool(const char *type, const char *name, gfp_t gfp,
160 struct zpool *zpool;
167 request_module("zpool-%s", type);
176 zpool = kmalloc(sizeof(*zpool), gfp);
177 if (!zpool) {
178 pr_err("couldn't create zpool - out of memory\n");
183 zpool->driver = driver;
184 zpool->pool = driver->create(name, gfp, ops, zpool);
185 zpool->ops = ops;
186 zpool->evictable = driver->shrink && ops && ops->evict;
187 zpool->can_sleep_mapped = driver->sleep_mapped;
189 if (!zpool->pool) {
192 kfree(zpool);
199 list_add(&zpool->list, &pools_head);
202 return zpool;
206 * zpool_destroy_pool() - Destroy a zpool
207 * @zpool: The zpool to destroy.
214 * This destroys an existing zpool. The zpool should not be in use.
216 void zpool_destroy_pool(struct zpool *zpool)
218 pr_debug("destroying pool type %s\n", zpool->driver->type);
221 list_del(&zpool->list);
223 zpool->driver->destroy(zpool->pool);
224 zpool_put_driver(zpool->driver);
225 kfree(zpool);
229 * zpool_get_type() - Get the type of the zpool
230 * @zpool: The zpool to check
236 * Returns: The type of zpool.
238 const char *zpool_get_type(struct zpool *zpool)
240 return zpool->driver->type;
244 * zpool_malloc_support_movable() - Check if the zpool supports
246 * @zpool: The zpool to check
248 * This returns if the zpool supports allocating movable memory.
252 * Returns: true if the zpool supports allocating movable memory, false if not
254 bool zpool_malloc_support_movable(struct zpool *zpool)
256 return zpool->driver->malloc_support_movable;
261 * @zpool: The zpool to allocate from.
275 int zpool_malloc(struct zpool *zpool, size_t size, gfp_t gfp,
278 return zpool->driver->malloc(zpool->pool, size, gfp, handle);
283 * @zpool: The zpool that allocated the memory.
295 void zpool_free(struct zpool *zpool, unsigned long handle)
297 zpool->driver->free(zpool->pool, handle);
302 * @zpool: The zpool to shrink.
317 int zpool_shrink(struct zpool *zpool, unsigned int pages,
320 return zpool->driver->shrink ?
321 zpool->driver->shrink(zpool->pool, pages, reclaimed) : -EINVAL;
326 * @zpool: The zpool that the handle was allocated from
346 void *zpool_map_handle(struct zpool *zpool, unsigned long handle,
349 return zpool->driver->map(zpool->pool, handle, mapmode);
354 * @zpool: The zpool that the handle was allocated from
362 void zpool_unmap_handle(struct zpool *zpool, unsigned long handle)
364 zpool->driver->unmap(zpool->pool, handle);
369 * @zpool: The zpool to check
373 * Returns: Total size of the zpool in bytes.
375 u64 zpool_get_total_size(struct zpool *zpool)
377 return zpool->driver->total_size(zpool->pool);
381 * zpool_evictable() - Test if zpool is potentially evictable
382 * @zpool: The zpool to test
393 bool zpool_evictable(struct zpool *zpool)
395 return zpool->evictable;
399 * zpool_can_sleep_mapped - Test if zpool can sleep when do mapped.
400 * @zpool: The zpool to test
402 * Returns: true if zpool can sleep; false otherwise.
404 bool zpool_can_sleep_mapped(struct zpool *zpool)
406 return zpool->can_sleep_mapped;