diff options
author | Amar Tumballi <amar@gluster.com> | 2010-08-12 01:54:38 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-08-12 00:45:48 -0700 |
commit | 78615ceea81479b38af43697766bcc04421a256d (patch) | |
tree | f5c95b96121abcd4fa0a8f6ce2f6c5e9d2df8366 /xlators/mount | |
parent | 553aa029de1817ae182cc86c1d00f8eb8ff52b50 (diff) |
logging enhancements
* per translator loglevel introduced, if set, it will override process
wide log level.
* with extended attribute 'trusted.glusterfs.<xlator-name>.set-log-level'
with the value being '<LOGLEVEL>', one can change log level of particular
translator.
* with extended attribute 'trusted.glusterfs.syslog' with the value
'<BOOLEAN>', one can enable disable syslog for gluster
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 601 (Enable changing 'log-level' of GlusterFS process at runtime)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=601
Diffstat (limited to 'xlators/mount')
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.c | 14 | ||||
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.h | 2 | ||||
-rw-r--r-- | xlators/mount/fuse/src/fuse-helpers.c | 88 |
3 files changed, 103 insertions, 1 deletions
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index ea5b5ae38ad..ac8295b96de 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -2290,6 +2290,15 @@ fuse_setxattr (xlator_t *this, fuse_in_header_t *finh, void *msg) } #endif + /* Check if the command is for changing the log + level of process or specific xlator */ + ret = is_gf_log_command (this, name, value); + if (ret >= 0) { + send_fuse_err (this, finh, ret); + GF_FREE (finh); + return; + } + GET_STATE (this, finh, state); state->size = fsi->size; ret = fuse_loc_fill (&state->loc, state, finh->nodeid, 0, NULL); @@ -2311,6 +2320,7 @@ fuse_setxattr (xlator_t *this, fuse_in_header_t *finh, void *msg) "%"PRIu64": SETXATTR dict allocation failed", finh->unique); + send_fuse_err (this, finh, ENOMEM); free_fuse_state (state); return; } @@ -2749,7 +2759,6 @@ fuse_setlk (xlator_t *this, fuse_in_header_t *finh, void *msg) return; } - static void fuse_init (xlator_t *this, fuse_in_header_t *finh, void *msg) { @@ -3001,6 +3010,9 @@ fuse_thread_proc (void *data) priv->msg0_len_p = &iov_in[0].iov_len; for (;;) { + /* THIS has to be reset here */ + THIS = this; + if (priv->init_recvd) fuse_graph_sync (this); diff --git a/xlators/mount/fuse/src/fuse-bridge.h b/xlators/mount/fuse/src/fuse-bridge.h index 8165053e06f..afefd815a14 100644 --- a/xlators/mount/fuse/src/fuse-bridge.h +++ b/xlators/mount/fuse/src/fuse-bridge.h @@ -27,6 +27,7 @@ #include <dirent.h> #include <sys/mount.h> #include <sys/time.h> +#include <fnmatch.h> #ifndef _CONFIG_H #define _CONFIG_H @@ -273,5 +274,6 @@ xlator_t *fuse_state_subvol (fuse_state_t *state); xlator_t *fuse_active_subvol (xlator_t *fuse); inode_t *fuse_ino_to_inode (uint64_t ino, xlator_t *fuse); int fuse_resolve_and_resume (fuse_state_t *state, fuse_resume_fn_t fn); +int is_gf_log_command (xlator_t *this, const char *name, char *value); #endif /* _GF_FUSE_BRIDGE_H_ */ diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c index d478d014db0..9a6b13514aa 100644 --- a/xlators/mount/fuse/src/fuse-helpers.c +++ b/xlators/mount/fuse/src/fuse-helpers.c @@ -298,3 +298,91 @@ gf_fuse_stat2attr (struct iatt *st, struct fuse_attr *fa) fa->flags = 0; #endif } + + +int +is_gf_log_command (xlator_t *this, const char *name, char *value) +{ + fuse_private_t *priv = NULL; + xlator_t *trav = NULL; + char key[1024] = {0,}; + int ret = -1; + int log_level = -1; + gf_boolean_t syslog_flag = 0; + + priv = this->private; + + if (!strcmp ("trusted.glusterfs.syslog", name)) { + ret = gf_string2boolean (value, &syslog_flag); + if (ret) { + ret = EOPNOTSUPP; + goto out; + } + if (syslog_flag) + gf_log_enable_syslog (); + else + gf_log_disable_syslog (); + + goto out; + } + + if (fnmatch ("trusted.glusterfs*set-log-level", name, FNM_NOESCAPE)) + goto out; + + 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) { + ret = EOPNOTSUPP; + goto out; + } + + /* Some crude way to change the log-level of process */ + if (!strcmp (name, "trusted.glusterfs.set-log-level")) { + /* */ + gf_log ("glusterfs", gf_log_get_loglevel(), + "setting log level to %d (old-value=%d)", + log_level, gf_log_get_loglevel()); + gf_log_set_loglevel (log_level); + ret = 0; + goto out; + } + if (!strcmp (name, "trusted.glusterfs.fuse.set-log-level")) { + /* */ + gf_log (this->name, gf_log_get_xl_loglevel (this), + "setting log level to %d (old-value=%d)", + log_level, gf_log_get_xl_loglevel (this)); + gf_log_set_xl_loglevel (this, log_level); + ret = 0; + goto out; + } + + trav = priv->active_subvol; + while (trav) { + snprintf (key, 1024, "trusted.glusterfs.%s.set-log-level", + trav->name); + if (fnmatch (name, key, FNM_NOESCAPE) == 0) { + gf_log (trav->name, gf_log_get_xl_loglevel (trav), + "setting log level to %d (old-value=%d)", + log_level, gf_log_get_xl_loglevel (trav)); + gf_log_set_xl_loglevel (trav, log_level); + ret = 0; + } + trav = trav->next; + } +out: + return ret; +} |