* [PATCH] zpool: add zpool_has_pool()
@ 2015-05-29 15:12 ` Dan Streetman
0 siblings, 0 replies; 6+ messages in thread
From: Dan Streetman @ 2015-05-29 15:12 UTC (permalink / raw)
To: Andrew Morton
Cc: Ganesh Mahendran, Minchan Kim, Kees Cook, linux-kernel, linux-mm,
Dan Streetman
Add zpool_has_pool() function, indicating if the specified type of zpool
is available (i.e. zsmalloc or zbud). This allows checking if a pool is
available, without actually trying to allocate it, similar to
crypto_has_alg().
Signed-off-by: Dan Streetman <ddstreet@ieee.org>
---
include/linux/zpool.h | 2 ++
mm/zpool.c | 25 +++++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/include/linux/zpool.h b/include/linux/zpool.h
index 56529b3..31b79e2 100644
--- a/include/linux/zpool.h
+++ b/include/linux/zpool.h
@@ -36,6 +36,8 @@ enum zpool_mapmode {
ZPOOL_MM_DEFAULT = ZPOOL_MM_RW
};
+bool zpool_has_pool(char *type);
+
struct zpool *zpool_create_pool(char *type, char *name,
gfp_t gfp, struct zpool_ops *ops);
diff --git a/mm/zpool.c b/mm/zpool.c
index 884659d..bff40ce 100644
--- a/mm/zpool.c
+++ b/mm/zpool.c
@@ -127,6 +127,31 @@ static void zpool_put_driver(struct zpool_driver *driver)
}
/**
+ * zpool_has_pool() - Check if the pool driver is available
+ * @type The type of the zpool to check (e.g. zbud, zsmalloc)
+ *
+ * This checks if the @type pool driver is available.
+ *
+ * Returns: true if @type pool is available, false if not
+ */
+bool zpool_has_pool(char *type)
+{
+ struct zpool_driver *driver = zpool_get_driver(type);
+
+ if (!driver) {
+ request_module("zpool-%s", type);
+ driver = zpool_get_driver(type);
+ }
+
+ if (!driver)
+ return false;
+
+ zpool_put_driver(driver);
+ return true;
+}
+EXPORT_SYMBOL(zpool_has_pool);
+
+/**
* zpool_create_pool() - Create a new zpool
* @type The type of the zpool to create (e.g. zbud, zsmalloc)
* @name The name of the zpool (e.g. zram0, zswap)
--
2.1.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] zpool: add zpool_has_pool()
@ 2015-05-29 15:12 ` Dan Streetman
0 siblings, 0 replies; 6+ messages in thread
From: Dan Streetman @ 2015-05-29 15:12 UTC (permalink / raw)
To: Andrew Morton
Cc: Ganesh Mahendran, Minchan Kim, Kees Cook, linux-kernel, linux-mm,
Dan Streetman
Add zpool_has_pool() function, indicating if the specified type of zpool
is available (i.e. zsmalloc or zbud). This allows checking if a pool is
available, without actually trying to allocate it, similar to
crypto_has_alg().
Signed-off-by: Dan Streetman <ddstreet@ieee.org>
---
include/linux/zpool.h | 2 ++
mm/zpool.c | 25 +++++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/include/linux/zpool.h b/include/linux/zpool.h
index 56529b3..31b79e2 100644
--- a/include/linux/zpool.h
+++ b/include/linux/zpool.h
@@ -36,6 +36,8 @@ enum zpool_mapmode {
ZPOOL_MM_DEFAULT = ZPOOL_MM_RW
};
+bool zpool_has_pool(char *type);
+
struct zpool *zpool_create_pool(char *type, char *name,
gfp_t gfp, struct zpool_ops *ops);
diff --git a/mm/zpool.c b/mm/zpool.c
index 884659d..bff40ce 100644
--- a/mm/zpool.c
+++ b/mm/zpool.c
@@ -127,6 +127,31 @@ static void zpool_put_driver(struct zpool_driver *driver)
}
/**
+ * zpool_has_pool() - Check if the pool driver is available
+ * @type The type of the zpool to check (e.g. zbud, zsmalloc)
+ *
+ * This checks if the @type pool driver is available.
+ *
+ * Returns: true if @type pool is available, false if not
+ */
+bool zpool_has_pool(char *type)
+{
+ struct zpool_driver *driver = zpool_get_driver(type);
+
+ if (!driver) {
+ request_module("zpool-%s", type);
+ driver = zpool_get_driver(type);
+ }
+
+ if (!driver)
+ return false;
+
+ zpool_put_driver(driver);
+ return true;
+}
+EXPORT_SYMBOL(zpool_has_pool);
+
+/**
* zpool_create_pool() - Create a new zpool
* @type The type of the zpool to create (e.g. zbud, zsmalloc)
* @name The name of the zpool (e.g. zram0, zswap)
--
2.1.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] zpool: add zpool_has_pool()
2015-05-29 15:12 ` Dan Streetman
@ 2015-05-29 21:37 ` Andrew Morton
-1 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2015-05-29 21:37 UTC (permalink / raw)
To: Dan Streetman
Cc: Ganesh Mahendran, Minchan Kim, Kees Cook, linux-kernel, linux-mm
On Fri, 29 May 2015 11:12:18 -0400 Dan Streetman <ddstreet@ieee.org> wrote:
> Add zpool_has_pool() function, indicating if the specified type of zpool
> is available (i.e. zsmalloc or zbud). This allows checking if a pool is
> available, without actually trying to allocate it, similar to
> crypto_has_alg().
>
> ...
>
> +bool zpool_has_pool(char *type);
This has no callers.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] zpool: add zpool_has_pool()
@ 2015-05-29 21:37 ` Andrew Morton
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2015-05-29 21:37 UTC (permalink / raw)
To: Dan Streetman
Cc: Ganesh Mahendran, Minchan Kim, Kees Cook, linux-kernel, linux-mm
On Fri, 29 May 2015 11:12:18 -0400 Dan Streetman <ddstreet@ieee.org> wrote:
> Add zpool_has_pool() function, indicating if the specified type of zpool
> is available (i.e. zsmalloc or zbud). This allows checking if a pool is
> available, without actually trying to allocate it, similar to
> crypto_has_alg().
>
> ...
>
> +bool zpool_has_pool(char *type);
This has no callers.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] zpool: add zpool_has_pool()
2015-05-29 21:37 ` Andrew Morton
@ 2015-06-01 11:14 ` Dan Streetman
-1 siblings, 0 replies; 6+ messages in thread
From: Dan Streetman @ 2015-06-01 11:14 UTC (permalink / raw)
To: Andrew Morton
Cc: Ganesh Mahendran, Minchan Kim, Kees Cook, linux-kernel, Linux-MM
On Fri, May 29, 2015 at 5:37 PM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Fri, 29 May 2015 11:12:18 -0400 Dan Streetman <ddstreet@ieee.org> wrote:
>
>> Add zpool_has_pool() function, indicating if the specified type of zpool
>> is available (i.e. zsmalloc or zbud). This allows checking if a pool is
>> available, without actually trying to allocate it, similar to
>> crypto_has_alg().
>>
>> ...
>>
>> +bool zpool_has_pool(char *type);
>
> This has no callers.
Yes, I have a few patches coming up for zswap, that use this. I was
trying to get the simple patches in first, but I can include this in
the patch series that uses it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] zpool: add zpool_has_pool()
@ 2015-06-01 11:14 ` Dan Streetman
0 siblings, 0 replies; 6+ messages in thread
From: Dan Streetman @ 2015-06-01 11:14 UTC (permalink / raw)
To: Andrew Morton
Cc: Ganesh Mahendran, Minchan Kim, Kees Cook, linux-kernel, Linux-MM
On Fri, May 29, 2015 at 5:37 PM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Fri, 29 May 2015 11:12:18 -0400 Dan Streetman <ddstreet@ieee.org> wrote:
>
>> Add zpool_has_pool() function, indicating if the specified type of zpool
>> is available (i.e. zsmalloc or zbud). This allows checking if a pool is
>> available, without actually trying to allocate it, similar to
>> crypto_has_alg().
>>
>> ...
>>
>> +bool zpool_has_pool(char *type);
>
> This has no callers.
Yes, I have a few patches coming up for zswap, that use this. I was
trying to get the simple patches in first, but I can include this in
the patch series that uses it.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-06-01 11:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-29 15:12 [PATCH] zpool: add zpool_has_pool() Dan Streetman
2015-05-29 15:12 ` Dan Streetman
2015-05-29 21:37 ` Andrew Morton
2015-05-29 21:37 ` Andrew Morton
2015-06-01 11:14 ` Dan Streetman
2015-06-01 11:14 ` Dan Streetman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.