summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHumble Devassy Chirammal <hchiramm@redhat.com>2015-04-25 12:44:15 +0530
committerNiels de Vos <ndevos@redhat.com>2015-04-28 05:46:31 -0700
commit8986a47c54db4769feb4e6664532386f1cd0275d (patch)
treed13b3b5593b36363f604e9cc6a0067bcbc85596d
parent315364b78cd152835cf6d30e32fd145a942e1d7a (diff)
libgfapi : port gfapi to new logging framework
Change-Id: Iaa0a92f82b9a0a26eda1a8d72b3b66ce66fab443 BUG: 1194640 Signed-off-by: Humble Devassy Chirammal <hchiramm@redhat.com> Reviewed-on: http://review.gluster.org/9918 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: jiffin tony Thottan <jthottan@redhat.com> Reviewed-by: Raghavendra Talur <rtalur@redhat.com> Reviewed-by: soumya k <skoduri@redhat.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
-rw-r--r--api/src/Makefile.am2
-rw-r--r--api/src/gfapi-messages.h102
-rw-r--r--api/src/glfs-handleops.c7
-rw-r--r--api/src/glfs-master.c10
-rw-r--r--api/src/glfs-mgmt.c129
-rw-r--r--api/src/glfs-resolve.c51
-rw-r--r--api/src/glfs.c45
7 files changed, 254 insertions, 92 deletions
diff --git a/api/src/Makefile.am b/api/src/Makefile.am
index 04246578ff6..3c517e68072 100644
--- a/api/src/Makefile.am
+++ b/api/src/Makefile.am
@@ -1,5 +1,5 @@
lib_LTLIBRARIES = libgfapi.la
-noinst_HEADERS = glfs-mem-types.h glfs-internal.h
+noinst_HEADERS = glfs-mem-types.h glfs-internal.h gfapi-messages.h
libgfapi_HEADERS = glfs.h glfs-handles.h
libgfapidir = $(includedir)/glusterfs/api
diff --git a/api/src/gfapi-messages.h b/api/src/gfapi-messages.h
new file mode 100644
index 00000000000..d7cfd8371e6
--- /dev/null
+++ b/api/src/gfapi-messages.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2015 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 _GFAPI_MESSAGES_H__
+#define _GFAPI_MESSAGES_H_
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "glfs-message-id.h"
+
+/*! \file gfapi-messages.h
+ * \brief libgfapi log-message IDs and their descriptions
+ */
+
+/* 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_GFAPI_BASE GLFS_MSGID_COMP_API
+#define GLFS_NUM_MESSAGES 45
+#define GLFS_MSGID_END (GLFS_GFAPI_BASE + GLFS_NUM_MESSAGESi + 1)
+/* Messages with message IDs */
+#define glfs_msg_start_x GLFS_GFAPI_BASE, "Invalid: Start of messages"
+/*------------*/
+
+#define API_MSG_MEM_ACCT_INIT_FAILED (GLFS_GFAPI_BASE + 1)
+#define API_MSG_MASTER_XLATOR_INIT_FAILED (GLFS_GFAPI_BASE + 2)
+#define API_MSG_GFAPI_XLATOR_INIT_FAILED (GLFS_GFAPI_BASE + 3)
+#define API_MSG_VOLFILE_OPEN_FAILED (GLFS_GFAPI_BASE + 4)
+#define API_MSG_VOL_SPEC_FILE_ERROR (GLFS_GFAPI_BASE + 5)
+#define API_MSG_GLFS_FSOBJ_NULL (GLFS_GFAPI_BASE + 6)
+#define API_MSG_INVALID_ENTRY (GLFS_GFAPI_BASE + 7)
+#define API_MSG_FSMUTEX_LOCK_FAILED (GLFS_GFAPI_BASE + 8)
+#define API_MSG_COND_WAIT_FAILED (GLFS_GFAPI_BASE + 9)
+#define API_MSG_FSMUTEX_UNLOCK_FAILED (GLFS_GFAPI_BASE + 10)
+#define API_MSG_INODE_REFRESH_FAILED (GLFS_GFAPI_BASE + 11)
+#define API_MSG_GRAPH_CONSTRUCT_FAILED (GLFS_GFAPI_BASE + 12)
+#define API_MSG_FUSE_XLATOR_ERROR (GLFS_GFAPI_BASE + 13)
+#define API_MSG_XDR_PAYLOAD_FAILED (GLFS_GFAPI_BASE + 14)
+#define API_MSG_GET_VOLINFO_CBK_FAILED (GLFS_GFAPI_BASE + 15)
+#define API_MSG_FETCH_VOLUUID_FAILED (GLFS_GFAPI_BASE + 16)
+#define API_MSG_INSUFF_SIZE (GLFS_GFAPI_BASE + 17)
+#define API_MSG_FRAME_CREAT_FAILED (GLFS_GFAPI_BASE + 18)
+#define API_MSG_DICT_SET_FAILED (GLFS_GFAPI_BASE + 19)
+#define API_MSG_XDR_DECODE_FAILED (GLFS_GFAPI_BASE + 20)
+#define API_MSG_GET_VOLFILE_FAILED (GLFS_GFAPI_BASE + 21)
+#define API_MSG_WRONG_OPVERSION (GLFS_GFAPI_BASE + 22)
+#define API_MSG_DICT_SERIALIZE_FAILED (GLFS_GFAPI_BASE + 23)
+#define API_MSG_REMOTE_HOST_CONN_FAILED (GLFS_GFAPI_BASE + 24)
+#define API_MSG_VOLFILE_SERVER_EXHAUST (GLFS_GFAPI_BASE + 25)
+#define API_MSG_CREATE_RPC_CLIENT_FAILED (GLFS_GFAPI_BASE + 26)
+#define API_MSG_REG_NOTIFY_FUNC_FAILED (GLFS_GFAPI_BASE + 27)
+#define API_MSG_REG_CBK_FUNC_FAILED (GLFS_GFAPI_BASE + 28)
+#define API_MSG_GET_CWD_FAILED (GLFS_GFAPI_BASE + 29)
+#define API_MSG_FGETXATTR_FAILED (GLFS_GFAPI_BASE + 30)
+#define API_MSG_LOCKINFO_KEY_MISSING (GLFS_GFAPI_BASE + 31)
+#define API_MSG_FSETXATTR_FAILED (GLFS_GFAPI_BASE + 32)
+#define API_MSG_FSYNC_FAILED (GLFS_GFAPI_BASE + 33)
+#define API_MSG_FDCREATE_FAILED (GLFS_GFAPI_BASE + 34)
+#define API_MSG_INODE_PATH_FAILED (GLFS_GFAPI_BASE + 35)
+#define API_MSG_SYNCOP_OPEN_FAILED (GLFS_GFAPI_BASE + 36)
+#define API_MSG_LOCK_MIGRATE_FAILED (GLFS_GFAPI_BASE + 37)
+#define API_MSG_OPENFD_SKIPPED (GLFS_GFAPI_BASE + 38)
+#define API_MSG_FIRST_LOOKUP_GRAPH_FAILED (GLFS_GFAPI_BASE + 39)
+#define API_MSG_CWD_GRAPH_REF_FAILED (GLFS_GFAPI_BASE + 40)
+#define API_MSG_SWITCHED_GRAPH (GLFS_GFAPI_BASE + 41)
+#define API_MSG_XDR_RESPONSE_DECODE_FAILED (GLFS_GFAPI_BASE + 42)
+#define API_MSG_VOLFILE_INFO (GLFS_GFAPI_BASE + 43)
+#define API_MSG_VOLFILE_CONNECTING (GLFS_GFAPI_BASE + 44)
+#define API_MSG_NEW_GRAPH (GLFS_GFAPI_BASE + 45)
+/*------------*/
+#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
+
+#endif /* !_GFAPI_MESSAGES_H_ */
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c
index 886eb3fc42c..ee8ea626c51 100644
--- a/api/src/glfs-handleops.c
+++ b/api/src/glfs-handleops.c
@@ -14,6 +14,7 @@
#include "syncop.h"
#include "glfs.h"
#include "glfs-handles.h"
+#include "gfapi-messages.h"
int
glfs_listxattr_process (void *value, size_t size, dict_t *xattr);
@@ -1161,7 +1162,8 @@ pub_glfs_h_create_from_handle (struct glfs *fs, unsigned char *handle, int len,
ret = syncop_lookup (subvol, &loc, &iatt, 0, 0, 0);
DECODE_SYNCOP_ERR (ret);
if (ret) {
- gf_log (subvol->name, GF_LOG_WARNING,
+ gf_msg (subvol->name, GF_LOG_WARNING, errno,
+ API_MSG_INODE_REFRESH_FAILED,
"inode refresh of %s failed: %s",
uuid_utoa (loc.gfid), strerror (errno));
goto out;
@@ -1171,7 +1173,8 @@ pub_glfs_h_create_from_handle (struct glfs *fs, unsigned char *handle, int len,
if (newinode)
inode_lookup (newinode);
else {
- gf_log (subvol->name, GF_LOG_WARNING,
+ gf_msg (subvol->name, GF_LOG_WARNING, EINVAL,
+ API_MSG_INVALID_ENTRY,
"inode linking of %s failed: %s",
uuid_utoa (loc.gfid), strerror (errno));
errno = EINVAL;
diff --git a/api/src/glfs-master.c b/api/src/glfs-master.c
index dfce2f9b78c..11843c15b4d 100644
--- a/api/src/glfs-master.c
+++ b/api/src/glfs-master.c
@@ -25,6 +25,7 @@
#include "glfs-internal.h"
#include "glfs-mem-types.h"
+#include "gfapi-messages.h"
int
@@ -88,7 +89,8 @@ notify (xlator_t *this, int event, void *data, ...)
switch (event) {
case GF_EVENT_GRAPH_NEW:
- gf_log (this->name, GF_LOG_INFO, "New graph %s (%d) coming up",
+ gf_msg (this->name, GF_LOG_INFO, 0, API_MSG_NEW_GRAPH,
+ "New graph %s (%d) coming up",
uuid_utoa ((unsigned char *)graph->graph_uuid),
graph->id);
break;
@@ -117,8 +119,7 @@ notify (xlator_t *this, int event, void *data, ...)
glfs_process_upcall_event (fs, data);
break;
default:
- gf_log (this->name, GF_LOG_DEBUG,
- "got notify event %d", event);
+ gf_msg_debug (this->name, 0, "got notify event %d", event);
break;
}
@@ -136,7 +137,8 @@ mem_acct_init (xlator_t *this)
ret = xlator_mem_acct_init (this, glfs_mt_end + 1);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to initialise "
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ API_MSG_MEM_ACCT_INIT_FAILED, "Failed to initialise "
"memory accounting");
return ret;
}
diff --git a/api/src/glfs-mgmt.c b/api/src/glfs-mgmt.c
index 67a3e6d6c29..2194c2f7a38 100644
--- a/api/src/glfs-mgmt.c
+++ b/api/src/glfs-mgmt.c
@@ -40,6 +40,7 @@
#include "glfs-internal.h"
#include "glfs-mem-types.h"
+#include "gfapi-messages.h"
int glfs_volfile_fetch (struct glfs *fs);
int32_t glfs_get_volume_info_rpc (call_frame_t *frame, xlator_t *this,
@@ -56,13 +57,16 @@ glfs_process_volfp (struct glfs *fs, FILE *fp)
ctx = fs->ctx;
graph = glusterfs_graph_construct (fp);
if (!graph) {
- gf_log ("glfs", GF_LOG_ERROR, "failed to construct the graph");
+ gf_msg ("glfs", GF_LOG_ERROR, errno,
+ API_MSG_GRAPH_CONSTRUCT_FAILED,
+ "failed to construct the graph");
goto out;
}
for (trav = graph->first; trav; trav = trav->next) {
if (strcmp (trav->type, "mount/fuse") == 0) {
- gf_log ("glfs", GF_LOG_ERROR,
+ gf_msg ("glfs", GF_LOG_ERROR, EINVAL,
+ API_MSG_FUSE_XLATOR_ERROR,
"fuse xlator cannot be specified "
"in volume file");
goto out;
@@ -183,7 +187,8 @@ mgmt_submit_request (void *req, call_frame_t *frame,
/* Create the xdr payload */
ret = xdr_serialize_generic (iov, req, xdrproc);
if (ret == -1) {
- gf_log (THIS->name, GF_LOG_WARNING,
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
+ API_MSG_XDR_PAYLOAD_FAILED,
"failed to create XDR payload");
goto out;
}
@@ -227,7 +232,8 @@ mgmt_get_volinfo_cbk (struct rpc_req *req, struct iovec *iov,
args = frame->local;
if (!ctx) {
- gf_log (frame->this->name, GF_LOG_ERROR, "NULL context");
+ gf_msg (frame->this->name, GF_LOG_ERROR, EINVAL,
+ API_MSG_INVALID_ENTRY, "NULL context");
errno = EINVAL;
ret = -1;
goto out;
@@ -236,7 +242,8 @@ mgmt_get_volinfo_cbk (struct rpc_req *req, struct iovec *iov,
fs = ((xlator_t *)ctx->master)->private;
if (-1 == req->rpc_status) {
- gf_log (frame->this->name, GF_LOG_ERROR,
+ gf_msg (frame->this->name, GF_LOG_ERROR, EINVAL,
+ API_MSG_INVALID_ENTRY,
"GET_VOLUME_INFO RPC call is not successfull");
errno = EINVAL;
ret = -1;
@@ -246,13 +253,14 @@ mgmt_get_volinfo_cbk (struct rpc_req *req, struct iovec *iov,
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_get_volume_info_rsp);
if (ret < 0) {
- gf_log (frame->this->name, GF_LOG_ERROR,
+ gf_msg (frame->this->name, GF_LOG_ERROR, 0,
+ API_MSG_XDR_RESPONSE_DECODE_FAILED,
"Failed to decode xdr response for GET_VOLUME_INFO");
goto out;
}
- gf_log (frame->this->name, GF_LOG_DEBUG,
- "Received resp to GET_VOLUME_INFO RPC: %d", rsp.op_ret);
+ gf_msg_debug (frame->this->name, 0, "Received resp to GET_VOLUME_INFO "
+ "RPC: %d", rsp.op_ret);
if (rsp.op_ret == -1) {
errno = rsp.op_errno;
@@ -261,8 +269,9 @@ mgmt_get_volinfo_cbk (struct rpc_req *req, struct iovec *iov,
}
if (!rsp.dict.dict_len) {
- gf_log (frame->this->name, GF_LOG_ERROR,
- "Response received for GET_VOLUME_INFO RPC call is not valid");
+ gf_msg (frame->this->name, GF_LOG_ERROR, EINVAL,
+ API_MSG_INVALID_ENTRY, "Response received for "
+ "GET_VOLUME_INFO RPC call is not valid");
ret = -1;
errno = EINVAL;
goto out;
@@ -295,17 +304,17 @@ mgmt_get_volinfo_cbk (struct rpc_req *req, struct iovec *iov,
ret = 0;
out:
if (volume_id_str) {
- gf_log (frame->this->name, GF_LOG_DEBUG,
- "Volume Id: %s", volume_id_str);
+ gf_msg_debug (frame->this->name, 0,
+ "Volume Id: %s", volume_id_str);
pthread_mutex_lock (&fs->mutex);
gf_uuid_parse (volume_id_str, fs->vol_uuid);
pthread_mutex_unlock (&fs->mutex);
}
if (ret) {
- gf_log (frame->this->name, GF_LOG_ERROR,
- "In GET_VOLUME_INFO cbk, received error: %s",
- strerror(errno));
+ gf_msg (frame->this->name, GF_LOG_ERROR, errno,
+ API_MSG_GET_VOLINFO_CBK_FAILED, "In GET_VOLUME_INFO "
+ "cbk, received error: %s", strerror(errno));
}
if (dict)
@@ -317,7 +326,7 @@ out:
if (rsp.op_errstr && *rsp.op_errstr)
free (rsp.op_errstr);
- gf_log (frame->this->name, GF_LOG_DEBUG, "Returning: %d", ret);
+ gf_msg_debug (frame->this->name, 0, "Returning: %d", ret);
__wake (args);
@@ -344,18 +353,21 @@ pub_glfs_get_volumeid (struct glfs *fs, char *volid, size_t size)
glfs_get_volume_info (fs);
if (gf_uuid_is_null (fs->vol_uuid)) {
- gf_log (THIS->name, GF_LOG_ERROR, "Unable to fetch volume UUID");
+ gf_msg (THIS->name, GF_LOG_ERROR, EINVAL,
+ API_MSG_FETCH_VOLUUID_FAILED, "Unable to fetch "
+ "volume UUID");
return -1;
}
done:
if (!volid || !size) {
- gf_log (THIS->name, GF_LOG_DEBUG, "volumeid/size is null");
+ gf_msg_debug (THIS->name, 0, "volumeid/size is null");
return uuid_size;
}
if (size < uuid_size) {
- gf_log (THIS->name, GF_LOG_ERROR, "Insufficient size passed");
+ gf_msg (THIS->name, GF_LOG_ERROR, ERANGE, API_MSG_INSUFF_SIZE,
+ "Insufficient size passed");
errno = ERANGE;
return -1;
}
@@ -378,7 +390,9 @@ glfs_get_volume_info (struct glfs *fs)
ctx = fs->ctx;
frame = create_frame (THIS, ctx->pool);
if (!frame) {
- gf_log ("glfs", GF_LOG_ERROR, "failed to create the frame");
+ gf_msg ("glfs", GF_LOG_ERROR, ENOMEM,
+ API_MSG_FRAME_CREAT_FAILED,
+ "failed to create the frame");
ret = -1;
goto out;
}
@@ -433,7 +447,8 @@ glfs_get_volume_info_rpc (call_frame_t *frame, xlator_t *this,
flags = (int32_t)GF_GET_VOLUME_UUID; //ctx->flags;
ret = dict_set_int32 (dict, "flags", flags);
if (ret) {
- gf_log (frame->this->name, GF_LOG_ERROR, "failed to set flags");
+ gf_msg (frame->this->name, GF_LOG_ERROR, ENOKEY,
+ API_MSG_DICT_SET_FAILED, "failed to set flags");
goto out;
}
@@ -500,7 +515,8 @@ glfs_mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count,
ctx = frame->this->ctx;
if (!ctx) {
- gf_log (frame->this->name, GF_LOG_ERROR, "NULL context");
+ gf_msg (frame->this->name, GF_LOG_ERROR, EINVAL,
+ API_MSG_INVALID_ENTRY, "NULL context");
errno = EINVAL;
ret = -1;
goto out;
@@ -516,13 +532,15 @@ glfs_mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count,
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_getspec_rsp);
if (ret < 0) {
- gf_log (frame->this->name, GF_LOG_ERROR, "XDR decoding error");
+ gf_msg (frame->this->name, GF_LOG_ERROR, 0,
+ API_MSG_XDR_DECODE_FAILED, "XDR decoding error");
ret = -1;
goto out;
}
if (-1 == rsp.op_ret) {
- gf_log (frame->this->name, GF_LOG_ERROR,
+ gf_msg (frame->this->name, GF_LOG_ERROR, rsp.op_errno,
+ API_MSG_GET_VOLFILE_FAILED,
"failed to get the 'volume file' from server");
ret = -1;
errno = rsp.op_errno;
@@ -534,7 +552,8 @@ glfs_mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count,
if ((size == fs->oldvollen) &&
(memcmp (fs->oldvolfile, rsp.spec, size) == 0)) {
- gf_log (frame->this->name, GF_LOG_INFO,
+ gf_msg (frame->this->name, GF_LOG_INFO, 0,
+ API_MSG_VOLFILE_INFO,
"No change in volfile, continuing");
goto out;
}
@@ -563,15 +582,14 @@ glfs_mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count,
ret = glusterfs_volfile_reconfigure (fs->oldvollen, tmpfp, fs->ctx,
fs->oldvolfile);
if (ret == 0) {
- gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG,
- "No need to re-load volfile, reconfigure done");
+ gf_msg_debug ("glusterfsd-mgmt", 0, "No need to re-load "
+ "volfile, reconfigure done");
ret = glusterfs_oldvolfile_update (fs, rsp.spec, size);
goto out;
}
if (ret < 0) {
- gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG,
- "Reconfigure failed !!");
+ gf_msg_debug ("glusterfsd-mgmt", 0, "Reconfigure failed !!");
goto out;
}
@@ -590,8 +608,9 @@ out:
// Stop if server is running at an unsupported op-version
if (ENOTSUP == ret) {
- gf_log ("mgmt", GF_LOG_ERROR, "Server is operating at an "
- "op-version which is not supported");
+ gf_msg ("mgmt", GF_LOG_ERROR, ENOTSUP, API_MSG_WRONG_OPVERSION,
+ "Server is operating at an op-version which is not "
+ "supported");
errno = ENOTSUP;
glfs_init_done (fs, -1);
}
@@ -600,7 +619,8 @@ out:
/* Do it only for the first time */
/* Failed to get the volume file, something wrong,
restart the process */
- gf_log ("glfs-mgmt", GF_LOG_ERROR,
+ gf_msg ("glfs-mgmt", GF_LOG_ERROR, EINVAL,
+ API_MSG_INVALID_ENTRY,
"failed to fetch volume file (key:%s)",
ctx->cmd_args.volfile_id);
if (!need_retry) {
@@ -645,22 +665,25 @@ glfs_volfile_fetch (struct glfs *fs)
// decision
ret = dict_set_int32 (dict, "min-op-version", GD_OP_VERSION_MIN);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Failed to set min-op-version"
- " in request dict");
+ gf_msg (THIS->name, GF_LOG_ERROR, ENOKEY,
+ API_MSG_DICT_SET_FAILED,
+ "Failed to set min-op-version in request dict");
goto out;
}
ret = dict_set_int32 (dict, "max-op-version", GD_OP_VERSION_MAX);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Failed to set max-op-version"
- " in request dict");
+ gf_msg (THIS->name, GF_LOG_ERROR, ENOKEY,
+ API_MSG_DICT_SET_FAILED,
+ "Failed to set max-op-version in request dict");
goto out;
}
ret = dict_allocate_and_serialize (dict, &req.xdata.xdata_val,
&req.xdata.xdata_len);
if (ret < 0) {
- gf_log (THIS->name, GF_LOG_ERROR,
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ API_MSG_DICT_SERIALIZE_FAILED,
"Failed to serialize dictionary");
goto out;
}
@@ -696,15 +719,17 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
switch (event) {
case RPC_CLNT_DISCONNECT:
if (!ctx->active) {
- gf_log ("glfs-mgmt", GF_LOG_ERROR,
+ gf_msg ("glfs-mgmt", GF_LOG_ERROR, errno,
+ API_MSG_REMOTE_HOST_CONN_FAILED,
"failed to connect with remote-host: %s (%s)",
ctx->cmd_args.volfile_server,
strerror (errno));
server = ctx->cmd_args.curr_server;
if (server->list.next == &ctx->cmd_args.volfile_servers) {
errno = ENOTCONN;
- gf_log("glfs-mgmt", GF_LOG_INFO,
- "Exhausted all volfile servers");
+ gf_msg ("glfs-mgmt", GF_LOG_INFO, ENOTCONN,
+ API_MSG_VOLFILE_SERVER_EXHAUST,
+ "Exhausted all volfile servers");
glfs_init_done (fs, -1);
break;
}
@@ -719,7 +744,8 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
"remote-port",
server->port);
if (ret != 0) {
- gf_log ("glfs-mgmt", GF_LOG_ERROR,
+ gf_msg ("glfs-mgmt", GF_LOG_ERROR, ENOTCONN,
+ API_MSG_DICT_SET_FAILED,
"failed to set remote-port: %d",
server->port);
errno = ENOTCONN;
@@ -731,7 +757,8 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
"remote-host",
server->volfile_server);
if (ret != 0) {
- gf_log ("glfs-mgmt", GF_LOG_ERROR,
+ gf_msg ("glfs-mgmt", GF_LOG_ERROR, ENOTCONN,
+ API_MSG_DICT_SET_FAILED,
"failed to set remote-host: %s",
server->volfile_server);
errno = ENOTCONN;
@@ -743,14 +770,16 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
"transport-type",
server->transport);
if (ret != 0) {
- gf_log ("glfs-mgmt", GF_LOG_ERROR,
+ gf_msg ("glfs-mgmt", GF_LOG_ERROR, ENOTCONN,
+ API_MSG_DICT_SET_FAILED,
"failed to set transport-type: %s",
server->transport);
errno = ENOTCONN;
glfs_init_done (fs, -1);
break;
}
- gf_log ("glfs-mgmt", GF_LOG_INFO,
+ gf_msg ("glfs-mgmt", GF_LOG_INFO, 0,
+ API_MSG_VOLFILE_CONNECTING,
"connecting to next volfile server %s"
" at port %d with transport: %s",
server->volfile_server, server->port,
@@ -764,7 +793,8 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
if (ret && (ctx->active == NULL)) {
/* Do it only for the first time */
/* Exit the process.. there are some wrong options */
- gf_log ("glfs-mgmt", GF_LOG_ERROR,
+ gf_msg ("glfs-mgmt", GF_LOG_ERROR, EINVAL,
+ API_MSG_INVALID_ENTRY,
"failed to fetch volume file (key:%s)",
ctx->cmd_args.volfile_id);
errno = EINVAL;
@@ -829,21 +859,24 @@ glfs_mgmt_init (struct glfs *fs)
rpc = rpc_clnt_new (options, ctx, THIS->name, 8);
if (!rpc) {
ret = -1;
- gf_log (THIS->name, GF_LOG_WARNING,
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
+ API_MSG_CREATE_RPC_CLIENT_FAILED,
"failed to create rpc clnt");
goto out;
}
ret = rpc_clnt_register_notify (rpc, mgmt_rpc_notify, THIS);
if (ret) {
- gf_log (THIS->name, GF_LOG_WARNING,
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
+ API_MSG_REG_NOTIFY_FUNC_FAILED,
"failed to register notify function");
goto out;
}
ret = rpcclnt_cbk_program_register (rpc, &mgmt_cbk_prog, THIS);
if (ret) {
- gf_log (THIS->name, GF_LOG_WARNING,
+ gf_msg (THIS->name, GF_LOG_WARNING, 0,
+ API_MSG_REG_CBK_FUNC_FAILED,
"failed to register callback function");
goto out;
}
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c
index 2e351e16ecd..60e285d3ae7 100644
--- a/api/src/glfs-resolve.c
+++ b/api/src/glfs-resolve.c
@@ -29,6 +29,7 @@
#include "common-utils.h"
#include "syncop.h"
#include "call-stub.h"
+#include "gfapi-messages.h"
#include "glfs-internal.h"
@@ -50,7 +51,7 @@ glfs_first_lookup_safe (xlator_t *subvol)
ret = syncop_lookup (subvol, &loc, 0, 0, 0, 0);
DECODE_SYNCOP_ERR (ret);
- gf_log (subvol->name, GF_LOG_DEBUG, "first lookup complete %d", ret);
+ gf_msg_debug (subvol->name, 0, "first lookup complete %d", ret);
return ret;
}
@@ -102,7 +103,8 @@ glfs_refresh_inode_safe (xlator_t *subvol, inode_t *oldinode)
DECODE_SYNCOP_ERR (ret);
if (ret) {
- gf_log (subvol->name, GF_LOG_WARNING,
+ gf_msg (subvol->name, GF_LOG_WARNING, errno,
+ API_MSG_INODE_REFRESH_FAILED,
"inode refresh of %s failed: %s",
uuid_utoa (oldinode->gfid), strerror (errno));
loc_wipe (&loc);
@@ -497,7 +499,8 @@ glfs_resolve_path (struct glfs *fs, xlator_t *subvol, const char *origpath,
cwd = glfs_cwd_get (fs);
if (NULL == cwd) {
- gf_log (subvol->name, GF_LOG_WARNING, "Failed to get cwd");
+ gf_msg (subvol->name, GF_LOG_WARNING, EIO,
+ API_MSG_GET_CWD_FAILED, "Failed to get cwd");
errno = EIO;
goto out;
}
@@ -553,7 +556,8 @@ glfs_migrate_fd_locks_safe (struct glfs *fs, xlator_t *oldsubvol, fd_t *oldfd,
GF_XATTR_LOCKINFO_KEY, NULL, NULL);
DECODE_SYNCOP_ERR (ret);
if (ret < 0) {
- gf_log (fs->volname, GF_LOG_WARNING,
+ gf_msg (fs->volname, GF_LOG_WARNING, errno,
+ API_MSG_FGETXATTR_FAILED,
"fgetxattr (%s) failed (%s) on graph %s (%d)",
uuid_utoa_r (oldfd->inode->gfid, uuid1),
strerror (errno),
@@ -562,7 +566,8 @@ glfs_migrate_fd_locks_safe (struct glfs *fs, xlator_t *oldsubvol, fd_t *oldfd,
}
if (!dict_get (lockinfo, GF_XATTR_LOCKINFO_KEY)) {
- gf_log (fs->volname, GF_LOG_WARNING,
+ gf_msg (fs->volname, GF_LOG_WARNING, 0,
+ API_MSG_LOCKINFO_KEY_MISSING,
"missing lockinfo key (%s) on graph %s (%d)",
uuid_utoa_r (oldfd->inode->gfid, uuid1),
graphid_str (oldsubvol), oldsubvol->graph->id);
@@ -572,7 +577,8 @@ glfs_migrate_fd_locks_safe (struct glfs *fs, xlator_t *oldsubvol, fd_t *oldfd,
ret = syncop_fsetxattr (newsubvol, newfd, lockinfo, 0, NULL, NULL);
DECODE_SYNCOP_ERR (ret);
if (ret < 0) {
- gf_log (fs->volname, GF_LOG_WARNING,
+ gf_msg (fs->volname, GF_LOG_WARNING, 0,
+ API_MSG_FSETXATTR_FAILED,
"fsetxattr (%s) failed (%s) on graph %s (%d)",
uuid_utoa_r (newfd->inode->gfid, uuid1),
strerror (errno),
@@ -608,9 +614,9 @@ glfs_migrate_fd_safe (struct glfs *fs, xlator_t *newsubvol, fd_t *oldfd)
ret = syncop_fsync (oldsubvol, oldfd, 0, NULL, NULL);
DECODE_SYNCOP_ERR (ret);
if (ret) {
- gf_log (fs->volname, GF_LOG_WARNING,
- "fsync() failed (%s) on %s graph %s (%d)",
- strerror (errno),
+ gf_msg (fs->volname, GF_LOG_WARNING, errno,
+ API_MSG_FSYNC_FAILED, "fsync() failed "
+ "(%s) on %s graph %s (%d)", strerror (errno),
uuid_utoa_r (oldfd->inode->gfid, uuid1),
graphid_str (oldsubvol), oldsubvol->graph->id);
}
@@ -618,7 +624,8 @@ glfs_migrate_fd_safe (struct glfs *fs, xlator_t *newsubvol, fd_t *oldfd)
newinode = glfs_refresh_inode_safe (newsubvol, oldinode);
if (!newinode) {
- gf_log (fs->volname, GF_LOG_WARNING,
+ gf_msg (fs->volname, GF_LOG_WARNING, errno,
+ API_MSG_INODE_REFRESH_FAILED,
"inode (%s) refresh failed (%s) on graph %s (%d)",
uuid_utoa_r (oldinode->gfid, uuid1),
strerror (errno),
@@ -628,7 +635,8 @@ glfs_migrate_fd_safe (struct glfs *fs, xlator_t *newsubvol, fd_t *oldfd)
newfd = fd_create (newinode, getpid());
if (!newfd) {
- gf_log (fs->volname, GF_LOG_WARNING,
+ gf_msg (fs->volname, GF_LOG_WARNING, errno,
+ API_MSG_FDCREATE_FAILED,
"fd_create (%s) failed (%s) on graph %s (%d)",
uuid_utoa_r (newinode->gfid, uuid1),
strerror (errno),
@@ -640,7 +648,8 @@ glfs_migrate_fd_safe (struct glfs *fs, xlator_t *newsubvol, fd_t *oldfd)
ret = inode_path (oldfd->inode, NULL, (char **)&loc.path);
if (ret < 0) {
- gf_log (fs->volname, GF_LOG_INFO, "inode_path failed");
+ gf_msg (fs->volname, GF_LOG_INFO, 0, API_MSG_INODE_PATH_FAILED,
+ "inode_path failed");
goto out;
}
@@ -657,7 +666,8 @@ glfs_migrate_fd_safe (struct glfs *fs, xlator_t *newsubvol, fd_t *oldfd)
loc_wipe (&loc);
if (ret) {
- gf_log (fs->volname, GF_LOG_WARNING,
+ gf_msg (fs->volname, GF_LOG_WARNING, errno,
+ API_MSG_SYNCOP_OPEN_FAILED,
"syncop_open%s (%s) failed (%s) on graph %s (%d)",
IA_ISDIR (oldinode->ia_type) ? "dir" : "",
uuid_utoa_r (newinode->gfid, uuid1),
@@ -670,7 +680,8 @@ glfs_migrate_fd_safe (struct glfs *fs, xlator_t *newsubvol, fd_t *oldfd)
newfd);
if (ret) {
- gf_log (fs->volname, GF_LOG_WARNING,
+ gf_msg (fs->volname, GF_LOG_WARNING, errno,
+ API_MSG_LOCK_MIGRATE_FAILED,
"lock migration (%s) failed (%s) on graph %s (%d)",
uuid_utoa_r (newinode->gfid, uuid1),
strerror (errno),
@@ -758,7 +769,8 @@ __glfs_migrate_openfds (struct glfs *fs, xlator_t *subvol)
list_for_each_entry (glfd, &fs->openfds, openfds) {
if (gf_uuid_is_null (glfd->fd->inode->gfid)) {
- gf_log (fs->volname, GF_LOG_INFO,
+ gf_msg (fs->volname, GF_LOG_INFO, 0,
+ API_MSG_OPENFD_SKIPPED,
"skipping openfd %p/%p in graph %s (%d)",
glfd, glfd->fd, graphid_str(subvol),
subvol->graph->id);
@@ -789,7 +801,8 @@ __glfs_active_subvol (struct glfs *fs)
ret = __glfs_first_lookup (fs, new_subvol);
if (ret) {
- gf_log (fs->volname, GF_LOG_INFO,
+ gf_msg (fs->volname, GF_LOG_INFO, errno,
+ API_MSG_FIRST_LOOKUP_GRAPH_FAILED,
"first lookup on graph %s (%d) failed (%s)",
graphid_str (new_subvol), new_subvol->graph->id,
strerror (errno));
@@ -801,7 +814,8 @@ __glfs_active_subvol (struct glfs *fs)
if (!new_cwd) {
char buf1[64];
- gf_log (fs->volname, GF_LOG_INFO,
+ gf_msg (fs->volname, GF_LOG_INFO, errno,
+ API_MSG_CWD_GRAPH_REF_FAILED,
"cwd refresh of %s graph %s (%d) failed (%s)",
uuid_utoa_r (fs->cwd->gfid, buf1),
graphid_str (new_subvol),
@@ -824,7 +838,8 @@ __glfs_active_subvol (struct glfs *fs)
inode_unref (new_cwd);
}
- gf_log (fs->volname, GF_LOG_INFO, "switched to graph %s (%d)",
+ gf_msg (fs->volname, GF_LOG_INFO, 0, API_MSG_SWITCHED_GRAPH,
+ "switched to graph %s (%d)",
graphid_str (new_subvol), new_subvol->graph->id);
return new_subvol;
diff --git a/api/src/glfs.c b/api/src/glfs.c
index 88fa187c229..12ca751e34d 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -46,6 +46,7 @@
#include "common-utils.h"
#include "syncop.h"
#include "call-stub.h"
+#include "gfapi-messages.h"
#include "glfs.h"
#include "glfs-internal.h"
@@ -72,8 +73,9 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
ret = xlator_mem_acct_init (THIS, glfs_mt_end + 1);
if (ret != 0) {
- gf_log (THIS->name, GF_LOG_ERROR,
- "Memory accounting init failed");
+ gf_msg (THIS->name, GF_LOG_ERROR, ENOMEM,
+ API_MSG_MEM_ACCT_INIT_FAILED,
+ "Memory accounting init failed");
return ret;
}
@@ -198,9 +200,9 @@ create_master (struct glfs *fs)
goto err;
if (xlator_set_type (master, "mount/api") == -1) {
- gf_log ("glfs", GF_LOG_ERROR,
- "master xlator for %s initialization failed",
- fs->volname);
+ gf_msg ("glfs", GF_LOG_ERROR, 0,
+ API_MSG_MASTER_XLATOR_INIT_FAILED, "master xlator "
+ "for %s initialization failed", fs->volname);
goto err;
}
@@ -213,7 +215,8 @@ create_master (struct glfs *fs)
ret = xlator_init (master);
if (ret) {
- gf_log ("glfs", GF_LOG_ERROR,
+ gf_msg ("glfs", GF_LOG_ERROR, 0,
+ API_MSG_GFAPI_XLATOR_INIT_FAILED,
"failed to initialize gfapi translator");
goto err;
}
@@ -241,15 +244,15 @@ get_volfp (struct glfs *fs)
cmd_args = &fs->ctx->cmd_args;
if ((specfp = fopen (cmd_args->volfile, "r")) == NULL) {
- gf_log ("glfs", GF_LOG_ERROR,
+ gf_msg ("glfs", GF_LOG_ERROR, errno,
+ API_MSG_VOLFILE_OPEN_FAILED,
"volume file %s open failed: %s",
cmd_args->volfile,
strerror (errno));
return NULL;
}
- gf_log ("glfs", GF_LOG_DEBUG,
- "loading volume file %s", cmd_args->volfile);
+ gf_msg_debug ("glfs", 0, "loading volume file %s", cmd_args->volfile);
return specfp;
}
@@ -275,7 +278,8 @@ glfs_volumes_init (struct glfs *fs)
fp = get_volfp (fs);
if (!fp) {
- gf_log ("glfs", GF_LOG_ERROR,
+ gf_msg ("glfs", GF_LOG_ERROR, ENOENT,
+ API_MSG_VOL_SPEC_FILE_ERROR,
"Cannot reach volume specification file");
ret = -1;
goto out;
@@ -801,7 +805,7 @@ priv_glfs_init_done (struct glfs *fs, int ret)
glfs_init_cbk init_cbk;
if (!fs) {
- gf_log ("glfs", GF_LOG_ERROR,
+ gf_msg ("glfs", GF_LOG_ERROR, EINVAL, API_MSG_GLFS_FSOBJ_NULL,
"fs is NULL");
goto out;
}
@@ -857,7 +861,7 @@ glfs_init_async (struct glfs *fs, glfs_init_cbk cbk)
int ret = -1;
if (!fs || !fs->ctx) {
- gf_log ("glfs", GF_LOG_ERROR,
+ gf_msg ("glfs", GF_LOG_ERROR, EINVAL, API_MSG_INVALID_ENTRY,
"fs is not properly initialized.");
errno = EINVAL;
return ret;
@@ -877,7 +881,7 @@ pub_glfs_init (struct glfs *fs)
int ret = -1;
if (!fs || !fs->ctx) {
- gf_log ("glfs", GF_LOG_ERROR,
+ gf_msg ("glfs", GF_LOG_ERROR, EINVAL, API_MSG_INVALID_ENTRY,
"fs is not properly initialized.");
errno = EINVAL;
return ret;
@@ -1005,7 +1009,7 @@ pub_glfs_fini (struct glfs *fs)
{
/* Do we need to increase countdown? */
if ((!call_pool->cnt) && (!fs->pin_refcnt)) {
- gf_log ("glfs", GF_LOG_TRACE,
+ gf_msg_trace ("glfs", 0,
"call_pool_cnt - %ld,"
"pin_refcnt - %d",
call_pool->cnt, fs->pin_refcnt);
@@ -1049,7 +1053,8 @@ pub_glfs_fini (struct glfs *fs)
graph = subvol->graph;
err = pthread_mutex_lock (&fs->mutex);
if (err != 0) {
- gf_log ("glfs", GF_LOG_ERROR,
+ gf_msg ("glfs", GF_LOG_ERROR, err,
+ API_MSG_FSMUTEX_LOCK_FAILED,
"pthread lock on glfs mutex, "
"returned error: (%s)", strerror (err));
goto fail;
@@ -1060,7 +1065,8 @@ pub_glfs_fini (struct glfs *fs)
err = pthread_cond_wait (&fs->child_down_cond,
&fs->mutex);
if (err != 0)
- gf_log ("glfs", GF_LOG_INFO,
+ gf_msg ("glfs", GF_LOG_INFO, err,
+ API_MSG_COND_WAIT_FAILED,
"%s cond wait failed %s",
subvol->name,
strerror (err));
@@ -1069,7 +1075,8 @@ pub_glfs_fini (struct glfs *fs)
err = pthread_mutex_unlock (&fs->mutex);
if (err != 0) {
- gf_log ("glfs", GF_LOG_ERROR,
+ gf_msg ("glfs", GF_LOG_ERROR, err,
+ API_MSG_FSMUTEX_UNLOCK_FAILED,
"pthread unlock on glfs mutex, "
"returned error: (%s)", strerror (err));
goto fail;
@@ -1145,13 +1152,13 @@ pub_glfs_get_volfile (struct glfs *fs, void *buf, size_t len)
glfs_lock(fs);
if (len >= fs->oldvollen) {
- gf_log ("glfs", GF_LOG_TRACE, "copying %zu to %p", len, buf);
+ gf_msg_trace ("glfs", 0, "copying %zu to %p", len, buf);
memcpy(buf,fs->oldvolfile,len);
res = len;
}
else {
res = len - fs->oldvollen;
- gf_log ("glfs", GF_LOG_TRACE, "buffer is %zd too short", -res);
+ gf_msg_trace ("glfs", 0, "buffer is %zd too short", -res);
}
glfs_unlock(fs);