0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef _ZPOOL_H_
0013 #define _ZPOOL_H_
0014
0015 struct zpool;
0016
0017 struct zpool_ops {
0018 int (*evict)(struct zpool *pool, unsigned long handle);
0019 };
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 enum zpool_mapmode {
0033 ZPOOL_MM_RW,
0034 ZPOOL_MM_RO,
0035 ZPOOL_MM_WO,
0036
0037 ZPOOL_MM_DEFAULT = ZPOOL_MM_RW
0038 };
0039
0040 bool zpool_has_pool(char *type);
0041
0042 struct zpool *zpool_create_pool(const char *type, const char *name,
0043 gfp_t gfp, const struct zpool_ops *ops);
0044
0045 const char *zpool_get_type(struct zpool *pool);
0046
0047 void zpool_destroy_pool(struct zpool *pool);
0048
0049 bool zpool_malloc_support_movable(struct zpool *pool);
0050
0051 int zpool_malloc(struct zpool *pool, size_t size, gfp_t gfp,
0052 unsigned long *handle);
0053
0054 void zpool_free(struct zpool *pool, unsigned long handle);
0055
0056 int zpool_shrink(struct zpool *pool, unsigned int pages,
0057 unsigned int *reclaimed);
0058
0059 void *zpool_map_handle(struct zpool *pool, unsigned long handle,
0060 enum zpool_mapmode mm);
0061
0062 void zpool_unmap_handle(struct zpool *pool, unsigned long handle);
0063
0064 u64 zpool_get_total_size(struct zpool *pool);
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084 struct zpool_driver {
0085 char *type;
0086 struct module *owner;
0087 atomic_t refcount;
0088 struct list_head list;
0089
0090 void *(*create)(const char *name,
0091 gfp_t gfp,
0092 const struct zpool_ops *ops,
0093 struct zpool *zpool);
0094 void (*destroy)(void *pool);
0095
0096 bool malloc_support_movable;
0097 int (*malloc)(void *pool, size_t size, gfp_t gfp,
0098 unsigned long *handle);
0099 void (*free)(void *pool, unsigned long handle);
0100
0101 int (*shrink)(void *pool, unsigned int pages,
0102 unsigned int *reclaimed);
0103
0104 bool sleep_mapped;
0105 void *(*map)(void *pool, unsigned long handle,
0106 enum zpool_mapmode mm);
0107 void (*unmap)(void *pool, unsigned long handle);
0108
0109 u64 (*total_size)(void *pool);
0110 };
0111
0112 void zpool_register_driver(struct zpool_driver *driver);
0113
0114 int zpool_unregister_driver(struct zpool_driver *driver);
0115
0116 bool zpool_evictable(struct zpool *pool);
0117 bool zpool_can_sleep_mapped(struct zpool *pool);
0118
0119 #endif