aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/zpool.h2
-rw-r--r--mm/zpool.c33
2 files changed, 35 insertions, 0 deletions
diff --git a/include/linux/zpool.h b/include/linux/zpool.h
index c924a28d9805..42f8ec992452 100644
--- a/include/linux/zpool.h
+++ b/include/linux/zpool.h
@@ -36,6 +36,8 @@ enum zpool_mapmode {
36 ZPOOL_MM_DEFAULT = ZPOOL_MM_RW 36 ZPOOL_MM_DEFAULT = ZPOOL_MM_RW
37}; 37};
38 38
39bool zpool_has_pool(char *type);
40
39struct zpool *zpool_create_pool(char *type, char *name, 41struct zpool *zpool_create_pool(char *type, char *name,
40 gfp_t gfp, const struct zpool_ops *ops); 42 gfp_t gfp, const struct zpool_ops *ops);
41 43
diff --git a/mm/zpool.c b/mm/zpool.c
index 68d2dd8ed2d8..8f670d3e8706 100644
--- a/mm/zpool.c
+++ b/mm/zpool.c
@@ -100,6 +100,39 @@ static void zpool_put_driver(struct zpool_driver *driver)
100} 100}
101 101
102/** 102/**
103 * zpool_has_pool() - Check if the pool driver is available
104 * @type The type of the zpool to check (e.g. zbud, zsmalloc)
105 *
106 * This checks if the @type pool driver is available. This will try to load
107 * the requested module, if needed, but there is no guarantee the module will
108 * still be loaded and available immediately after calling. If this returns
109 * true, the caller should assume the pool is available, but must be prepared
110 * to handle the @zpool_create_pool() returning failure. However if this
111 * returns false, the caller should assume the requested pool type is not
112 * available; either the requested pool type module does not exist, or could
113 * not be loaded, and calling @zpool_create_pool() with the pool type will
114 * fail.
115 *
116 * Returns: true if @type pool is available, false if not
117 */
118bool zpool_has_pool(char *type)
119{
120 struct zpool_driver *driver = zpool_get_driver(type);
121
122 if (!driver) {
123 request_module("zpool-%s", type);
124 driver = zpool_get_driver(type);
125 }
126
127 if (!driver)
128 return false;
129
130 zpool_put_driver(driver);
131 return true;
132}
133EXPORT_SYMBOL(zpool_has_pool);
134
135/**
103 * zpool_create_pool() - Create a new zpool 136 * zpool_create_pool() - Create a new zpool
104 * @type The type of the zpool to create (e.g. zbud, zsmalloc) 137 * @type The type of the zpool to create (e.g. zbud, zsmalloc)
105 * @name The name of the zpool (e.g. zram0, zswap) 138 * @name The name of the zpool (e.g. zram0, zswap)