* [PATCH 0/2] mm:constify zpool/zs_pool char members @ 2015-09-10 11:48 Sergey Senozhatsky 2015-09-10 11:48 ` [PATCH 1/2] mm:zpool: constify struct zpool type Sergey Senozhatsky ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Sergey Senozhatsky @ 2015-09-10 11:48 UTC (permalink / raw) To: Andrew Morton Cc: Seth Jennings, Dan Streetman, Minchan Kim, linux-mm, linux-kernel, Sergey Senozhatsky, Sergey Senozhatsky Hi, Two trivial patches to constify zs_pool and zpool ->name and ->type members and functions' signatures that set/return them. Sergey SENOZHATSKY (2): mm:zpool: constify struct zpool type mm:zsmalloc: constify struct zs_pool name include/linux/zpool.h | 12 +++++++----- include/linux/zsmalloc.h | 2 +- mm/zbud.c | 2 +- mm/zpool.c | 12 ++++++------ mm/zsmalloc.c | 10 +++++----- 5 files changed, 20 insertions(+), 18 deletions(-) -- 2.5.1 -- 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
* [PATCH 1/2] mm:zpool: constify struct zpool type 2015-09-10 11:48 [PATCH 0/2] mm:constify zpool/zs_pool char members Sergey Senozhatsky @ 2015-09-10 11:48 ` Sergey Senozhatsky 2015-09-11 22:21 ` Andrew Morton 2015-09-10 11:48 ` [PATCH 2/2] mm:zsmalloc: constify struct zs_pool name Sergey Senozhatsky 2015-09-11 12:13 ` [PATCH 0/2] mm:constify zpool/zs_pool char members Sergey Senozhatsky 2 siblings, 1 reply; 6+ messages in thread From: Sergey Senozhatsky @ 2015-09-10 11:48 UTC (permalink / raw) To: Andrew Morton Cc: Seth Jennings, Dan Streetman, Minchan Kim, linux-mm, linux-kernel, Sergey Senozhatsky, Sergey SENOZHATSKY From: Sergey SENOZHATSKY <sergey.senozhatsky@gmail.com> Constify `struct zpool' ->type. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> --- include/linux/zpool.h | 8 ++++---- mm/zpool.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/zpool.h b/include/linux/zpool.h index 42f8ec9..2c136f4 100644 --- a/include/linux/zpool.h +++ b/include/linux/zpool.h @@ -36,12 +36,12 @@ enum zpool_mapmode { ZPOOL_MM_DEFAULT = ZPOOL_MM_RW }; -bool zpool_has_pool(char *type); +bool zpool_has_pool(const char *type); -struct zpool *zpool_create_pool(char *type, char *name, +struct zpool *zpool_create_pool(const 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); @@ -78,7 +78,7 @@ u64 zpool_get_total_size(struct zpool *pool); * with zpool. */ struct zpool_driver { - char *type; + const char *type; struct module *owner; atomic_t refcount; struct list_head list; diff --git a/mm/zpool.c b/mm/zpool.c index 8f670d3..2889d0d 100644 --- a/mm/zpool.c +++ b/mm/zpool.c @@ -18,7 +18,7 @@ #include <linux/zpool.h> struct zpool { - char *type; + const char *type; struct zpool_driver *driver; void *pool; @@ -73,7 +73,7 @@ int zpool_unregister_driver(struct zpool_driver *driver) } EXPORT_SYMBOL(zpool_unregister_driver); -static struct zpool_driver *zpool_get_driver(char *type) +static struct zpool_driver *zpool_get_driver(const char *type) { struct zpool_driver *driver; @@ -115,7 +115,7 @@ static void zpool_put_driver(struct zpool_driver *driver) * * Returns: true if @type pool is available, false if not */ -bool zpool_has_pool(char *type) +bool zpool_has_pool(const char *type) { struct zpool_driver *driver = zpool_get_driver(type); @@ -147,7 +147,7 @@ EXPORT_SYMBOL(zpool_has_pool); * * Returns: New zpool on success, NULL on failure. */ -struct zpool *zpool_create_pool(char *type, char *name, gfp_t gfp, +struct zpool *zpool_create_pool(const char *type, char *name, gfp_t gfp, const struct zpool_ops *ops) { struct zpool_driver *driver; @@ -228,7 +228,7 @@ void zpool_destroy_pool(struct zpool *zpool) * * Returns: The type of zpool. */ -char *zpool_get_type(struct zpool *zpool) +const char *zpool_get_type(struct zpool *zpool) { return zpool->type; } -- 2.5.1 -- 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 1/2] mm:zpool: constify struct zpool type 2015-09-10 11:48 ` [PATCH 1/2] mm:zpool: constify struct zpool type Sergey Senozhatsky @ 2015-09-11 22:21 ` Andrew Morton 2015-09-12 0:29 ` Sergey Senozhatsky 0 siblings, 1 reply; 6+ messages in thread From: Andrew Morton @ 2015-09-11 22:21 UTC (permalink / raw) To: Sergey Senozhatsky Cc: Seth Jennings, Dan Streetman, Minchan Kim, linux-mm, linux-kernel, Sergey Senozhatsky On Thu, 10 Sep 2015 20:48:37 +0900 Sergey Senozhatsky <sergey.senozhatsky@gmail.com> wrote: > From: Sergey SENOZHATSKY <sergey.senozhatsky@gmail.com> > > Constify `struct zpool' ->type. > I think I prefer Dan's patch, which deletes stuff: From: Dan Streetman <ddstreet@ieee.org> Subject: zpool: remove redundant zpool->type string, const-ify zpool_get_type 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> --- include/linux/zpool.h | 2 +- mm/zpool.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff -puN include/linux/zpool.h~zpool-remove-redundant-zpool-type-string-const-ify-zpool_get_type include/linux/zpool.h --- a/include/linux/zpool.h~zpool-remove-redundant-zpool-type-string-const-ify-zpool_get_type +++ a/include/linux/zpool.h @@ -41,7 +41,7 @@ bool zpool_has_pool(char *type); 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); diff -puN mm/zpool.c~zpool-remove-redundant-zpool-type-string-const-ify-zpool_get_type mm/zpool.c --- a/mm/zpool.c~zpool-remove-redundant-zpool-type-string-const-ify-zpool_get_type +++ a/mm/zpool.c @@ -18,8 +18,6 @@ #include <linux/zpool.h> struct zpool { - char *type; - struct zpool_driver *driver; void *pool; const struct zpool_ops *ops; @@ -73,6 +71,7 @@ int zpool_unregister_driver(struct zpool } EXPORT_SYMBOL(zpool_unregister_driver); +/* this assumes @type is null-terminated. */ static struct zpool_driver *zpool_get_driver(char *type) { struct zpool_driver *driver; @@ -113,6 +112,8 @@ static void zpool_put_driver(struct zpoo * 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) @@ -145,6 +146,8 @@ EXPORT_SYMBOL(zpool_has_pool); * * 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, @@ -174,7 +177,6 @@ struct zpool *zpool_create_pool(char *ty return NULL; } - zpool->type = driver->type; zpool->driver = driver; zpool->pool = driver->create(name, gfp, ops, zpool); zpool->ops = ops; @@ -208,7 +210,7 @@ struct zpool *zpool_create_pool(char *ty */ 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); @@ -228,9 +230,9 @@ void zpool_destroy_pool(struct zpool *zp * * Returns: The type of zpool. */ -char *zpool_get_type(struct zpool *zpool) +const char *zpool_get_type(struct zpool *zpool) { - return zpool->type; + return zpool->driver->type; } /** _ -- 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 1/2] mm:zpool: constify struct zpool type 2015-09-11 22:21 ` Andrew Morton @ 2015-09-12 0:29 ` Sergey Senozhatsky 0 siblings, 0 replies; 6+ messages in thread From: Sergey Senozhatsky @ 2015-09-12 0:29 UTC (permalink / raw) To: Andrew Morton Cc: Sergey Senozhatsky, Seth Jennings, Dan Streetman, Minchan Kim, linux-mm, linux-kernel, Sergey Senozhatsky On (09/11/15 15:21), Andrew Morton wrote: > > From: Sergey SENOZHATSKY <sergey.senozhatsky@gmail.com> > > > > Constify `struct zpool' ->type. > > > > I think I prefer Dan's patch, which deletes stuff: Sure, agree. Somehow I overlooked it. -ss > From: Dan Streetman <ddstreet@ieee.org> > Subject: zpool: remove redundant zpool->type string, const-ify zpool_get_type > > 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> > --- > > include/linux/zpool.h | 2 +- > mm/zpool.c | 14 ++++++++------ > 2 files changed, 9 insertions(+), 7 deletions(-) > > diff -puN include/linux/zpool.h~zpool-remove-redundant-zpool-type-string-const-ify-zpool_get_type include/linux/zpool.h > --- a/include/linux/zpool.h~zpool-remove-redundant-zpool-type-string-const-ify-zpool_get_type > +++ a/include/linux/zpool.h > @@ -41,7 +41,7 @@ bool zpool_has_pool(char *type); > 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); > > diff -puN mm/zpool.c~zpool-remove-redundant-zpool-type-string-const-ify-zpool_get_type mm/zpool.c > --- a/mm/zpool.c~zpool-remove-redundant-zpool-type-string-const-ify-zpool_get_type > +++ a/mm/zpool.c > @@ -18,8 +18,6 @@ > #include <linux/zpool.h> > > struct zpool { > - char *type; > - > struct zpool_driver *driver; > void *pool; > const struct zpool_ops *ops; > @@ -73,6 +71,7 @@ int zpool_unregister_driver(struct zpool > } > EXPORT_SYMBOL(zpool_unregister_driver); > > +/* this assumes @type is null-terminated. */ > static struct zpool_driver *zpool_get_driver(char *type) > { > struct zpool_driver *driver; > @@ -113,6 +112,8 @@ static void zpool_put_driver(struct zpoo > * 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) > @@ -145,6 +146,8 @@ EXPORT_SYMBOL(zpool_has_pool); > * > * 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, > @@ -174,7 +177,6 @@ struct zpool *zpool_create_pool(char *ty > return NULL; > } > > - zpool->type = driver->type; > zpool->driver = driver; > zpool->pool = driver->create(name, gfp, ops, zpool); > zpool->ops = ops; > @@ -208,7 +210,7 @@ struct zpool *zpool_create_pool(char *ty > */ > 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); > @@ -228,9 +230,9 @@ void zpool_destroy_pool(struct zpool *zp > * > * Returns: The type of zpool. > */ > -char *zpool_get_type(struct zpool *zpool) > +const char *zpool_get_type(struct zpool *zpool) > { > - return zpool->type; > + return zpool->driver->type; > } > > /** > _ > -- 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
* [PATCH 2/2] mm:zsmalloc: constify struct zs_pool name 2015-09-10 11:48 [PATCH 0/2] mm:constify zpool/zs_pool char members Sergey Senozhatsky 2015-09-10 11:48 ` [PATCH 1/2] mm:zpool: constify struct zpool type Sergey Senozhatsky @ 2015-09-10 11:48 ` Sergey Senozhatsky 2015-09-11 12:13 ` [PATCH 0/2] mm:constify zpool/zs_pool char members Sergey Senozhatsky 2 siblings, 0 replies; 6+ messages in thread From: Sergey Senozhatsky @ 2015-09-10 11:48 UTC (permalink / raw) To: Andrew Morton Cc: Seth Jennings, Dan Streetman, Minchan Kim, linux-mm, linux-kernel, Sergey Senozhatsky, Sergey SENOZHATSKY From: Sergey SENOZHATSKY <sergey.senozhatsky@gmail.com> Constify `struct zs_pool' ->name. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> --- include/linux/zpool.h | 6 ++++-- include/linux/zsmalloc.h | 2 +- mm/zbud.c | 2 +- mm/zpool.c | 4 ++-- mm/zsmalloc.c | 10 +++++----- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/include/linux/zpool.h b/include/linux/zpool.h index 2c136f4..8edb451 100644 --- a/include/linux/zpool.h +++ b/include/linux/zpool.h @@ -38,7 +38,7 @@ enum zpool_mapmode { bool zpool_has_pool(const char *type); -struct zpool *zpool_create_pool(const char *type, char *name, +struct zpool *zpool_create_pool(const char *type, const char *name, gfp_t gfp, const struct zpool_ops *ops); const char *zpool_get_type(struct zpool *pool); @@ -83,7 +83,9 @@ struct zpool_driver { atomic_t refcount; struct list_head list; - void *(*create)(char *name, gfp_t gfp, const struct zpool_ops *ops, + void *(*create)(const char *name, + gfp_t gfp, + const struct zpool_ops *ops, struct zpool *zpool); void (*destroy)(void *pool); diff --git a/include/linux/zsmalloc.h b/include/linux/zsmalloc.h index 6398dfa..34eb160 100644 --- a/include/linux/zsmalloc.h +++ b/include/linux/zsmalloc.h @@ -41,7 +41,7 @@ struct zs_pool_stats { struct zs_pool; -struct zs_pool *zs_create_pool(char *name, gfp_t flags); +struct zs_pool *zs_create_pool(const char *name, gfp_t flags); void zs_destroy_pool(struct zs_pool *pool); unsigned long zs_malloc(struct zs_pool *pool, size_t size); diff --git a/mm/zbud.c b/mm/zbud.c index fa48bcdf..d8a181f 100644 --- a/mm/zbud.c +++ b/mm/zbud.c @@ -137,7 +137,7 @@ static const struct zbud_ops zbud_zpool_ops = { .evict = zbud_zpool_evict }; -static void *zbud_zpool_create(char *name, gfp_t gfp, +static void *zbud_zpool_create(const char *name, gfp_t gfp, const struct zpool_ops *zpool_ops, struct zpool *zpool) { diff --git a/mm/zpool.c b/mm/zpool.c index 2889d0d..1247c28 100644 --- a/mm/zpool.c +++ b/mm/zpool.c @@ -147,8 +147,8 @@ EXPORT_SYMBOL(zpool_has_pool); * * Returns: New zpool on success, NULL on failure. */ -struct zpool *zpool_create_pool(const char *type, char *name, gfp_t gfp, - const struct zpool_ops *ops) +struct zpool *zpool_create_pool(const char *type, const char *name, + gfp_t gfp, const struct zpool_ops *ops) { struct zpool_driver *driver; struct zpool *zpool; diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index f135b1b..8b8e0da 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -237,7 +237,7 @@ struct link_free { }; struct zs_pool { - char *name; + const char *name; struct size_class **size_class; struct kmem_cache *handle_cachep; @@ -311,7 +311,7 @@ static void record_obj(unsigned long handle, unsigned long obj) #ifdef CONFIG_ZPOOL -static void *zs_zpool_create(char *name, gfp_t gfp, +static void *zs_zpool_create(const char *name, gfp_t gfp, const struct zpool_ops *zpool_ops, struct zpool *zpool) { @@ -548,7 +548,7 @@ static const struct file_operations zs_stat_size_ops = { .release = single_release, }; -static int zs_pool_stat_create(char *name, struct zs_pool *pool) +static int zs_pool_stat_create(const char *name, struct zs_pool *pool) { struct dentry *entry; @@ -588,7 +588,7 @@ static void __exit zs_stat_exit(void) { } -static inline int zs_pool_stat_create(char *name, struct zs_pool *pool) +static inline int zs_pool_stat_create(const char *name, struct zs_pool *pool) { return 0; } @@ -1866,7 +1866,7 @@ static int zs_register_shrinker(struct zs_pool *pool) * On success, a pointer to the newly created pool is returned, * otherwise NULL. */ -struct zs_pool *zs_create_pool(char *name, gfp_t flags) +struct zs_pool *zs_create_pool(const char *name, gfp_t flags) { int i; struct zs_pool *pool; -- 2.5.1 -- 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 0/2] mm:constify zpool/zs_pool char members 2015-09-10 11:48 [PATCH 0/2] mm:constify zpool/zs_pool char members Sergey Senozhatsky 2015-09-10 11:48 ` [PATCH 1/2] mm:zpool: constify struct zpool type Sergey Senozhatsky 2015-09-10 11:48 ` [PATCH 2/2] mm:zsmalloc: constify struct zs_pool name Sergey Senozhatsky @ 2015-09-11 12:13 ` Sergey Senozhatsky 2 siblings, 0 replies; 6+ messages in thread From: Sergey Senozhatsky @ 2015-09-11 12:13 UTC (permalink / raw) To: Sergey Senozhatsky Cc: Andrew Morton, Seth Jennings, Dan Streetman, Minchan Kim, linux-mm, linux-kernel, Sergey Senozhatsky On (09/10/15 20:48), Sergey Senozhatsky wrote: > Two trivial patches to constify zs_pool and zpool ->name and ->type > members and functions' signatures that set/return them. > oh.. um.. somehow linux-next 20150910 contained zpool_has_pool() function, which I can't find any more. I'll resend the patch set. -ss > Sergey SENOZHATSKY (2): > mm:zpool: constify struct zpool type > mm:zsmalloc: constify struct zs_pool name > > include/linux/zpool.h | 12 +++++++----- > include/linux/zsmalloc.h | 2 +- > mm/zbud.c | 2 +- > mm/zpool.c | 12 ++++++------ > mm/zsmalloc.c | 10 +++++----- > 5 files changed, 20 insertions(+), 18 deletions(-) > > -- > 2.5.1 > -- 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-09-12 0:30 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-09-10 11:48 [PATCH 0/2] mm:constify zpool/zs_pool char members Sergey Senozhatsky 2015-09-10 11:48 ` [PATCH 1/2] mm:zpool: constify struct zpool type Sergey Senozhatsky 2015-09-11 22:21 ` Andrew Morton 2015-09-12 0:29 ` Sergey Senozhatsky 2015-09-10 11:48 ` [PATCH 2/2] mm:zsmalloc: constify struct zs_pool name Sergey Senozhatsky 2015-09-11 12:13 ` [PATCH 0/2] mm:constify zpool/zs_pool char members Sergey Senozhatsky
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).