From abc2a6b0b91a82bb59327cd2a4ca72b8954e1425 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Wed, 16 Mar 2011 09:39:21 +0000 Subject: glusterfsd: log enhancement Signed-off-by: Amar Tumballi Signed-off-by: Vijay Bellur BUG: 2346 (Log message enhancements in GlusterFS - phase 1) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2346 --- cli/src/cli.c | 3 +- glusterfsd/src/Makefile.am | 2 +- glusterfsd/src/glusterfsd-common.h | 30 ------ glusterfsd/src/glusterfsd-mgmt.c | 16 ++- glusterfsd/src/glusterfsd.c | 188 +++++++++++++++++++---------------- glusterfsd/src/glusterfsd.h | 55 +++++----- libglusterfs/src/globals.c | 82 +++------------ libglusterfs/src/globals.h | 6 -- libglusterfs/src/glusterfs.h | 7 ++ libglusterfs/src/logging.c | 104 +------------------ rpc/rpc-lib/src/rpc-transport.c | 22 ++-- xlators/mount/fuse/src/Makefile.am | 2 +- xlators/mount/fuse/src/fuse-bridge.h | 1 - 13 files changed, 188 insertions(+), 330 deletions(-) delete mode 100644 glusterfsd/src/glusterfsd-common.h diff --git a/cli/src/cli.c b/cli/src/cli.c index ef88d0420..d6c801967 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -247,8 +247,7 @@ logging_init (glusterfs_ctx_t *ctx) cmd_args = &ctx->cmd_args; if (gf_log_init (cmd_args->log_file) == -1) { - fprintf (stderr, - "failed to open logfile %s. exiting\n", + fprintf (stderr, "ERROR: failed to open logfile %s\n", cmd_args->log_file); return -1; } diff --git a/glusterfsd/src/Makefile.am b/glusterfsd/src/Makefile.am index 8cfe4b554..537eda0bb 100644 --- a/glusterfsd/src/Makefile.am +++ b/glusterfsd/src/Makefile.am @@ -9,7 +9,7 @@ glusterfsd_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ $(top_builddir)/rpc/xdr/src/libgfxdr.la \ $(GF_LDADD) glusterfsd_LDFLAGS = $(GF_LDFLAGS) $(GF_GLUSTERFS_LDFLAGS) -noinst_HEADERS = glusterfsd.h glusterfsd-common.h glusterfsd-mem-types.h +noinst_HEADERS = glusterfsd.h glusterfsd-mem-types.h AM_CFLAGS = -fPIC -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS)\ -I$(top_srcdir)/libglusterfs/src -DDATADIR=\"$(localstatedir)\" \ diff --git a/glusterfsd/src/glusterfsd-common.h b/glusterfsd/src/glusterfsd-common.h deleted file mode 100644 index a463f15ad..000000000 --- a/glusterfsd/src/glusterfsd-common.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - Copyright (c) 2006-2010 Gluster, Inc. - This file is part of GlusterFS. - - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see - . -*/ - -#ifndef __GLUSTERFSD_COMMON_H__ -#define __GLUSTERFSD_COMMON_H__ - -#define ZR_MOUNTPOINT_OPT "mountpoint" -#define ZR_ATTR_TIMEOUT_OPT "attribute-timeout" -#define ZR_ENTRY_TIMEOUT_OPT "entry-timeout" -#define ZR_DIRECT_IO_OPT "direct-io-mode" -#define ZR_STRICT_VOLFILE_CHECK "strict-volfile-check" -#define ZR_DUMP_FUSE "dump-fuse" - -#endif diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index 86bd482f7..77b18e972 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -425,6 +425,7 @@ mgmt_submit_request (void *req, call_frame_t *frame, if (req && sfunc) { ret = sfunc (iov, req); if (ret == -1) { + gf_log ("", GF_LOG_WARNING, "failed to create XDR payload"); goto out; } iov.iov_len = ret; @@ -617,7 +618,7 @@ mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_getspec_rsp (*iov, &rsp); if (ret < 0) { - gf_log (frame->this->name, GF_LOG_ERROR, "error"); + gf_log (frame->this->name, GF_LOG_ERROR, "XDR decoding error"); ret = -1; goto out; } @@ -872,16 +873,21 @@ glusterfs_mgmt_init (glusterfs_ctx_t *ctx) rpc = rpc_clnt_new (options, THIS->ctx, THIS->name); if (!rpc) { ret = -1; + gf_log ("", GF_LOG_WARNING, "failed to create rpc clnt"); goto out; } ret = rpc_clnt_register_notify (rpc, mgmt_rpc_notify, THIS); - if (ret) + if (ret) { + gf_log ("", GF_LOG_WARNING, "failed to register notify function"); goto out; + } ret = rpcclnt_cbk_program_register (rpc, &mgmt_cbk_prog); - if (ret) + if (ret) { + gf_log ("", GF_LOG_WARNING, "failed to register callback function"); goto out; + } ret = rpc_clnt_start (rpc); if (ret) @@ -910,7 +916,7 @@ mgmt_pmap_signin_cbk (struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_pmap_signin_rsp (*iov, &rsp); if (ret < 0) { - gf_log (frame->this->name, GF_LOG_ERROR, "error"); + gf_log (frame->this->name, GF_LOG_ERROR, "XDR decode error"); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -976,7 +982,7 @@ mgmt_pmap_signout_cbk (struct rpc_req *req, struct iovec *iov, int count, ctx = glusterfs_ctx_get (); ret = xdr_to_pmap_signout_rsp (*iov, &rsp); if (ret < 0) { - gf_log ("", GF_LOG_ERROR, "error"); + gf_log ("", GF_LOG_ERROR, "XDR decoding failed"); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 253b6b839..d784e0d87 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -111,8 +111,6 @@ static struct argp_option gf_options[] = { "File to use as VOLUME_FILE"}, {"spec-file", ARGP_VOLUME_FILE_KEY, "VOLFILE", OPTION_HIDDEN, "File to use as VOLUME FILE"}, - {"log-server", ARGP_LOG_SERVER_KEY, "LOGSERVER", 0, - "Server to use as the central log server"}, {"log-level", ARGP_LOG_LEVEL_KEY, "LOGLEVEL", 0, "Logging severity. Valid options are DEBUG, NORMAL, WARNING, ERROR, " @@ -129,8 +127,6 @@ static struct argp_option gf_options[] = { "Transport type to get volfile from server [default: socket]"}, {"volfile-id", ARGP_VOLFILE_ID_KEY, "KEY", 0, "'key' of the volfile to be fetched from server"}, - {"log-server-port", ARGP_LOG_SERVER_PORT_KEY, "PORT", 0, - "Listening port number of log server"}, {"pid-file", ARGP_PID_FILE_KEY, "PIDFILE", 0, "File to use as pid file"}, {"socket-file", ARGP_SOCK_FILE_KEY, "SOCKFILE", 0, @@ -200,8 +196,11 @@ create_fuse_mount (glusterfs_ctx_t *ctx) cmd_args = &ctx->cmd_args; - if (!cmd_args->mount_point) + if (!cmd_args->mount_point) { + gf_log ("", GF_LOG_TRACE, + "mount point not found, not a client process"); return 0; + } master = GF_CALLOC (1, sizeof (*master), gfd_mt_xlator_t); @@ -221,6 +220,8 @@ create_fuse_mount (glusterfs_ctx_t *ctx) master->ctx = ctx; master->options = get_new_dict (); + if (!master->options) + goto err; ret = dict_set_static_ptr (master->options, ZR_MOUNTPOINT_OPT, cmd_args->mount_point); @@ -236,7 +237,8 @@ create_fuse_mount (glusterfs_ctx_t *ctx) if (ret < 0) { gf_log ("glusterfsd", GF_LOG_ERROR, - "failed to set dict value."); + "failed to set dict value for key %s", + ZR_ATTR_TIMEOUT_OPT); goto err; } } @@ -246,7 +248,8 @@ create_fuse_mount (glusterfs_ctx_t *ctx) cmd_args->fuse_entry_timeout); if (ret < 0) { gf_log ("glusterfsd", GF_LOG_ERROR, - "failed to set dict value."); + "failed to set dict value for key %s", + ZR_ENTRY_TIMEOUT_OPT); goto err; } } @@ -256,7 +259,8 @@ create_fuse_mount (glusterfs_ctx_t *ctx) cmd_args->client_pid); if (ret < 0) { gf_log ("glusterfsd", GF_LOG_ERROR, - "failed to set dict value."); + "failed to set dict value for key %s", + "client-pid"); goto err; } } @@ -266,7 +270,8 @@ create_fuse_mount (glusterfs_ctx_t *ctx) cmd_args->volfile_check); if (ret < 0) { gf_log ("glusterfsd", GF_LOG_ERROR, - "failed to set dict value."); + "failed to set dict value for key %s", + ZR_STRICT_VOLFILE_CHECK); goto err; } } @@ -276,7 +281,8 @@ create_fuse_mount (glusterfs_ctx_t *ctx) cmd_args->dump_fuse); if (ret < 0) { gf_log ("glusterfsd", GF_LOG_ERROR, - "failed to set dict value."); + "failed to set dict value for key %s", + ZR_DUMP_FUSE); goto err; } } @@ -287,7 +293,8 @@ create_fuse_mount (glusterfs_ctx_t *ctx) "disable"); if (ret < 0) { gf_log ("glusterfsd", GF_LOG_ERROR, - "failed to set dict value."); + "failed to set 'disable' for key %s", + ZR_DIRECT_IO_OPT); goto err; } break; @@ -296,18 +303,23 @@ create_fuse_mount (glusterfs_ctx_t *ctx) "enable"); if (ret < 0) { gf_log ("glusterfsd", GF_LOG_ERROR, - "failed to set dict value."); + "failed to set 'enable' for key %s", + ZR_DIRECT_IO_OPT); goto err; } break; case GF_OPTION_DEFERRED: /* default */ default: + gf_log ("", GF_LOG_DEBUG, "fuse direct io type %d", + cmd_args->fuse_direct_io_mode); break; } ret = xlator_init (master); - if (ret) + if (ret) { + gf_log ("", GF_LOG_DEBUG, "failed to initialize fuse translator"); goto err; + } ctx->master = master; @@ -375,16 +387,25 @@ gf_remember_xlator_option (struct list_head *options, char *arg) INIT_LIST_HEAD (&option->cmd_args); dot = strchr (arg, '.'); - if (!dot) + if (!dot) { + gf_log ("", GF_LOG_WARNING, + "xlator option %s is invalid", arg); goto out; + } option->volume = GF_CALLOC ((dot - arg) + 1, sizeof (char), gfd_mt_char); + if (!option->volume) + goto out; + strncpy (option->volume, arg, (dot - arg)); equals = strchr (arg, '='); - if (!equals) + if (!equals) { + gf_log ("", GF_LOG_WARNING, + "xlator option %s is invalid", arg); goto out; + } option->key = GF_CALLOC ((equals - dot) + 1, sizeof (char), gfd_mt_char); @@ -393,8 +414,11 @@ gf_remember_xlator_option (struct list_head *options, char *arg) strncpy (option->key, dot + 1, (equals - dot - 1)); - if (!*(equals + 1)) + if (!*(equals + 1)) { + gf_log ("", GF_LOG_WARNING, + "xlator option %s is invalid", arg); goto out; + } option->value = gf_strdup (equals + 1); @@ -488,13 +512,6 @@ parse_opts (int key, char *arg, struct argp_state *state) break; - case ARGP_LOG_SERVER_KEY: - if (cmd_args->log_server) - GF_FREE (cmd_args->log_server); - - cmd_args->log_server = gf_strdup (arg); - break; - case ARGP_LOG_LEVEL_KEY: if (strcasecmp (arg, ARGP_LOG_LEVEL_NONE_OPTION) == 0) { cmd_args->log_level = GF_LOG_NONE; @@ -544,18 +561,6 @@ parse_opts (int key, char *arg, struct argp_state *state) "unknown volfile server port %s", arg); break; - case ARGP_LOG_SERVER_PORT_KEY: - n = 0; - - if (gf_string2uint_base10 (arg, &n) == 0) { - cmd_args->log_server_port = n; - break; - } - - argp_failure (state, -1, 0, - "unknown log server port %s", arg); - break; - case ARGP_VOLFILE_SERVER_TRANSPORT_KEY: cmd_args->volfile_server_transport = gf_strdup (arg); break; @@ -642,7 +647,9 @@ parse_opts (int key, char *arg, struct argp_state *state) break; case ARGP_XLATOR_OPTION_KEY: - gf_remember_xlator_option (&cmd_args->xlator_options, arg); + if (gf_remember_xlator_option (&cmd_args->xlator_options, arg)) + argp_failure (state, -1, 0, "invalid xlator option %s", arg); + break; case ARGP_KEY_NO_ARGS: @@ -686,9 +693,12 @@ cleanup_and_exit (int signum) ctx = glusterfs_ctx_get (); - /* TODO: is this the right place? */ if (!ctx) return; + + gf_log_callingfn ("", GF_LOG_WARNING, + "received signum (%d), shutting down", signum); + if (ctx->cleanup_started) return; @@ -707,8 +717,6 @@ cleanup_and_exit (int signum) trav->fini (trav); } - gf_log ("glusterfsd", GF_LOG_NORMAL, "shutting down"); - glusterfs_pidfile_cleanup (ctx); exit (0); @@ -742,24 +750,23 @@ reincarnate (int signum) ctx = glusterfs_ctx_get (); cmd_args = &ctx->cmd_args; - if (cmd_args->volfile_server) { - gf_log ("glusterfsd", GF_LOG_NORMAL, + gf_log ("glusterfsd", GF_LOG_INFO, "Fetching the volume file from server..."); ret = glusterfs_volfile_fetch (ctx); } else { - gf_log ("glusterfsd", GF_LOG_NORMAL, + gf_log ("glusterfsd", GF_LOG_INFO, "Reloading volfile ..."); ret = glusterfs_volumes_init (ctx); } + /* Also, SIGHUP should do logroate */ + gf_log_logrotate (1); + if (ret < 0) gf_log ("glusterfsd", GF_LOG_ERROR, "volume initialization failed."); - /* Also, SIGHUP should do logroate */ - gf_log_logrotate (1); - return; } @@ -845,10 +852,6 @@ set_log_file_path (cmd_args_t *cmd_args) ret = gf_asprintf (&cmd_args->log_file, DEFAULT_LOG_FILE_DIRECTORY "/%s.log", tmp_str); - if (ret == -1) { - gf_log ("glusterfsd", GF_LOG_ERROR, - "asprintf failed while setting up log-file"); - } goto done; } @@ -865,10 +868,6 @@ set_log_file_path (cmd_args_t *cmd_args) ret = gf_asprintf (&cmd_args->log_file, DEFAULT_LOG_FILE_DIRECTORY "/%s.log", tmp_str); - if (ret == -1) { - gf_log ("glusterfsd", GF_LOG_ERROR, - "asprintf failed while setting up log-file"); - } goto done; } @@ -884,10 +883,6 @@ set_log_file_path (cmd_args_t *cmd_args) ret = gf_asprintf (&cmd_args->log_file, DEFAULT_LOG_FILE_DIRECTORY "/%s-%s-%d.log", cmd_args->volfile_server, tmp_ptr, port); - if (-1 == ret) { - gf_log ("glusterfsd", GF_LOG_ERROR, - "asprintf failed while setting up log-file"); - } } done: return ret; @@ -904,39 +899,59 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx) xlator_mem_acct_init (THIS, gfd_mt_end); ctx->process_uuid = generate_uuid (); - if (!ctx->process_uuid) + if (!ctx->process_uuid) { + gf_log ("", GF_LOG_CRITICAL, + "ERROR: glusterfs uuid generation failed"); return -1; + } ctx->page_size = 128 * GF_UNIT_KB; ctx->iobuf_pool = iobuf_pool_new (8 * GF_UNIT_MB, ctx->page_size); - if (!ctx->iobuf_pool) + if (!ctx->iobuf_pool) { + gf_log ("", GF_LOG_CRITICAL, + "ERROR: glusterfs iobuf pool creation failed"); return -1; + } ctx->event_pool = event_pool_new (DEFAULT_EVENT_POOL_SIZE); - if (!ctx->event_pool) + if (!ctx->event_pool) { + gf_log ("", GF_LOG_CRITICAL, + "ERROR: glusterfs event pool creation failed"); return -1; + } pool = GF_CALLOC (1, sizeof (call_pool_t), gfd_mt_call_pool_t); - if (!pool) + if (!pool) { + gf_log ("", GF_LOG_CRITICAL, + "ERROR: glusterfs call pool creation failed"); return -1; + } /* frame_mem_pool size 112 * 16k */ pool->frame_mem_pool = mem_pool_new (call_frame_t, 16384); - if (!pool->frame_mem_pool) + if (!pool->frame_mem_pool) { + gf_log ("", GF_LOG_CRITICAL, + "ERROR: glusterfs frame pool creation failed"); return -1; - + } /* stack_mem_pool size 256 * 8k */ pool->stack_mem_pool = mem_pool_new (call_stack_t, 8192); - if (!pool->stack_mem_pool) + if (!pool->stack_mem_pool) { + gf_log ("", GF_LOG_CRITICAL, + "ERROR: glusterfs stack pool creation failed"); return -1; + } ctx->stub_mem_pool = mem_pool_new (call_stub_t, 1024); - if (!ctx->stub_mem_pool) + if (!ctx->stub_mem_pool) { + gf_log ("", GF_LOG_CRITICAL, + "ERROR: glusterfs stub pool creation failed"); return -1; + } INIT_LIST_HEAD (&pool->all_frames); LOCK_INIT (&pool->lock); @@ -982,15 +997,13 @@ logging_init (glusterfs_ctx_t *ctx) if (cmd_args->log_file == NULL) { ret = set_log_file_path (cmd_args); if (ret == -1) { - fprintf (stderr, "failed to set the log file path.. " - "exiting\n"); + fprintf (stderr, "ERROR: failed to set the log file path\n"); return -1; } } if (gf_log_init (cmd_args->log_file) == -1) { - fprintf (stderr, - "failed to open logfile %s. exiting\n", + fprintf (stderr, "ERROR: failed to open logfile %s\n", cmd_args->log_file); return -1; } @@ -1059,7 +1072,7 @@ parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx) ret = sys_symlink (tmp_logfilebase, cmd_args->log_file); if (ret == -1) { - fprintf (stderr, "symlink of logfile failed"); + fprintf (stderr, "ERROR: symlink of logfile failed\n"); } else { GF_FREE (cmd_args->log_file); cmd_args->log_file = gf_strdup (tmp_logfile); @@ -1267,8 +1280,12 @@ glusterfs_signals_setup (glusterfs_ctx_t *ctx) sigaddset (&set, SIGUSR2); /* gf_latency_toggle */ ret = pthread_sigmask (SIG_BLOCK, &set, NULL); - if (ret) + if (ret) { + gf_log ("", GF_LOG_WARNING, + "failed to execute pthread_signmask %s", + strerror (errno)); return ret; + } ret = pthread_create (&ctx->sigwaiter, NULL, glusterfs_sigwaiter, (void *) &set); @@ -1278,6 +1295,9 @@ glusterfs_signals_setup (glusterfs_ctx_t *ctx) fallback to signals getting handled by other threads. setup the signal handlers */ + gf_log ("", GF_LOG_WARNING, + "failed to create pthread %s", + strerror (errno)); return ret; } @@ -1288,15 +1308,14 @@ glusterfs_signals_setup (glusterfs_ctx_t *ctx) int daemonize (glusterfs_ctx_t *ctx) { - int ret = 0; + int ret = -1; cmd_args_t *cmd_args = NULL; - cmd_args = &ctx->cmd_args; ret = glusterfs_pidfile_setup (ctx); if (ret) - return ret; + goto out; if (cmd_args->no_daemon_mode) goto postfork; @@ -1308,16 +1327,16 @@ daemonize (glusterfs_ctx_t *ctx) if (ret == -1) { gf_log ("daemonize", GF_LOG_ERROR, "Daemonization failed: %s", strerror(errno)); - return ret; + goto out; } postfork: ret = glusterfs_pidfile_update (ctx); if (ret) - return ret; + goto out; glusterfs_signals_setup (ctx); - +out: return ret; } @@ -1326,13 +1345,12 @@ int glusterfs_process_volfp (glusterfs_ctx_t *ctx, FILE *fp) { glusterfs_graph_t *graph = NULL; - int ret = 0; + int ret = -1; xlator_t *trav = NULL; graph = glusterfs_graph_construct (fp); - if (!graph) { - ret = -1; + gf_log ("", GF_LOG_ERROR, "failed to construct the graph"); goto out; } @@ -1341,16 +1359,13 @@ glusterfs_process_volfp (glusterfs_ctx_t *ctx, FILE *fp) gf_log ("glusterfsd", GF_LOG_ERROR, "fuse xlator cannot be specified " "in volume file"); - ret = -1; goto out; } } ret = glusterfs_graph_prepare (graph, ctx); - if (ret) { glusterfs_graph_destroy (graph); - ret = -1; goto out; } @@ -1358,12 +1373,12 @@ glusterfs_process_volfp (glusterfs_ctx_t *ctx, FILE *fp) if (ret) { glusterfs_graph_destroy (graph); - ret = -1; goto out; } gf_log_volume_file (fp); + ret = 0; out: if (fp) fclose (fp); @@ -1426,8 +1441,11 @@ main (int argc, char *argv[]) return ret; ctx = glusterfs_ctx_get (); - if (!ctx) + if (!ctx) { + gf_log ("glusterfs", GF_LOG_CRITICAL, + "ERROR: glusterfs context not initialized"); return ENOMEM; + } ret = glusterfs_ctx_defaults_init (ctx); if (ret) diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h index e2f6131f3..ffe8b596e 100644 --- a/glusterfsd/src/glusterfsd.h +++ b/glusterfsd/src/glusterfsd.h @@ -25,7 +25,6 @@ #include "config.h" #endif -#include "glusterfsd-common.h" #define DEFAULT_GLUSTERD_VOLFILE CONFDIR "/glusterd.vol" #define DEFAULT_CLIENT_VOLFILE CONFDIR "/glusterfs.vol" @@ -47,36 +46,36 @@ #define ENABLE_DEBUG_MODE 1 enum argp_option_keys { - ARGP_VOLFILE_SERVER_KEY = 's', - ARGP_VOLUME_FILE_KEY = 'f', - ARGP_LOG_LEVEL_KEY = 'L', - ARGP_LOG_FILE_KEY = 'l', - ARGP_VOLFILE_SERVER_PORT_KEY = 131, + ARGP_VOLFILE_SERVER_KEY = 's', + ARGP_VOLUME_FILE_KEY = 'f', + ARGP_LOG_LEVEL_KEY = 'L', + ARGP_LOG_FILE_KEY = 'l', + ARGP_VOLFILE_SERVER_PORT_KEY = 131, ARGP_VOLFILE_SERVER_TRANSPORT_KEY = 132, - ARGP_PID_FILE_KEY = 'p', - ARGP_SOCK_FILE_KEY = 'S', - ARGP_NO_DAEMON_KEY = 'N', - ARGP_RUN_ID_KEY = 'r', - ARGP_DEBUG_KEY = 133, - ARGP_ENTRY_TIMEOUT_KEY = 135, - ARGP_ATTRIBUTE_TIMEOUT_KEY = 136, - ARGP_VOLUME_NAME_KEY = 137, - ARGP_XLATOR_OPTION_KEY = 138, - ARGP_DIRECT_IO_MODE_KEY = 139, + ARGP_PID_FILE_KEY = 'p', + ARGP_SOCK_FILE_KEY = 'S', + ARGP_NO_DAEMON_KEY = 'N', + ARGP_RUN_ID_KEY = 'r', + ARGP_DEBUG_KEY = 133, + ARGP_ENTRY_TIMEOUT_KEY = 135, + ARGP_ATTRIBUTE_TIMEOUT_KEY = 136, + ARGP_VOLUME_NAME_KEY = 137, + ARGP_XLATOR_OPTION_KEY = 138, + ARGP_DIRECT_IO_MODE_KEY = 139, #ifdef GF_DARWIN_HOST_OS - ARGP_NON_LOCAL_KEY = 140, + ARGP_NON_LOCAL_KEY = 140, #endif /* DARWIN */ - ARGP_VOLFILE_ID_KEY = 143, - ARGP_VOLFILE_CHECK_KEY = 144, - ARGP_VOLFILE_MAX_FETCH_ATTEMPTS = 145, - ARGP_LOG_SERVER_KEY = 146, - ARGP_LOG_SERVER_PORT_KEY = 147, - ARGP_READ_ONLY_KEY = 148, - ARGP_MAC_COMPAT_KEY = 149, - ARGP_DUMP_FUSE_KEY = 150, - ARGP_BRICK_NAME_KEY = 151, - ARGP_BRICK_PORT_KEY = 152, - ARGP_CLIENT_PID_KEY = 153, + ARGP_VOLFILE_ID_KEY = 143, + ARGP_VOLFILE_CHECK_KEY = 144, + ARGP_VOLFILE_MAX_FETCH_ATTEMPTS = 145, + ARGP_LOG_SERVER_KEY = 146, + ARGP_LOG_SERVER_PORT_KEY = 147, + ARGP_READ_ONLY_KEY = 148, + ARGP_MAC_COMPAT_KEY = 149, + ARGP_DUMP_FUSE_KEY = 150, + ARGP_BRICK_NAME_KEY = 151, + ARGP_BRICK_PORT_KEY = 152, + ARGP_CLIENT_PID_KEY = 153, }; int glusterfs_mgmt_pmap_signout (glusterfs_ctx_t *ctx); diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index 10f370b5c..90e4bc413 100644 --- a/libglusterfs/src/globals.c +++ b/libglusterfs/src/globals.c @@ -211,63 +211,6 @@ glusterfs_this_set (xlator_t *this) return 0; } - -/* IS_CENTRAL_LOG */ - -static pthread_key_t central_log_flag_key; - -void -glusterfs_central_log_flag_destroy (void *ptr) -{ - if (ptr) - FREE (ptr); -} - - -int -glusterfs_central_log_flag_init () -{ - int ret = 0; - - ret = pthread_key_create (¢ral_log_flag_key, - glusterfs_central_log_flag_destroy); - - if (ret != 0) { - return ret; - } - - pthread_setspecific (central_log_flag_key, (void *) 0); - - return ret; -} - - -void -glusterfs_central_log_flag_set () -{ - pthread_setspecific (central_log_flag_key, (void *) 1); -} - - -long -glusterfs_central_log_flag_get () -{ - long flag = 0; - - flag = (long) pthread_getspecific (central_log_flag_key); - - return flag; -} - - -void -glusterfs_central_log_flag_unset () -{ - pthread_setspecific (central_log_flag_key, (void *) 0); -} - - - /* SYNCTASK */ static pthread_key_t synctask_key; @@ -352,27 +295,34 @@ glusterfs_globals_init () gf_log_globals_init (); ret = glusterfs_ctx_init (); - if (ret) + if (ret) { + gf_log ("", GF_LOG_CRITICAL, + "ERROR: glusterfs context init failed"); goto out; + } ret = glusterfs_this_init (); - if (ret) - goto out; - - ret = glusterfs_central_log_flag_init (); - if (ret) + if (ret) { + gf_log ("", GF_LOG_CRITICAL, + "ERROR: glusterfs-translator init failed"); goto out; + } ret = glusterfs_uuid_buf_init (); - if(ret) + if(ret) { + gf_log ("", GF_LOG_CRITICAL, + "ERROR: glusterfs uuid buffer init failed"); goto out; + } gf_mem_acct_enable_set (); ret = synctask_init (); - if (ret) + if (ret) { + gf_log ("", GF_LOG_CRITICAL, + "ERROR: glusterfs synctask init failed"); goto out; - + } out: return ret; } diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h index 665ec55e4..78ceddab3 100644 --- a/libglusterfs/src/globals.h +++ b/libglusterfs/src/globals.h @@ -46,12 +46,6 @@ xlator_t **__glusterfs_this_location (); xlator_t *glusterfs_this_get (); int glusterfs_this_set (xlator_t *); -/* central log */ - -void glusterfs_central_log_flag_set (); -long glusterfs_central_log_flag_get (); -void glusterfs_central_log_flag_unset (); - /* task */ void *synctask_get (); int synctask_set (void *); diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 8c8a3b32e..af03bd36b 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -73,6 +73,13 @@ #define FNM_EXTMATCH 0 #endif +#define ZR_MOUNTPOINT_OPT "mountpoint" +#define ZR_ATTR_TIMEOUT_OPT "attribute-timeout" +#define ZR_ENTRY_TIMEOUT_OPT "entry-timeout" +#define ZR_DIRECT_IO_OPT "direct-io-mode" +#define ZR_STRICT_VOLFILE_CHECK "strict-volfile-check" +#define ZR_DUMP_FUSE "dump-fuse" + #define GF_XATTR_PATHINFO_KEY "trusted.glusterfs.pathinfo" #define GF_XATTR_LINKINFO_KEY "trusted.distribute.linkinfo" #define GFID_XATTR_KEY "trusted.gfid" diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index 4c6bc2ed7..2f598a6dc 100644 --- a/libglusterfs/src/logging.c +++ b/libglusterfs/src/logging.c @@ -131,22 +131,21 @@ int gf_log_init (const char *file) { if (!file){ - fprintf (stderr, "gf_log_init: no filename specified\n"); + fprintf (stderr, "ERROR: no filename specified\n"); return -1; } filename = gf_strdup (file); if (!filename) { - fprintf (stderr, "gf_log_init: strdup error\n"); + fprintf (stderr, "ERROR: updating log-filename failed: %s\n", + strerror (errno)); return -1; } logfile = fopen (file, "a"); if (!logfile){ - fprintf (stderr, - "gf_log_init: failed to open logfile \"%s\" (%s)\n", - file, - strerror (errno)); + fprintf (stderr, "ERROR: failed to open logfile \"%s\" (%s)\n", + file, strerror (errno)); return -1; } @@ -156,13 +155,6 @@ gf_log_init (const char *file) } -/* - * Initialize logging to a central server. - * If successful, log messages will be written both to - * the local file and to the remote server. - */ - -static int __central_log_enabled = 0; struct _msg_queue { struct list_head msgs; @@ -582,15 +574,6 @@ unlock: pthread_mutex_unlock (&logfile_mutex); if (msg) { - if ((ret != -1) && __central_log_enabled && - ((glusterfs_central_log_flag_get ()) == 0)) { - - glusterfs_central_log_flag_set (); - { - //gf_log_central (msg); - } - glusterfs_central_log_flag_unset (); - } GF_FREE (msg); } @@ -605,83 +588,6 @@ out: } -struct _client_log { - char *identifier; - FILE *file; - struct list_head list; -}; - -struct _client_log *client_logs = NULL; - - -static void -client_log_init (struct _client_log *cl, char *identifier) -{ - int ret = 0; - char *path = NULL; - - cl->identifier = identifier; - - ret = gf_asprintf (&path, "%s.client-%s", filename, identifier); - if (-1 == ret) { - return; - } - cl->file = fopen (path, "a"); - GF_FREE (path); - - INIT_LIST_HEAD (&cl->list); -} - - -static FILE * -__logfile_for_client (char *identifier) -{ - struct _client_log *client = NULL; - - if (!client_logs) { - client = GF_CALLOC (1, sizeof (*client), - gf_common_mt_client_log); - if (!client) - return NULL; - - client_log_init (client, identifier); - - client_logs = client; - } - - list_for_each_entry (client, &client_logs->list, list) { - if (!strcmp (client->identifier, identifier)) - break; - } - - if (!client) { - client = GF_CALLOC (1, sizeof (*client), - gf_common_mt_client_log); - if (!client) - return NULL; - - client_log_init (client, identifier); - - list_add_tail (&client->list, &client_logs->list); - } - - return client->file; -} - - -int -gf_log_from_client (const char *msg, char *identifier) -{ - FILE *client_log = NULL; - - client_log = __logfile_for_client (identifier); - - fprintf (client_log, "%s\n", msg); - fflush (client_log); - - return 0; -} - int gf_cmd_log_init (const char *filename) { diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c index b3bf4c93b..10c835cc8 100644 --- a/rpc/rpc-lib/src/rpc-transport.c +++ b/rpc/rpc-lib/src/rpc-transport.c @@ -1094,7 +1094,6 @@ rpc_transport_inet_options_build (dict_t **options, const char *hostname, int po if (!dict) goto out; - host = gf_strdup ((char*)hostname); if (!hostname) { ret = -1; @@ -1102,20 +1101,31 @@ rpc_transport_inet_options_build (dict_t **options, const char *hostname, int po } ret = dict_set_dynstr (dict, "remote-host", host); - if (ret) + if (ret) { + gf_log ("", GF_LOG_WARNING, "failed to set remote-host with %s", + host); goto out; + } ret = dict_set_int32 (dict, "remote-port", port); - if (ret) + if (ret) { + gf_log ("", GF_LOG_WARNING, "failed to set remote-port with %d", + port); goto out; - + } ret = dict_set_str (dict, "transport.address-family", "inet"); - if (ret) + if (ret) { + gf_log ("", GF_LOG_WARNING, + "failed to set addr-family with inet"); goto out; + } ret = dict_set_str (dict, "transport-type", "socket"); - if (ret) + if (ret) { + gf_log ("", GF_LOG_WARNING, + "failed to set trans-type with socket"); goto out; + } *options = dict; out: diff --git a/xlators/mount/fuse/src/Makefile.am b/xlators/mount/fuse/src/Makefile.am index 66d044e32..3dace143a 100644 --- a/xlators/mount/fuse/src/Makefile.am +++ b/xlators/mount/fuse/src/Makefile.am @@ -19,7 +19,7 @@ fuse_la_LDFLAGS = -module -avoidversion -shared -nostartfiles AM_CFLAGS = -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS) -Wall \ -I$(top_srcdir)/libglusterfs/src -I$(CONTRIBDIR)/fuse-include \ - -I$(top_srcdir)/glusterfsd/src $(GF_CFLAGS) $(GF_FUSE_CFLAGS) + $(GF_CFLAGS) $(GF_FUSE_CFLAGS) CLEANFILES = diff --git a/xlators/mount/fuse/src/fuse-bridge.h b/xlators/mount/fuse/src/fuse-bridge.h index c6462c7ed..f20e47272 100644 --- a/xlators/mount/fuse/src/fuse-bridge.h +++ b/xlators/mount/fuse/src/fuse-bridge.h @@ -39,7 +39,6 @@ #include "xlator.h" #include "defaults.h" #include "common-utils.h" -#include "glusterfsd-common.h" #include "statedump.h" #ifdef GF_DARWIN_HOST_OS -- cgit