summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanju Rakonde <srakonde@redhat.com>2018-09-11 14:19:42 +0530
committerAtin Mukherjee <amukherj@redhat.com>2018-09-18 04:09:01 +0000
commit484f417da945cf83afdbf136bb4817311862a8d2 (patch)
tree677eaa9f90b4cf5de59598fded7abd8984014962
parentd345ac09548dbb486c1619a27cb70149b3ca962a (diff)
glusterd: acquire lock to update volinfo structure
Problem: With commit cb0339f92, we are using a separate syntask for restart_bricks. There can be a situation where two threads are accessing the same volinfo structure at the same time and updating volinfo structure. This can lead volinfo to have inconsistent values and assertion failures because of unexpected values. Solution: While updating the volinfo structure, acquire a store_volinfo_lock, and release the lock only when the thread completed its critical section part. Fixes: bz#1627610 Signed-off-by: Sanju Rakonde <srakonde@redhat.com> Change-Id: I545e4e2368e3285d8f7aa28081ff4448abb72f5d
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c65
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h9
3 files changed, 42 insertions, 34 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index e04a3d493d9..26984b6ffba 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -1785,44 +1785,47 @@ glusterd_store_volinfo(glusterd_volinfo_t *volinfo,
GF_ASSERT(volinfo);
- glusterd_perform_volinfo_version_action(volinfo, ac);
- ret = glusterd_store_create_volume_dir(volinfo);
- if (ret)
- goto out;
-
- ret = glusterd_store_create_volume_run_dir(volinfo);
- if (ret)
- goto out;
+ pthread_mutex_lock(&volinfo->store_volinfo_lock);
+ {
+ glusterd_perform_volinfo_version_action(volinfo, ac);
+ ret = glusterd_store_create_volume_dir(volinfo);
+ if (ret)
+ goto unlock;
- ret = glusterd_store_create_vol_shandle_on_absence(volinfo);
- if (ret)
- goto out;
+ ret = glusterd_store_create_volume_run_dir(volinfo);
+ if (ret)
+ goto unlock;
- ret = glusterd_store_create_nodestate_sh_on_absence(volinfo);
- if (ret)
- goto out;
+ ret = glusterd_store_create_vol_shandle_on_absence(volinfo);
+ if (ret)
+ goto unlock;
- ret = glusterd_store_perform_volume_store(volinfo);
- if (ret)
- goto out;
+ ret = glusterd_store_create_nodestate_sh_on_absence(volinfo);
+ if (ret)
+ goto unlock;
- ret = glusterd_store_volume_atomic_update(volinfo);
- if (ret) {
- glusterd_perform_volinfo_version_action(
- volinfo, GLUSTERD_VOLINFO_VER_AC_DECREMENT);
- goto out;
- }
+ ret = glusterd_store_perform_volume_store(volinfo);
+ if (ret)
+ goto unlock;
- ret = glusterd_store_perform_node_state_store(volinfo);
- if (ret)
- goto out;
+ ret = glusterd_store_volume_atomic_update(volinfo);
+ if (ret) {
+ glusterd_perform_volinfo_version_action(
+ volinfo, GLUSTERD_VOLINFO_VER_AC_DECREMENT);
+ goto unlock;
+ }
- /* checksum should be computed at the end */
- ret = glusterd_compute_cksum(volinfo, _gf_false);
- if (ret)
- goto out;
+ ret = glusterd_store_perform_node_state_store(volinfo);
+ if (ret)
+ goto unlock;
-out:
+ /* checksum should be computed at the end */
+ ret = glusterd_compute_cksum(volinfo, _gf_false);
+ if (ret)
+ goto unlock;
+ }
+unlock:
+ pthread_mutex_unlock(&volinfo->store_volinfo_lock);
if (ret)
glusterd_store_volume_cleanup_tmp(volinfo);
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index d4dd1dc11a8..a6561e101d5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -2283,6 +2283,8 @@ glusterd_op_create_volume(dict_t *dict, char **op_errstr)
goto out;
}
+ pthread_mutex_init(&volinfo->store_volinfo_lock, NULL);
+
ret = dict_get_strn(dict, "volname", SLEN("volname"), &volname);
if (ret) {
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 19cdee392f6..412ba7415f0 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -494,9 +494,12 @@ struct glusterd_volinfo_ {
glusterd_tierdsvc_t tierd;
glusterd_gfproxydsvc_t gfproxyd;
int32_t quota_xattr_version;
- gf_boolean_t stage_deleted; /* volume has passed staging
- * for delete operation
- */
+ gf_boolean_t stage_deleted; /* volume has passed staging
+ * for delete operation
+ */
+ pthread_mutex_t store_volinfo_lock; /* acquire lock for
+ * updating the volinfo
+ */
};
typedef enum gd_snap_status_ {
+#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