From b9fc8953d8b4ea769114ecab287d89b71ee5aba1 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 19 Jun 2019 23:38:40 -0400 Subject: [PATCH] LU-4423 ldlm: discard varname in ldlm_pool. This allocated buffer serves no purpose. A constant string is copied into it, it is passed to some function which copies it out again, then the buffer is freed. Instead, we can pass the constant string to that function. Change-Id: I83ea8fc839da3933ebc34756fc5c06b86427ce7c Signed-off-by: NeilBrown Reviewed-on: https://review.whamcloud.com/35273 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Petros Koutoupis --- lustre/ldlm/ldlm_internal.h | 4 +--- lustre/ldlm/ldlm_pool.c | 16 ++++------------ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/lustre/ldlm/ldlm_internal.h b/lustre/ldlm/ldlm_internal.h index 136d9f5..3fac6fd 100644 --- a/lustre/ldlm/ldlm_internal.h +++ b/lustre/ldlm/ldlm_internal.h @@ -30,8 +30,6 @@ * Lustre is a trademark of Sun Microsystems, Inc. */ -#define MAX_STRING_SIZE 128 - extern int ldlm_srv_namespace_nr; extern int ldlm_cli_namespace_nr; extern struct mutex ldlm_srv_namespace_lock; @@ -346,7 +344,7 @@ static inline void ldlm_add_var(struct lprocfs_vars *vars, struct dentry *debugfs_entry, const char *name, void *data, const struct file_operations *ops) { - snprintf((char *)vars->name, MAX_STRING_SIZE, "%s", name); + vars->name = name; vars->data = data; vars->fops = ops; ldebugfs_add_vars(debugfs_entry, vars, NULL); diff --git a/lustre/ldlm/ldlm_pool.c b/lustre/ldlm/ldlm_pool.c index 3e74a40..9d47ac6 100644 --- a/lustre/ldlm/ldlm_pool.c +++ b/lustre/ldlm/ldlm_pool.c @@ -789,20 +789,15 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl) struct ldlm_namespace *ns = ldlm_pl2ns(pl); struct dentry *debugfs_ns_parent; struct lprocfs_vars pool_vars[2]; - char *var_name = NULL; int rc = 0; ENTRY; - OBD_ALLOC(var_name, MAX_STRING_SIZE + 1); - if (!var_name) - RETURN(-ENOMEM); - debugfs_ns_parent = ns->ns_debugfs_entry; if (IS_ERR_OR_NULL(debugfs_ns_parent)) { CERROR("%s: debugfs entry is not initialized\n", ldlm_ns_name(ns)); - GOTO(out_free_name, rc = -EINVAL); + GOTO(out, rc = -EINVAL); } pl->pl_debugfs_entry = ldebugfs_register("pool", debugfs_ns_parent, NULL, NULL); @@ -811,12 +806,10 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl) pl->pl_debugfs_entry = NULL; CERROR("%s: cannot create 'pool' debugfs entry: rc = %d\n", ldlm_ns_name(ns), rc); - GOTO(out_free_name, rc); + GOTO(out, rc); } - var_name[MAX_STRING_SIZE] = '\0'; memset(pool_vars, 0, sizeof(pool_vars)); - pool_vars[0].name = var_name; ldlm_add_var(&pool_vars[0], pl->pl_debugfs_entry, "state", pl, &lprocfs_pool_state_fops); @@ -824,7 +817,7 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl) pl->pl_stats = lprocfs_alloc_stats(LDLM_POOL_LAST_STAT - LDLM_POOL_FIRST_STAT, 0); if (!pl->pl_stats) - GOTO(out_free_name, rc = -ENOMEM); + GOTO(out, rc = -ENOMEM); lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANTED_STAT, LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV, @@ -863,8 +856,7 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl) pl->pl_stats); EXIT; -out_free_name: - OBD_FREE(var_name, MAX_STRING_SIZE + 1); +out: return rc; } -- 1.8.3.1