summaryrefslogtreecommitdiffstats
path: root/glusterfsd
diff options
context:
space:
mode:
Diffstat (limited to 'glusterfsd')
-rw-r--r--glusterfsd/src/Makefile.am2
-rw-r--r--glusterfsd/src/glusterfsd-messages.h114
-rw-r--r--glusterfsd/src/glusterfsd-mgmt.c78
-rw-r--r--glusterfsd/src/glusterfsd.c319
-rw-r--r--glusterfsd/src/glusterfsd.h2
5 files changed, 340 insertions, 175 deletions
diff --git a/glusterfsd/src/Makefile.am b/glusterfsd/src/Makefile.am
index 05a10dee3..1797c32be 100644
--- a/glusterfsd/src/Makefile.am
+++ b/glusterfsd/src/Makefile.am
@@ -6,7 +6,7 @@ glusterfsd_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \
$(top_builddir)/rpc/xdr/src/libgfxdr.la \
$(GF_LDADD) $(GF_GLUSTERFS_LIBS)
glusterfsd_LDFLAGS = $(GF_LDFLAGS)
-noinst_HEADERS = glusterfsd.h glusterfsd-mem-types.h
+noinst_HEADERS = glusterfsd.h glusterfsd-mem-types.h glusterfsd-messages.h
AM_CPPFLAGS = $(GF_CPPFLAGS) \
-I$(top_srcdir)/libglusterfs/src -DDATADIR=\"$(localstatedir)\" \
diff --git a/glusterfsd/src/glusterfsd-messages.h b/glusterfsd/src/glusterfsd-messages.h
new file mode 100644
index 000000000..3165c971f
--- /dev/null
+++ b/glusterfsd/src/glusterfsd-messages.h
@@ -0,0 +1,114 @@
+/*
+ Copyright (c) 2013 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _GLUSTERFSD_MESSAGES_H_
+#define _GLUSTERFSD_MESSAGES_H_
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "glfs-message-id.h"
+
+/* NOTE: Rules for message additions
+ * 1) Each instance of a message is _better_ left with a unique message ID, even
+ * if the message format is the same. Reasoning is that, if the message
+ * format needs to change in one instance, the other instances are not
+ * impacted or the new change does not change the ID of the instance being
+ * modified.
+ * 2) Addition of a message,
+ * - Should increment the GLFS_NUM_MESSAGES
+ * - Append to the list of messages defined, towards the end
+ * - Retain macro naming as glfs_msg_X (for redability across developers)
+ * NOTE: Rules for message format modifications
+ * 3) Check acorss the code if the message ID macro in question is reused
+ * anywhere. If reused then then the modifications should ensure correctness
+ * everywhere, or needs a new message ID as (1) above was not adhered to. If
+ * not used anywhere, proceed with the required modification.
+ * NOTE: Rules for message deletion
+ * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used
+ * anywhere, then can be deleted, but will leave a hole by design, as
+ * addition rules specify modification to the end of the list and not filling
+ * holes.
+ */
+
+#define GLFS_COMP_BASE GLFS_MSGID_COMP_GLUSTERFSD
+#define GLFS_NUM_MESSAGES 33
+#define GLFS_MSGID_END (GLFS_COMP_BASE + GLFS_NUM_MESSAGES + 1)
+/* Messaged with message IDs */
+#define glfs_msg_start_x GLFS_COMP_BASE, "Invalid: Start of messages"
+/*------------*/
+#define glusterfsd_msg_1 (GLFS_COMP_BASE + 1), "Could not create absolute" \
+ " mountpoint path"
+#define glusterfsd_msg_2 (GLFS_COMP_BASE + 2), "Could not get current " \
+ "working directory"
+#define glusterfsd_msg_3 (GLFS_COMP_BASE + 3), "failed to set mount-point" \
+ " to options dictionary"
+#define glusterfsd_msg_4 (GLFS_COMP_BASE + 4), "failed to set dict value" \
+ " for key %s"
+#define glusterfsd_msg_5 (GLFS_COMP_BASE + 5), "failed to set 'disable'" \
+ " for key %s"
+#define glusterfsd_msg_6 (GLFS_COMP_BASE + 6), "failed to set 'enable'" \
+ " for key %s"
+#define glusterfsd_msg_7 (GLFS_COMP_BASE + 7), "Not a client process, not" \
+ " performing mount operation"
+#define glusterfsd_msg_8 (GLFS_COMP_BASE + 8), "MOUNT-POINT %s" \
+ " initialization failed"
+#define glusterfsd_msg_9 (GLFS_COMP_BASE + 9), "loading volume file %s" \
+ " failed"
+#define glusterfsd_msg_10 (GLFS_COMP_BASE + 10), "xlator option %s is" \
+ " invalid"
+#define glusterfsd_msg_11 (GLFS_COMP_BASE + 11), "Fetching the volume" \
+ " file from server..."
+#define glusterfsd_msg_12 (GLFS_COMP_BASE + 12), "volume initialization" \
+ " failed."
+#define glusterfsd_msg_13 (GLFS_COMP_BASE + 13), "ERROR: glusterfs uuid" \
+ " generation failed"
+#define glusterfsd_msg_14 (GLFS_COMP_BASE + 14), "ERROR: glusterfs %s" \
+ " pool creation failed"
+#define glusterfsd_msg_15 (GLFS_COMP_BASE + 15), "ERROR: '--volfile-id' is" \
+ " mandatory if '-s' OR '--volfile-server'" \
+ " option is given"
+#define glusterfsd_msg_16 (GLFS_COMP_BASE + 16), "ERROR: parsing the" \
+ " volfile failed"
+#define glusterfsd_msg_17 (GLFS_COMP_BASE + 17), "pidfile %s open failed"
+#define glusterfsd_msg_18 (GLFS_COMP_BASE + 18), "pidfile %s lock failed"
+#define glusterfsd_msg_19 (GLFS_COMP_BASE + 19), "pidfile %s unlock failed"
+#define glusterfsd_msg_20 (GLFS_COMP_BASE + 20), "pidfile %s truncation" \
+ " failed"
+#define glusterfsd_msg_21 (GLFS_COMP_BASE + 21), "pidfile %s write failed"
+#define glusterfsd_msg_22 (GLFS_COMP_BASE + 22), "failed to execute" \
+ " pthread_sigmask"
+#define glusterfsd_msg_23 (GLFS_COMP_BASE + 23), "failed to create pthread"
+#define glusterfsd_msg_24 (GLFS_COMP_BASE + 24), "daemonization failed"
+#define glusterfsd_msg_25 (GLFS_COMP_BASE + 25), "mount failed"
+#define glusterfsd_msg_26 (GLFS_COMP_BASE + 26), "failed to construct" \
+ " the graph"
+#define glusterfsd_msg_27 (GLFS_COMP_BASE + 27), "fuse xlator cannot be" \
+ " specified in volume file"
+#define glusterfsd_msg_28 (GLFS_COMP_BASE + 28), "Cannot reach volume" \
+ " specification file"
+#define glusterfsd_msg_29 (GLFS_COMP_BASE + 29), "ERROR: glusterfs context" \
+ " not initialized"
+#define glusterfsd_msg_30 (GLFS_COMP_BASE + 30), "Started running %s" \
+ " version %s (args: %s)"
+#define glusterfsd_msg_31 (GLFS_COMP_BASE + 31), "Could not create new" \
+ " sync-environment"
+#define glusterfsd_msg_32 (GLFS_COMP_BASE + 32), "received signum (%d)," \
+ " shutting down"
+#define glusterfsd_msg_33 (GLFS_COMP_BASE + 33), "obsolete option " \
+ "'--volfile-max-fetch-attempts or fetch-attempts' " \
+ "was provided"
+/*------------*/
+#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
+
+
+#endif /* !_GLUSTERFSD_MESSAGES_H_ */
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
index d4201b38e..c42228a04 100644
--- a/glusterfsd/src/glusterfsd-mgmt.c
+++ b/glusterfsd/src/glusterfsd-mgmt.c
@@ -1129,6 +1129,83 @@ out:
}
int
+glusterfs_handle_volume_barrier_op (rpcsvc_request_t *req)
+{
+ int32_t ret = -1;
+ gd1_mgmt_brick_op_req xlator_req = {0,};
+ dict_t *dict = NULL;
+ xlator_t *xlator = NULL;
+ xlator_t *any = NULL;
+ dict_t *output = NULL;
+ char msg[2048] = {0};
+ glusterfs_ctx_t *ctx = NULL;
+ glusterfs_graph_t *active = NULL;
+ xlator_t *this = NULL;
+
+ GF_ASSERT (req);
+ this = THIS;
+ GF_ASSERT (this);
+
+ ctx = glusterfsd_ctx;
+ GF_ASSERT (ctx);
+
+ active = ctx->active;
+ if (!active) {
+ req->rpc_err = GARBAGE_ARGS;
+ goto out;
+ }
+
+ any = active->first;
+ ret = xdr_to_generic (req->msg[0], &xlator_req,
+ (xdrproc_t)xdr_gd1_mgmt_brick_op_req);
+ if (ret < 0) {
+ //failed to decode msg;
+ req->rpc_err = GARBAGE_ARGS;
+ goto out;
+ }
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+
+ ret = dict_unserialize (xlator_req.input.input_val,
+ xlator_req.input.input_len,
+ &dict);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to "
+ "unserialize req-buffer to dictionary");
+ goto out;
+ }
+ xlator = xlator_search_by_name (any, xlator_req.name);
+ if (!xlator) {
+ snprintf (msg, sizeof (msg), "xlator %s is not loaded",
+ xlator_req.name);
+ goto out;
+ }
+
+ output = dict_new ();
+ if (!output) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = xlator->notify (xlator, GF_EVENT_VOLUME_BARRIER_OP,
+ dict, output);
+
+ ret = glusterfs_translator_info_response_send (req, ret,
+ msg, output);
+out:
+ if (dict)
+ dict_unref (dict);
+ free (xlator_req.input.input_val); // malloced by xdr
+ if (output)
+ dict_unref (output);
+ free (xlator_req.name); //malloced by xdr
+
+ return ret;
+
+}
+int
glusterfs_handle_rpc_msg (rpcsvc_request_t *req)
{
int ret = -1;
@@ -1192,6 +1269,7 @@ rpcsvc_actor_t glusterfs_actors[] = {
[GLUSTERD_BRICK_XLATOR_DEFRAG] = {"TRANSLATOR DEFRAG", GLUSTERD_BRICK_XLATOR_DEFRAG, glusterfs_handle_defrag, NULL, 0, DRC_NA},
[GLUSTERD_NODE_PROFILE] = {"NFS PROFILE", GLUSTERD_NODE_PROFILE, glusterfs_handle_nfs_profile, NULL, 0, DRC_NA},
[GLUSTERD_NODE_STATUS] = {"NFS STATUS", GLUSTERD_NODE_STATUS, glusterfs_handle_node_status, NULL, 0, DRC_NA},
+ [GLUSTERD_VOLUME_BARRIER_OP] = {"VOLUME BARRIER OP", GLUSTERD_VOLUME_BARRIER_OP, glusterfs_handle_volume_barrier_op, NULL, 0, DRC_NA},
};
struct rpcsvc_program glusterfs_mop_prog = {
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index 6a4655fc6..531932619 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -50,6 +50,7 @@
#include "glusterfs.h"
#include "compat.h"
#include "logging.h"
+#include "glusterfsd-messages.h"
#include "dict.h"
#include "list.h"
#include "timer.h"
@@ -109,6 +110,11 @@ static struct argp_option gf_options[] = {
{"log-file", ARGP_LOG_FILE_KEY, "LOGFILE", 0,
"File to use for logging [default: "
DEFAULT_LOG_FILE_DIRECTORY "/" PACKAGE_NAME ".log" "]"},
+ {"logger", ARGP_LOGGER, "LOGGER", 0, "Set which logging sub-system to "
+ "log to, valid options are: gluster-log and syslog, "
+ "[default: \"gluster-log\"]"},
+ {"log-format", ARGP_LOG_FORMAT, "LOG-FORMAT", 0, "Set log format, valid"
+ " options are: no-msg-id and with-msg-id, [default: \"with-msg-id\"]"},
{0, 0, 0, 0, "Advanced Options:"},
{"volfile-server-port", ARGP_VOLFILE_SERVER_PORT_KEY, "PORT", 0,
@@ -240,14 +246,13 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = gf_asprintf (&mount_point, "%s/%s", cwd,
cmd_args->mount_point);
if (ret == -1) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "Could not create absolute mountpoint "
- "path");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, errno,
+ glusterfsd_msg_1);
goto err;
}
} else {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "Could not get current working directory");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, errno,
+ glusterfsd_msg_2);
goto err;
}
} else
@@ -255,8 +260,7 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_dynstr (options, ZR_MOUNTPOINT_OPT, mount_point);
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set mount-point to options dictionary");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_3);
goto err;
}
@@ -265,9 +269,8 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
cmd_args->fuse_attribute_timeout);
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key %s",
- ZR_ATTR_TIMEOUT_OPT);
+ gf_msg ("glusterfsd", GF_LOG_ERROR, errno,
+ glusterfsd_msg_4, ZR_ATTR_TIMEOUT_OPT);
goto err;
}
}
@@ -276,8 +279,7 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_double (options, ZR_ENTRY_TIMEOUT_OPT,
cmd_args->fuse_entry_timeout);
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key %s",
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
ZR_ENTRY_TIMEOUT_OPT);
goto err;
}
@@ -287,8 +289,7 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_double (options, ZR_NEGATIVE_TIMEOUT_OPT,
cmd_args->fuse_negative_timeout);
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key %s",
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
ZR_NEGATIVE_TIMEOUT_OPT);
goto err;
}
@@ -298,8 +299,7 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_int32 (options, "client-pid",
cmd_args->client_pid);
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key %s",
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
"client-pid");
goto err;
}
@@ -309,8 +309,7 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_int32 (options, "uid-map-root",
cmd_args->uid_map_root);
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key %s",
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
"uid-map-root");
goto err;
}
@@ -320,8 +319,7 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_int32 (options, ZR_STRICT_VOLFILE_CHECK,
cmd_args->volfile_check);
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key %s",
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
ZR_STRICT_VOLFILE_CHECK);
goto err;
}
@@ -331,8 +329,7 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_static_ptr (options, ZR_DUMP_FUSE,
cmd_args->dump_fuse);
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key %s",
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
ZR_DUMP_FUSE);
goto err;
}
@@ -341,8 +338,8 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
if (cmd_args->acl) {
ret = dict_set_static_ptr (options, "acl", "on");
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key acl");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
+ "acl");
goto err;
}
}
@@ -350,8 +347,8 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
if (cmd_args->selinux) {
ret = dict_set_static_ptr (options, "selinux", "on");
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key selinux");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
+ "selinux");
goto err;
}
}
@@ -360,8 +357,7 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_static_ptr (options, "virtual-gfid-access",
"on");
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key "
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
"aux-gfid-mount");
goto err;
}
@@ -370,8 +366,8 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
if (cmd_args->enable_ino32) {
ret = dict_set_static_ptr (options, "enable-ino32", "on");
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key enable-ino32");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
+ "enable-ino32");
goto err;
}
}
@@ -379,8 +375,8 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
if (cmd_args->read_only) {
ret = dict_set_static_ptr (options, "read-only", "on");
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key read-only");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
+ "read-only");
goto err;
}
}
@@ -390,8 +386,7 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_static_ptr(options, "fopen-keep-cache",
"on");
if (ret < 0) {
- gf_log("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key "
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
"fopen-keep-cache");
goto err;
}
@@ -400,17 +395,15 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_static_ptr(options, "fopen-keep-cache",
"off");
if (ret < 0) {
- gf_log("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key "
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
"fopen-keep-cache");
goto err;
}
break;
case GF_OPTION_DEFERRED: /* default */
default:
- gf_log ("glusterfsd", GF_LOG_DEBUG,
- "fopen-keep-cache mode %d",
- cmd_args->fopen_keep_cache);
+ gf_msg_debug ("glusterfsd", 0, "fopen-keep-cache mode %d",
+ cmd_args->fopen_keep_cache);
break;
}
@@ -418,8 +411,8 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_int32(options, "gid-timeout",
cmd_args->gid_timeout);
if (ret < 0) {
- gf_log("glusterfsd", GF_LOG_ERROR, "failed to set dict "
- "value for key gid-timeout");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
+ "gid-timeout");
goto err;
}
}
@@ -427,8 +420,8 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_int32 (options, "background-qlen",
cmd_args->background_qlen);
if (ret < 0) {
- gf_log("glusterfsd", GF_LOG_ERROR, "failed to set dict "
- "value for key background-qlen");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
+ "background-qlen");
goto err;
}
}
@@ -436,8 +429,8 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_int32 (options, "congestion-threshold",
cmd_args->congestion_threshold);
if (ret < 0) {
- gf_log("glusterfsd", GF_LOG_ERROR, "failed to set dict "
- "value for key congestion-threshold");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
+ "congestion-threshold");
goto err;
}
}
@@ -447,8 +440,7 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_static_ptr (options, ZR_DIRECT_IO_OPT,
"disable");
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set 'disable' for key %s",
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_5,
ZR_DIRECT_IO_OPT);
goto err;
}
@@ -457,16 +449,15 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_static_ptr (options, ZR_DIRECT_IO_OPT,
"enable");
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set 'enable' for key %s",
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_6,
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);
+ gf_msg_debug ("glusterfsd", 0, "fuse direct io type %d",
+ cmd_args->fuse_direct_io_mode);
break;
}
@@ -475,8 +466,7 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_static_ptr (options, "no-root-squash",
"enable");
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set 'enable' for key "
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_6,
"no-root-squash");
goto err;
}
@@ -486,12 +476,11 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_static_ptr (options, "no-root-squash",
"disable");
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set 'disable' for key "
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_5,
"no-root-squash");
goto err;
}
- gf_log ("", GF_LOG_DEBUG, "fuse no-root-squash mode %d",
+ gf_msg_debug ("glusterfsd", 0, "fuse no-root-squash mode %d",
cmd_args->no_root_squash);
break;
}
@@ -500,8 +489,8 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_static_ptr (options, "sync-to-mount",
"enable");
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key sync-mtab");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
+ "sync-mtab");
goto err;
}
}
@@ -510,8 +499,8 @@ set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
ret = dict_set_str (options, "use-readdirp",
cmd_args->use_readdirp);
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR, "failed to set dict"
- " value for key use-readdirp");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
+ "use-readdirp");
goto err;
}
}
@@ -530,14 +519,13 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
cmd_args = &ctx->cmd_args;
if (!cmd_args->mount_point) {
- gf_log ("", GF_LOG_TRACE,
- "mount point not found, not a client process");
+ gf_msg_trace ("glusterfsd", 0,
+ "mount point not found, not a client process");
return 0;
}
if (ctx->process_mode != GF_CLIENT_PROCESS) {
- gf_log("glusterfsd", GF_LOG_ERROR,
- "Not a client process, not performing mount operation");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_7);
return -1;
}
@@ -551,8 +539,7 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
goto err;
if (xlator_set_type (master, "mount/fuse") == -1) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "MOUNT-POINT %s initialization failed",
+ gf_msg ("glusterfsd", GF_LOG_ERROR, errno, glusterfsd_msg_8,
cmd_args->mount_point);
goto err;
}
@@ -570,8 +557,7 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
ret = dict_set_static_ptr (master->options, ZR_FUSE_MOUNTOPTS,
cmd_args->fuse_mountopts);
if (ret < 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "failed to set dict value for key %s",
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4,
ZR_FUSE_MOUNTOPTS);
goto err;
}
@@ -579,7 +565,8 @@ create_fuse_mount (glusterfs_ctx_t *ctx)
ret = xlator_init (master);
if (ret) {
- gf_log ("", GF_LOG_DEBUG, "failed to initialize fuse translator");
+ gf_msg_debug ("glusterfsd", 0,
+ "failed to initialize fuse translator");
goto err;
}
@@ -608,21 +595,19 @@ get_volfp (glusterfs_ctx_t *ctx)
ret = sys_lstat (cmd_args->volfile, &statbuf);
if (ret == -1) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "%s: %s", cmd_args->volfile, strerror (errno));
+ gf_msg ("glusterfsd", GF_LOG_ERROR, errno, glusterfsd_msg_9,
+ cmd_args->volfile);
return NULL;
}
if ((specfp = fopen (cmd_args->volfile, "r")) == NULL) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "volume file %s: %s",
- cmd_args->volfile,
- strerror (errno));
+ gf_msg ("glusterfsd", GF_LOG_ERROR, errno, glusterfsd_msg_9,
+ cmd_args->volfile);
return NULL;
}
- gf_log ("glusterfsd", GF_LOG_DEBUG,
- "loading volume file %s", cmd_args->volfile);
+ gf_msg_debug ("glusterfsd", 0, "loading volume file %s",
+ cmd_args->volfile);
return specfp;
}
@@ -658,8 +643,8 @@ gf_remember_backup_volfile_server (char *arg)
}
if (!server->volfile_server) {
- gf_log ("", GF_LOG_WARNING,
- "xlator option %s is invalid", arg);
+ gf_msg ("glusterfsd", GF_LOG_WARNING, 0, glusterfsd_msg_10,
+ arg);
goto out;
}
@@ -700,8 +685,7 @@ gf_remember_xlator_option (char *arg)
dot = strchr (arg, '.');
if (!dot) {
- gf_log ("", GF_LOG_WARNING,
- "xlator option %s is invalid", arg);
+ gf_msg ("", GF_LOG_WARNING, 0, glusterfsd_msg_10, arg);
goto out;
}
@@ -714,8 +698,7 @@ gf_remember_xlator_option (char *arg)
equals = strchr (arg, '=');
if (!equals) {
- gf_log ("", GF_LOG_WARNING,
- "xlator option %s is invalid", arg);
+ gf_msg ("", GF_LOG_WARNING, 0, glusterfsd_msg_10, arg);
goto out;
}
@@ -727,8 +710,7 @@ gf_remember_xlator_option (char *arg)
strncpy (option->key, dot + 1, (equals - dot - 1));
if (!*(equals + 1)) {
- gf_log ("", GF_LOG_WARNING,
- "xlator option %s is invalid", arg);
+ gf_msg ("", GF_LOG_WARNING, 0, glusterfsd_msg_10, arg);
goto out;
}
@@ -1107,6 +1089,27 @@ parse_opts (int key, char *arg, struct argp_state *state)
"unknown use-readdirp setting \"%s\"", arg);
break;
+ case ARGP_LOGGER:
+ if (strcasecmp (arg, GF_LOGGER_GLUSTER_LOG) == 0)
+ cmd_args->logger = gf_logger_glusterlog;
+ else if (strcasecmp (arg, GF_LOGGER_SYSLOG) == 0)
+ cmd_args->logger = gf_logger_syslog;
+ else
+ argp_failure (state, -1, 0, "unknown logger %s", arg);
+
+ break;
+
+ case ARGP_LOG_FORMAT:
+ if (strcasecmp (arg, GF_LOG_FORMAT_NO_MSG_ID) == 0)
+ cmd_args->log_format = gf_logformat_traditional;
+ else if (strcasecmp (arg, GF_LOG_FORMAT_WITH_MSG_ID) == 0)
+ cmd_args->log_format = gf_logformat_withmsgid;
+ else
+ argp_failure (state, -1, 0, "unknown log format %s",
+ arg);
+
+ break;
+
}
return 0;
@@ -1124,8 +1127,7 @@ cleanup_and_exit (int signum)
if (!ctx)
return;
- gf_log_callingfn ("", GF_LOG_WARNING,
- "received signum (%d), shutting down", signum);
+ gf_msg_callingfn ("", GF_LOG_WARNING, 0, glusterfsd_msg_32, signum);
if (ctx->cleanup_started)
return;
@@ -1190,20 +1192,19 @@ reincarnate (int signum)
cmd_args = &ctx->cmd_args;
if (cmd_args->volfile_server) {
- gf_log ("glusterfsd", GF_LOG_INFO,
- "Fetching the volume file from server...");
+ gf_msg ("glusterfsd", GF_LOG_INFO, 0, glusterfsd_msg_11);
ret = glusterfs_volfile_fetch (ctx);
} else {
- gf_log ("glusterfsd", GF_LOG_DEBUG,
- "Not reloading volume specification file on SIGHUP");
+ gf_msg_debug ("glusterfsd", 0,
+ "Not reloading volume specification file"
+ " on SIGHUP");
}
/* Also, SIGHUP should do logrotate */
gf_log_logrotate (1);
if (ret < 0)
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "volume initialization failed.");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_12);
return;
}
@@ -1253,8 +1254,7 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
ctx->process_uuid = generate_glusterfs_ctx_id ();
if (!ctx->process_uuid) {
- gf_log ("", GF_LOG_CRITICAL,
- "ERROR: glusterfs uuid generation failed");
+ gf_msg ("", GF_LOG_CRITICAL, 0, glusterfsd_msg_13);
goto out;
}
@@ -1262,22 +1262,19 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
ctx->iobuf_pool = iobuf_pool_new ();
if (!ctx->iobuf_pool) {
- gf_log ("", GF_LOG_CRITICAL,
- "ERROR: glusterfs iobuf pool creation failed");
+ gf_msg ("", GF_LOG_CRITICAL, 0, glusterfsd_msg_14, "iobuf");
goto out;
}
ctx->event_pool = event_pool_new (DEFAULT_EVENT_POOL_SIZE);
if (!ctx->event_pool) {
- gf_log ("", GF_LOG_CRITICAL,
- "ERROR: glusterfs event pool creation failed");
+ gf_msg ("", GF_LOG_CRITICAL, 0, glusterfsd_msg_14, "event");
goto out;
}
ctx->pool = GF_CALLOC (1, sizeof (call_pool_t), gfd_mt_call_pool_t);
if (!ctx->pool) {
- gf_log ("", GF_LOG_CRITICAL,
- "ERROR: glusterfs call pool creation failed");
+ gf_msg ("", GF_LOG_CRITICAL, 0, glusterfsd_msg_14, "call");
goto out;
}
@@ -1287,22 +1284,19 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
/* frame_mem_pool size 112 * 4k */
ctx->pool->frame_mem_pool = mem_pool_new (call_frame_t, 4096);
if (!ctx->pool->frame_mem_pool) {
- gf_log ("", GF_LOG_CRITICAL,
- "ERROR: glusterfs frame pool creation failed");
+ gf_msg ("", GF_LOG_CRITICAL, 0, glusterfsd_msg_14, "frame");
goto out;
}
/* stack_mem_pool size 256 * 1024 */
ctx->pool->stack_mem_pool = mem_pool_new (call_stack_t, 1024);
if (!ctx->pool->stack_mem_pool) {
- gf_log ("", GF_LOG_CRITICAL,
- "ERROR: glusterfs stack pool creation failed");
+ gf_msg ("", GF_LOG_CRITICAL, 0, glusterfsd_msg_14, "stack");
goto out;
}
ctx->stub_mem_pool = mem_pool_new (call_stub_t, 1024);
if (!ctx->stub_mem_pool) {
- gf_log ("", GF_LOG_CRITICAL,
- "ERROR: glusterfs stub pool creation failed");
+ gf_msg ("", GF_LOG_CRITICAL, 0, glusterfsd_msg_14, "stub");
goto out;
}
@@ -1329,6 +1323,8 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
/* parsing command line arguments */
cmd_args->log_level = DEFAULT_LOG_LEVEL;
+ cmd_args->logger = gf_logger_glusterlog;
+ cmd_args->log_format = gf_logformat_withmsgid;
cmd_args->mac_compat = GF_OPTION_DISABLE;
#ifdef GF_DARWIN_HOST_OS
@@ -1373,43 +1369,40 @@ logging_init (glusterfs_ctx_t *ctx, const char *progpath)
{
cmd_args_t *cmd_args = NULL;
int ret = 0;
- char ident[1024] = {0,};
- char *progname = NULL;
- char *ptr = NULL;
cmd_args = &ctx->cmd_args;
if (cmd_args->log_file == NULL) {
ret = gf_set_log_file_path (cmd_args);
if (ret == -1) {
- fprintf (stderr, "ERROR: failed to set the log file path\n");
+ fprintf (stderr, "ERROR: failed to set the log file "
+ "path\n");
return -1;
}
}
-#ifdef GF_USE_SYSLOG
- progname = gf_strdup (progpath);
- snprintf (ident, 1024, "%s_%s", basename(progname),
- basename(cmd_args->log_file));
- GF_FREE (progname);
- /* remove .log suffix */
- if (NULL != (ptr = strrchr(ident, '.'))) {
- if (strcmp(ptr, ".log") == 0) {
- /* note: ptr points to location in ident only */
- ptr[0] = '\0';
+ if (cmd_args->log_ident == NULL) {
+ ret = gf_set_log_ident (cmd_args);
+ if (ret == -1) {
+ fprintf (stderr, "ERROR: failed to set the log "
+ "identity\n");
+ return -1;
}
}
- ptr = ident;
-#endif
- if (gf_log_init (ctx, cmd_args->log_file, ptr) == -1) {
+ /* finish log set parameters before init */
+ gf_log_set_loglevel (cmd_args->log_level);
+
+ gf_log_set_logger (cmd_args->logger);
+
+ gf_log_set_logformat (cmd_args->log_format);
+
+ if (gf_log_init (ctx, cmd_args->log_file, cmd_args->log_ident) == -1) {
fprintf (stderr, "ERROR: failed to open logfile %s\n",
cmd_args->log_file);
return -1;
}
- gf_log_set_loglevel (cmd_args->log_level);
-
return 0;
}
@@ -1453,9 +1446,7 @@ parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx)
/* Make sure after the parsing cli, if '--volfile-server' option is
given, then '--volfile-id' is mandatory */
if (cmd_args->volfile_server && !cmd_args->volfile_id) {
- gf_log ("glusterfs", GF_LOG_CRITICAL,
- "ERROR: '--volfile-id' is mandatory if '-s' OR "
- "'--volfile-server' option is given");
+ gf_msg ("glusterfs", GF_LOG_CRITICAL, 0, glusterfsd_msg_15);
ret = -1;
goto out;
}
@@ -1473,9 +1464,8 @@ parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx)
and exit */
ret = stat (cmd_args->volfile, &stbuf);
if (ret) {
- gf_log ("glusterfs", GF_LOG_CRITICAL,
- "ERROR: parsing the volfile failed (%s)\n",
- strerror (errno));
+ gf_msg ("glusterfs", GF_LOG_CRITICAL, errno,
+ glusterfsd_msg_16);
/* argp_usage (argp.) */
fprintf (stderr, "USAGE: %s [options] [mountpoint]\n",
argv[0]);
@@ -1521,9 +1511,7 @@ parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx)
compatibility with third party applications
*/
if (cmd_args->max_connect_attempts) {
- gf_log ("glusterfs", GF_LOG_WARNING,
- "obsolete option '--volfile-max-fetch-attempts"
- " or fetch-attempts' was provided");
+ gf_msg ("glusterfs", GF_LOG_WARNING, 0, glusterfsd_msg_33);
}
#ifdef GF_DARWIN_HOST_OS
@@ -1551,9 +1539,8 @@ glusterfs_pidfile_setup (glusterfs_ctx_t *ctx)
pidfp = fopen (cmd_args->pid_file, "a+");
if (!pidfp) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "pidfile %s error (%s)",
- cmd_args->pid_file, strerror (errno));
+ gf_msg ("glusterfsd", GF_LOG_ERROR, errno, glusterfsd_msg_17,
+ cmd_args->pid_file);
goto out;
}
@@ -1576,9 +1563,8 @@ glusterfs_pidfile_cleanup (glusterfs_ctx_t *ctx)
if (!ctx->pidfp)
return 0;
- gf_log ("glusterfsd", GF_LOG_TRACE,
- "pidfile %s cleanup",
- cmd_args->pid_file);
+ gf_msg_trace ("glusterfsd", 0, "pidfile %s cleanup",
+ cmd_args->pid_file);
if (ctx->cmd_args.pid_file) {
unlink (ctx->cmd_args.pid_file);
@@ -1607,39 +1593,34 @@ glusterfs_pidfile_update (glusterfs_ctx_t *ctx)
ret = lockf (fileno (pidfp), F_TLOCK, 0);
if (ret) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "pidfile %s lock failed",
+ gf_msg ("glusterfsd", GF_LOG_ERROR, errno, glusterfsd_msg_18,
cmd_args->pid_file);
return ret;
}
ret = ftruncate (fileno (pidfp), 0);
if (ret) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "pidfile %s truncation failed",
+ gf_msg ("glusterfsd", GF_LOG_ERROR, errno, glusterfsd_msg_20,
cmd_args->pid_file);
return ret;
}
ret = fprintf (pidfp, "%d\n", getpid ());
if (ret <= 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "pidfile %s write failed",
+ gf_msg ("glusterfsd", GF_LOG_ERROR, errno, glusterfsd_msg_21,
cmd_args->pid_file);
return ret;
}
ret = fflush (pidfp);
if (ret) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "pidfile %s write failed",
+ gf_msg ("glusterfsd", GF_LOG_ERROR, errno, glusterfsd_msg_21,
cmd_args->pid_file);
return ret;
}
- gf_log ("glusterfsd", GF_LOG_DEBUG,
- "pidfile %s updated with pid %d",
- cmd_args->pid_file, getpid ());
+ gf_msg_debug ("glusterfsd", 0, "pidfile %s updated with pid %d",
+ cmd_args->pid_file, getpid ());
return 0;
}
@@ -1723,9 +1704,7 @@ glusterfs_signals_setup (glusterfs_ctx_t *ctx)
ret = pthread_sigmask (SIG_BLOCK, &set, NULL);
if (ret) {
- gf_log ("glusterfsd", GF_LOG_WARNING,
- "failed to execute pthread_signmask %s",
- strerror (errno));
+ gf_msg ("glusterfsd", GF_LOG_WARNING, errno, glusterfsd_msg_22);
return ret;
}
@@ -1737,9 +1716,7 @@ glusterfs_signals_setup (glusterfs_ctx_t *ctx)
fallback to signals getting handled by other threads.
setup the signal handlers
*/
- gf_log ("glusterfsd", GF_LOG_WARNING,
- "failed to create pthread %s",
- strerror (errno));
+ gf_msg ("glusterfsd", GF_LOG_WARNING, errno, glusterfsd_msg_23);
return ret;
}
@@ -1784,8 +1761,7 @@ daemonize (glusterfs_ctx_t *ctx)
close (ctx->daemon_pipe[1]);
}
- gf_log ("daemonize", GF_LOG_ERROR,
- "Daemonization failed: %s", strerror(errno));
+ gf_msg ("daemonize", GF_LOG_ERROR, errno, glusterfsd_msg_24);
goto out;
case 0:
/* child */
@@ -1800,8 +1776,8 @@ daemonize (glusterfs_ctx_t *ctx)
if (ctx->mnt_pid > 0) {
ret = waitpid (ctx->mnt_pid, &cstatus, 0);
if (!(ret == ctx->mnt_pid && cstatus == 0)) {
- gf_log ("daemonize", GF_LOG_ERROR,
- "mount failed");
+ gf_msg ("daemonize", GF_LOG_ERROR, 0,
+ glusterfsd_msg_25);
exit (1);
}
}
@@ -1831,15 +1807,14 @@ glusterfs_process_volfp (glusterfs_ctx_t *ctx, FILE *fp)
graph = glusterfs_graph_construct (fp);
if (!graph) {
- gf_log ("", GF_LOG_ERROR, "failed to construct the graph");
+ gf_msg ("", GF_LOG_ERROR, 0, glusterfsd_msg_26);
goto out;
}
for (trav = graph->first; trav; trav = trav->next) {
if (strcmp (trav->type, "mount/fuse") == 0) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "fuse xlator cannot be specified "
- "in volume file");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0,
+ glusterfsd_msg_27);
goto out;
}
}
@@ -1897,8 +1872,7 @@ glusterfs_volumes_init (glusterfs_ctx_t *ctx)
fp = get_volfp (ctx);
if (!fp) {
- gf_log ("glusterfsd", GF_LOG_ERROR,
- "Cannot reach volume specification file");
+ gf_msg ("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_28);
ret = -1;
goto out;
}
@@ -1925,8 +1899,7 @@ main (int argc, char *argv[])
ctx = glusterfs_ctx_new ();
if (!ctx) {
- gf_log ("glusterfs", GF_LOG_CRITICAL,
- "ERROR: glusterfs context not initialized");
+ gf_msg ("glusterfs", GF_LOG_CRITICAL, 0, glusterfsd_msg_29);
return ENOMEM;
}
glusterfsd_ctx = ctx;
@@ -1965,8 +1938,7 @@ main (int argc, char *argv[])
strcat (cmdlinestr, " ");
strcat (cmdlinestr, argv[i]);
}
- gf_log (argv[0], GF_LOG_INFO,
- "Started running %s version %s (%s)",
+ gf_msg (argv[0], GF_LOG_INFO, 0, glusterfsd_msg_30,
argv[0], PACKAGE_VERSION, cmdlinestr);
}
@@ -1982,8 +1954,7 @@ main (int argc, char *argv[])
ctx->env = syncenv_new (0, 0, 0);
if (!ctx->env) {
- gf_log ("", GF_LOG_ERROR,
- "Could not create new sync-environment");
+ gf_msg ("", GF_LOG_ERROR, 0, glusterfsd_msg_31);
goto out;
}
diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h
index ad4c3699b..24487b4d4 100644
--- a/glusterfsd/src/glusterfsd.h
+++ b/glusterfsd/src/glusterfsd.h
@@ -85,6 +85,8 @@ enum argp_option_keys {
ARGP_FUSE_USE_READDIRP_KEY = 165,
ARGP_AUX_GFID_MOUNT_KEY = 166,
ARGP_FUSE_NO_ROOT_SQUASH_KEY = 167,
+ ARGP_LOGGER = 168,
+ ARGP_LOG_FORMAT = 169,
};
struct _gfd_vol_top_priv_t {