]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/linux/zpool.h
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * zpool memory storage api
5 * Copyright (C) 2014 Dan Streetman
7 * This is a common frontend for the zbud and zsmalloc memory
8 * storage pool implementations. Typically, this is used to
9 * store compressed memory.
18 int (*evict
)(struct zpool
*pool
, unsigned long handle
);
22 * Control how a handle is mapped. It will be ignored if the
23 * implementation does not support it. Its use is optional.
24 * Note that this does not refer to memory protection, it
25 * refers to how the memory will be copied in/out if copying
26 * is necessary during mapping; read-write is the safest as
27 * it copies the existing memory in on map, and copies the
28 * changed memory back out on unmap. Write-only does not copy
29 * in the memory and should only be used for initialization.
30 * If in doubt, use ZPOOL_MM_DEFAULT which is read-write.
33 ZPOOL_MM_RW
, /* normal read-write mapping */
34 ZPOOL_MM_RO
, /* read-only (no copy-out at unmap time) */
35 ZPOOL_MM_WO
, /* write-only (no copy-in at map time) */
37 ZPOOL_MM_DEFAULT
= ZPOOL_MM_RW
40 bool zpool_has_pool(char *type
);
42 struct zpool
*zpool_create_pool(const char *type
, const char *name
,
43 gfp_t gfp
, const struct zpool_ops
*ops
);
45 const char *zpool_get_type(struct zpool
*pool
);
47 void zpool_destroy_pool(struct zpool
*pool
);
49 int zpool_malloc(struct zpool
*pool
, size_t size
, gfp_t gfp
,
50 unsigned long *handle
);
52 void zpool_free(struct zpool
*pool
, unsigned long handle
);
54 int zpool_shrink(struct zpool
*pool
, unsigned int pages
,
55 unsigned int *reclaimed
);
57 void *zpool_map_handle(struct zpool
*pool
, unsigned long handle
,
58 enum zpool_mapmode mm
);
60 void zpool_unmap_handle(struct zpool
*pool
, unsigned long handle
);
62 u64
zpool_get_total_size(struct zpool
*pool
);
66 * struct zpool_driver - driver implementation for zpool
67 * @type: name of the driver.
68 * @list: entry in the list of zpool drivers.
69 * @create: create a new pool.
70 * @destroy: destroy a pool.
71 * @malloc: allocate mem from a pool.
72 * @free: free mem from a pool.
73 * @shrink: shrink the pool.
75 * @unmap: unmap a handle.
76 * @total_size: get total size of a pool.
78 * This is created by a zpool implementation and registered
85 struct list_head list
;
87 void *(*create
)(const char *name
,
89 const struct zpool_ops
*ops
,
91 void (*destroy
)(void *pool
);
93 int (*malloc
)(void *pool
, size_t size
, gfp_t gfp
,
94 unsigned long *handle
);
95 void (*free
)(void *pool
, unsigned long handle
);
97 int (*shrink
)(void *pool
, unsigned int pages
,
98 unsigned int *reclaimed
);
100 void *(*map
)(void *pool
, unsigned long handle
,
101 enum zpool_mapmode mm
);
102 void (*unmap
)(void *pool
, unsigned long handle
);
104 u64 (*total_size
)(void *pool
);
107 void zpool_register_driver(struct zpool_driver
*driver
);
109 int zpool_unregister_driver(struct zpool_driver
*driver
);
111 bool zpool_evictable(struct zpool
*pool
);