From eaceb4d8c5f08a97cc91843b0f80adc93fc3f391 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Wed, 10 Feb 2016 18:27:38 -0500 Subject: [PATCH 21/86] logging: Change log file name for glusterd Backport of http://review.gluster.org/13426 log file names are based on: a. user provided input (through -l switch while starting a gluster process) b. mount point paths in the case of native clients c. volume/configuration files used for starting a gluster process d. volume server used for starting a gluster process Currently glusterd uses scheme c. to have a log file name that reads as INSTALL_PREFIX-etc-glusterfs-glusterd.log Since glusterd has a well known configuration file, it does not make much sense to have log file name based on scheme c. This patch changes the name of glusterd's log file to "glusterd.log". Hopefully this enables users to identify glusterd's log file more easily. >Reviewed-on: http://review.gluster.org/13426 >Tested-by: Atin Mukherjee >Smoke: Gluster Build System >NetBSD-regression: NetBSD Build System >CentOS-regression: Gluster Build System >Reviewed-by: Atin Mukherjee Change-Id: I2d04179c4b9b06271b50eeee3909ee259e8cf547 BUG: 1306120 Signed-off-by: Vijay Bellur Reviewed-on: https://code.engineering.redhat.com/gerrit/84621 Reviewed-by: Atin Mukherjee Tested-by: Atin Mukherjee --- api/src/glfs.c | 2 +- glusterfsd/src/glusterfsd.c | 6 +----- libglusterfs/src/common-utils.c | 12 +++++++++++- libglusterfs/src/common-utils.h | 8 +++++++- xlators/mgmt/glusterd/src/glusterd.h | 1 - 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/api/src/glfs.c b/api/src/glfs.c index ee74487..3aec115 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -847,7 +847,7 @@ pub_glfs_set_logging (struct glfs *fs, const char *logfile, int loglevel) THIS->ctx = fs->ctx; if (!logfile) { - ret = gf_set_log_file_path (&fs->ctx->cmd_args); + ret = gf_set_log_file_path (&fs->ctx->cmd_args, fs->ctx); if (ret) goto out; tmplog = fs->ctx->cmd_args.log_file; diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 4a2f7ad..e726cc5 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -75,10 +75,6 @@ #include "daemon.h" #include "tw.h" -/* process mode definitions */ -#define GF_SERVER_PROCESS 0 -#define GF_CLIENT_PROCESS 1 -#define GF_GLUSTERD_PROCESS 2 /* using argp for command line parsing */ static char gf_doc[] = ""; @@ -1556,7 +1552,7 @@ logging_init (glusterfs_ctx_t *ctx, const char *progpath) cmd_args = &ctx->cmd_args; if (cmd_args->log_file == NULL) { - ret = gf_set_log_file_path (cmd_args); + ret = gf_set_log_file_path (cmd_args, ctx); if (ret == -1) { fprintf (stderr, "ERROR: failed to set the log file " "path\n"); diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 973e31c..9583352 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -3413,7 +3413,7 @@ out: /* Sets log file path from user provided arguments */ int -gf_set_log_file_path (cmd_args_t *cmd_args) +gf_set_log_file_path (cmd_args_t *cmd_args, glusterfs_ctx_t *ctx) { int i = 0; int j = 0; @@ -3442,6 +3442,16 @@ gf_set_log_file_path (cmd_args_t *cmd_args) goto done; } + if (ctx && GF_GLUSTERD_PROCESS == ctx->process_mode) { + ret = gf_asprintf (&cmd_args->log_file, + DEFAULT_LOG_FILE_DIRECTORY "/%s.log", + GLUSTERD_NAME); + if (ret > 0) + ret = 0; + + goto done; + } + if (cmd_args->volfile) { j = 0; i = 0; diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index 93dee58..2930fea 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -73,6 +73,7 @@ void trap (void); #define GEOREP "geo-replication" #define GHADOOP "glusterfs-hadoop" +#define GLUSTERD_NAME "glusterd" #define GF_SELINUX_XATTR_KEY "security.selinux" @@ -83,6 +84,11 @@ void trap (void); !strcmp (fs_name, "ext3") || \ !strcmp (fs_name, "ext4")) +/* process mode definitions */ +#define GF_SERVER_PROCESS 0 +#define GF_CLIENT_PROCESS 1 +#define GF_GLUSTERD_PROCESS 2 + /* Defining this here as it is needed by glusterd for setting * nfs port in volume status. */ @@ -221,7 +227,7 @@ int32_t gf_resolve_ip6 (const char *hostname, uint16_t port, int family, void gf_log_dump_graph (FILE *specfp, glusterfs_graph_t *graph); void gf_print_trace (int32_t signal, glusterfs_ctx_t *ctx); -int gf_set_log_file_path (cmd_args_t *cmd_args); +int gf_set_log_file_path (cmd_args_t *cmd_args, glusterfs_ctx_t *ctx); int gf_set_log_ident (cmd_args_t *cmd_args); #define VECTORSIZE(count) (count * (sizeof (struct iovec))) diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index 9889565..eec1adf 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -38,7 +38,6 @@ #include "glusterd-rcu.h" #define GLUSTERD_TR_LOG_SIZE 50 -#define GLUSTERD_NAME "glusterd" #define GLUSTERD_SOCKET_LISTEN_BACKLOG 128 #define GLUSTERD_QUORUM_TYPE_KEY "cluster.server-quorum-type" #define GLUSTERD_QUORUM_RATIO_KEY "cluster.server-quorum-ratio" -- 1.7.1