~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/zpool.h

Version: ~ [ linux-5.4-rc3 ] ~ [ linux-5.3.6 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.79 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.149 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.196 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.196 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.75 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * zpool memory storage api
  4  *
  5  * Copyright (C) 2014 Dan Streetman
  6  *
  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.
 10  */
 11 
 12 #ifndef _ZPOOL_H_
 13 #define _ZPOOL_H_
 14 
 15 struct zpool;
 16 
 17 struct zpool_ops {
 18         int (*evict)(struct zpool *pool, unsigned long handle);
 19 };
 20 
 21 /*
 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.
 31  */
 32 enum zpool_mapmode {
 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) */
 36 
 37         ZPOOL_MM_DEFAULT = ZPOOL_MM_RW
 38 };
 39 
 40 bool zpool_has_pool(char *type);
 41 
 42 struct zpool *zpool_create_pool(const char *type, const char *name,
 43                         gfp_t gfp, const struct zpool_ops *ops);
 44 
 45 const char *zpool_get_type(struct zpool *pool);
 46 
 47 void zpool_destroy_pool(struct zpool *pool);
 48 
 49 int zpool_malloc(struct zpool *pool, size_t size, gfp_t gfp,
 50                         unsigned long *handle);
 51 
 52 void zpool_free(struct zpool *pool, unsigned long handle);
 53 
 54 int zpool_shrink(struct zpool *pool, unsigned int pages,
 55                         unsigned int *reclaimed);
 56 
 57 void *zpool_map_handle(struct zpool *pool, unsigned long handle,
 58                         enum zpool_mapmode mm);
 59 
 60 void zpool_unmap_handle(struct zpool *pool, unsigned long handle);
 61 
 62 u64 zpool_get_total_size(struct zpool *pool);
 63 
 64 
 65 /**
 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.
 74  * @map:        map a handle.
 75  * @unmap:      unmap a handle.
 76  * @total_size: get total size of a pool.
 77  *
 78  * This is created by a zpool implementation and registered
 79  * with zpool.
 80  */
 81 struct zpool_driver {
 82         char *type;
 83         struct module *owner;
 84         atomic_t refcount;
 85         struct list_head list;
 86 
 87         void *(*create)(const char *name,
 88                         gfp_t gfp,
 89                         const struct zpool_ops *ops,
 90                         struct zpool *zpool);
 91         void (*destroy)(void *pool);
 92 
 93         int (*malloc)(void *pool, size_t size, gfp_t gfp,
 94                                 unsigned long *handle);
 95         void (*free)(void *pool, unsigned long handle);
 96 
 97         int (*shrink)(void *pool, unsigned int pages,
 98                                 unsigned int *reclaimed);
 99 
100         void *(*map)(void *pool, unsigned long handle,
101                                 enum zpool_mapmode mm);
102         void (*unmap)(void *pool, unsigned long handle);
103 
104         u64 (*total_size)(void *pool);
105 };
106 
107 void zpool_register_driver(struct zpool_driver *driver);
108 
109 int zpool_unregister_driver(struct zpool_driver *driver);
110 
111 bool zpool_evictable(struct zpool *pool);
112 
113 #endif
114 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp