| Submitter | shishir gowda |
|---|---|
| Date | 2010-10-11 09:19:45 |
| Message ID | <20101011091945.GA24185@dev.gluster.com> |
| Download | mbox | patch |
| Permalink | /patch/5422/ |
| State | Accepted |
| Headers | show |
Comments
Shishir, On Mon, Oct 11, 2010 at 2:49 PM, shishir gowda <shishirng@gluster.com> wrote: > > Signed-off-by: shishir gowda <shishirng@gluster.com> > --- > xlators/mgmt/glusterd/src/glusterd-volgen.c | 32 ++++++++++++++++++++++++++- > xlators/mgmt/glusterd/src/glusterd-volgen.h | 1 + > 2 files changed, 32 insertions(+), 1 deletions(-) I think where you added validation is not really the right place. Translators themselves implement their option validation by means of the validate_options(), so this code should go to io-stats#validate_options(). Csaba
Hi Csaba, Ok, will move the check to iostats validate. With regards, Shishir ----- Original Message ----- From: "Csaba Henk" <csaba@gluster.com> To: "Shishir Nagaraja. Gowda" <shishirng@gluster.com> Cc: glusterfs@dev.gluster.com, "kaushik" <kaushikbv@gluster.com> Sent: Monday, October 11, 2010 4:18:15 PM Subject: Re: [PATCH BUG:1886] Add log-level validation for volume set command Shishir, On Mon, Oct 11, 2010 at 2:49 PM, shishir gowda <shishirng@gluster.com> wrote: > > Signed-off-by: shishir gowda <shishirng@gluster.com> > --- > xlators/mgmt/glusterd/src/glusterd-volgen.c | 32 ++++++++++++++++++++++++++- > xlators/mgmt/glusterd/src/glusterd-volgen.h | 1 + > 2 files changed, 32 insertions(+), 1 deletions(-) I think where you added validation is not really the right place. Translators themselves implement their option validation by means of the validate_options(), so this code should go to io-stats#validate_options(). Csaba
Patch
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index df4818d..9874499 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -738,6 +738,8 @@ loglevel_option_handler (glusterfs_graph_t *graph, !strstr (vme->key, role)) return 0; + if (glusterd_check_log_level(vme->value) == -1) + return -1; memcpy (&vme2, vme, sizeof (vme2)); vme2.option = "log-level"; @@ -1387,4 +1389,32 @@ glusterd_validate_reconfopts (glusterd_volinfo_t *volinfo, dict_t *val_dict, out: gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); return ret; -} \ No newline at end of file +} + +int +glusterd_check_log_level (const char *value) +{ + int log_level = -1; + + if (!strcasecmp (value, "CRITICAL")) { + log_level = GF_LOG_CRITICAL; + } else if (!strcasecmp (value, "ERROR")) { + log_level = GF_LOG_ERROR; + } else if (!strcasecmp (value, "WARNING")) { + log_level = GF_LOG_WARNING; + } else if (!strcasecmp (value, "INFO")) { + log_level = GF_LOG_INFO; + } else if (!strcasecmp (value, "DEBUG")) { + log_level = GF_LOG_DEBUG; + } else if (!strcasecmp (value, "TRACE")) { + log_level = GF_LOG_TRACE; + } else if (!strcasecmp (value, "NONE")) { + log_level = GF_LOG_NONE; + } + + if (log_level == -1) + gf_log ("", GF_LOG_ERROR, "Invalid log-level. possible values " + "are DEBUG|WARNING|ERROR|CRITICAL|NONE|TRACE"); + + return log_level; +} diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h index 16bf1c7..95f6138 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.h +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h @@ -41,4 +41,5 @@ int glusterd_delete_volfile (glusterd_volinfo_t *volinfo, int glusterd_volinfo_get (glusterd_volinfo_t *volinfo, char *key, char **value); +int glusterd_check_log_level (const char *log_level); #endif
Signed-off-by: shishir gowda <shishirng@gluster.com> --- xlators/mgmt/glusterd/src/glusterd-volgen.c | 32 ++++++++++++++++++++++++++- xlators/mgmt/glusterd/src/glusterd-volgen.h | 1 + 2 files changed, 32 insertions(+), 1 deletions(-)