Make the return type of zpool_get_type const; the string belongs to the
zpool driver and should not be modified. Remove the redundant type field
in the struct zpool; it is private to zpool.c and isn't needed since
->driver->type can be used directly. Add comments indicating strings must
be null-terminated.
Signed-off-by: Dan Streetman <ddstreet@ieee.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Seth Jennings <sjennings@variantweb.net>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
struct zpool *zpool_create_pool(char *type, char *name,
gfp_t gfp, const struct zpool_ops *ops);
struct zpool *zpool_create_pool(char *type, char *name,
gfp_t gfp, const struct zpool_ops *ops);
-char *zpool_get_type(struct zpool *pool);
+const char *zpool_get_type(struct zpool *pool);
void zpool_destroy_pool(struct zpool *pool);
void zpool_destroy_pool(struct zpool *pool);
#include <linux/zpool.h>
struct zpool {
#include <linux/zpool.h>
struct zpool {
struct zpool_driver *driver;
void *pool;
const struct zpool_ops *ops;
struct zpool_driver *driver;
void *pool;
const struct zpool_ops *ops;
}
EXPORT_SYMBOL(zpool_unregister_driver);
}
EXPORT_SYMBOL(zpool_unregister_driver);
+/* this assumes @type is null-terminated. */
static struct zpool_driver *zpool_get_driver(char *type)
{
struct zpool_driver *driver;
static struct zpool_driver *zpool_get_driver(char *type)
{
struct zpool_driver *driver;
* not be loaded, and calling @zpool_create_pool() with the pool type will
* fail.
*
* not be loaded, and calling @zpool_create_pool() with the pool type will
* fail.
*
+ * The @type string must be null-terminated.
+ *
* Returns: true if @type pool is available, false if not
*/
bool zpool_has_pool(char *type)
* Returns: true if @type pool is available, false if not
*/
bool zpool_has_pool(char *type)
*
* Implementations must guarantee this to be thread-safe.
*
*
* Implementations must guarantee this to be thread-safe.
*
+ * The @type and @name strings must be null-terminated.
+ *
* Returns: New zpool on success, NULL on failure.
*/
struct zpool *zpool_create_pool(char *type, char *name, gfp_t gfp,
* Returns: New zpool on success, NULL on failure.
*/
struct zpool *zpool_create_pool(char *type, char *name, gfp_t gfp,
- zpool->type = driver->type;
zpool->driver = driver;
zpool->pool = driver->create(name, gfp, ops, zpool);
zpool->ops = ops;
zpool->driver = driver;
zpool->pool = driver->create(name, gfp, ops, zpool);
zpool->ops = ops;
*/
void zpool_destroy_pool(struct zpool *zpool)
{
*/
void zpool_destroy_pool(struct zpool *zpool)
{
- pr_debug("destroying pool type %s\n", zpool->type);
+ pr_debug("destroying pool type %s\n", zpool->driver->type);
spin_lock(&pools_lock);
list_del(&zpool->list);
spin_lock(&pools_lock);
list_del(&zpool->list);
*
* Returns: The type of zpool.
*/
*
* Returns: The type of zpool.
*/
-char *zpool_get_type(struct zpool *zpool)
+const char *zpool_get_type(struct zpool *zpool)
+ return zpool->driver->type;