Lines Matching +full:memory +full:- +full:mapped

1 // SPDX-License-Identifier: GPL-2.0-only
3 * zpool memory storage api
7 * This is a common frontend for memory storage pool implementations.
8 * Typically, this is used to store compressed memory.
30 * zpool_register_driver() - register a zpool implementation.
36 atomic_set(&driver->refcount, 0); in zpool_register_driver()
37 list_add(&driver->list, &drivers_head); in zpool_register_driver()
43 * zpool_unregister_driver() - unregister a zpool implementation.
57 refcount = atomic_read(&driver->refcount); in zpool_unregister_driver()
60 ret = -EBUSY; in zpool_unregister_driver()
62 list_del(&driver->list); in zpool_unregister_driver()
69 /* this assumes @type is null-terminated. */
76 if (!strcmp(driver->type, type)) { in zpool_get_driver()
77 bool got = try_module_get(driver->owner); in zpool_get_driver()
80 atomic_inc(&driver->refcount); in zpool_get_driver()
92 atomic_dec(&driver->refcount); in zpool_put_driver()
93 module_put(driver->owner); in zpool_put_driver()
97 * zpool_has_pool() - Check if the pool driver is available
110 * The @type string must be null-terminated.
119 request_module("zpool-%s", type); in zpool_has_pool()
132 * zpool_create_pool() - Create a new zpool
138 * used when allocating memory, if the implementation supports it. If the
141 * Implementations must guarantee this to be thread-safe.
143 * The @type and @name strings must be null-terminated.
157 request_module("zpool-%s", type); in zpool_create_pool()
168 pr_err("couldn't create zpool - out of memory\n"); in zpool_create_pool()
173 zpool->driver = driver; in zpool_create_pool()
174 zpool->pool = driver->create(name, gfp); in zpool_create_pool()
176 if (!zpool->pool) { in zpool_create_pool()
189 * zpool_destroy_pool() - Destroy a zpool
192 * Implementations must guarantee this to be thread-safe,
201 pr_debug("destroying pool type %s\n", zpool->driver->type); in zpool_destroy_pool()
203 zpool->driver->destroy(zpool->pool); in zpool_destroy_pool()
204 zpool_put_driver(zpool->driver); in zpool_destroy_pool()
209 * zpool_get_type() - Get the type of the zpool
214 * Implementations must guarantee this to be thread-safe.
220 return zpool->driver->type; in zpool_get_type()
224 * zpool_malloc_support_movable() - Check if the zpool supports
225 * allocating movable memory
228 * This returns if the zpool supports allocating movable memory.
230 * Implementations must guarantee this to be thread-safe.
232 * Returns: true if the zpool supports allocating movable memory, false if not
236 return zpool->driver->malloc_support_movable; in zpool_malloc_support_movable()
240 * zpool_malloc() - Allocate memory
242 * @size: The amount of memory to allocate.
243 * @gfp: The GFP flags to use when allocating memory.
246 * This allocates the requested amount of memory from the pool.
247 * The gfp flags will be used when allocating memory, if the
251 * Implementations must guarantee this to be thread-safe.
258 return zpool->driver->malloc(zpool->pool, size, gfp, handle); in zpool_malloc()
262 * zpool_free() - Free previously allocated memory
263 * @zpool: The zpool that allocated the memory.
264 * @handle: The handle to the memory to free.
266 * This frees previously allocated memory. This does not guarantee
267 * that the pool will actually free memory, only that the memory
270 * Implementations must guarantee this to be thread-safe,
277 zpool->driver->free(zpool->pool, handle); in zpool_free()
281 * zpool_map_handle() - Map a previously allocated handle into memory
284 * @mapmode: How the memory should be mapped
286 * This maps a previously allocated handle into memory. The @mapmode
287 * param indicates to the implementation how the memory will be
288 * used, i.e. read-only, write-only, read-write. If the
289 * implementation does not support it, the memory will be treated
290 * as read-write.
294 * actions. The code that uses the mapped handle should complete
295 * its operations on the mapped handle memory quickly and unmap
296 * as soon as possible. As the implementation may use per-cpu
297 * data, multiple handles should not be mapped concurrently on
300 * Returns: A pointer to the handle's mapped memory area.
305 return zpool->driver->map(zpool->pool, handle, mapmode); in zpool_map_handle()
309 * zpool_unmap_handle() - Unmap a previously mapped handle
313 * This unmaps a previously mapped handle. Any locks or other
315 * will be undone here. The memory area returned from
320 zpool->driver->unmap(zpool->pool, handle); in zpool_unmap_handle()
324 * zpool_get_total_size() - The total size of the pool
333 return zpool->driver->total_size(zpool->pool); in zpool_get_total_size()
337 * zpool_can_sleep_mapped - Test if zpool can sleep when do mapped.
340 * Some allocators enter non-preemptible context in ->map() callback (e.g.
341 * disable pagefaults) and exit that context in ->unmap(), which limits what
342 * we can do with the mapped object. For instance, we cannot wait for
351 return zpool->driver->sleep_mapped; in zpool_can_sleep_mapped()
355 MODULE_DESCRIPTION("Common API for compressed memory storage");