summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client/src/client.c
diff options
context:
space:
mode:
authorManikandan Selvaganesh <mselvaga@redhat.com>2015-04-06 16:21:43 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-06-15 06:26:43 -0700
commit379dbbfd683d2b0e1704c098b1f020567328122c (patch)
tree1ef1bd78d6a3bcf19915093463c8ef08b8473335 /xlators/protocol/client/src/client.c
parent554fa0c1315d0b4b78ba35a2d332d7ac0fd07d48 (diff)
protocol/client : porting log messages to new framework
Change-Id: I9bf2ca08fef969e566a64475d0f7a16d37e66eeb BUG: 1194640 Signed-off-by: Manikandan Selvaganesh <mselvaga@redhat.com> Reviewed-on: http://review.gluster.org/10042 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Tested-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/protocol/client/src/client.c')
-rw-r--r--xlators/protocol/client/src/client.c243
1 files changed, 107 insertions, 136 deletions
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index 63cc81a..ea0a9d8 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -20,6 +20,7 @@
#include "xdr-rpc.h"
#include "glusterfs3.h"
#include "gf-dirent.h"
+#include "client-messages.h"
extern rpc_clnt_prog_t clnt_handshake_prog;
extern rpc_clnt_prog_t clnt_dump_prog;
@@ -163,7 +164,7 @@ client_grace_timeout (void *data)
}
pthread_mutex_unlock (&conf->lock);
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_TIMER_EXPIRED,
"client grace timer expired, updating "
"the lk-version to %d", ver);
@@ -183,12 +184,12 @@ client_register_grace_timer (xlator_t *this, clnt_conf_t *conf)
pthread_mutex_lock (&conf->lock);
{
if (conf->grace_timer || !conf->grace_timer_needed) {
- gf_log (this->name, GF_LOG_TRACE,
- "Client grace timer is already set "
- "or a grace-timer has already time out, "
- "not registering a new timer");
+ gf_msg_trace (this->name, 0,
+ "Client grace timer is already set "
+ "or a grace-timer has already time "
+ "out, not registering a new timer");
} else {
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_TIMER_REG,
"Registering a grace timer");
conf->grace_timer_needed = _gf_false;
@@ -242,8 +243,8 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame,
(procnum == GF_HNDSK_SETVOLUME))))) {
/* This particular error captured/logged in
functions calling this */
- gf_log (this->name, GF_LOG_DEBUG,
- "connection in disconnected state");
+ gf_msg_debug (this->name, 0,
+ "connection in disconnected state");
goto out;
}
@@ -262,16 +263,18 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame,
if (iobref != NULL) {
ret = iobref_merge (new_iobref, iobref);
if (ret != 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "cannot merge iobref passed from caller "
- "into new_iobref");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ PC_MSG_NO_MEMORY, "cannot merge "
+ "iobref passed from caller into "
+ "new_iobref");
}
}
ret = iobref_add (new_iobref, iobuf);
if (ret != 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "cannot add iobuf into iobref");
+ gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
+ PC_MSG_NO_MEMORY, "cannot add iobuf into "
+ "iobref");
goto out;
}
@@ -309,7 +312,7 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame,
rsp_payload, rsp_payload_count, rsp_iobref);
if (ret < 0) {
- gf_log (this->name, GF_LOG_DEBUG, "rpc_clnt_submit failed");
+ gf_msg_debug (this->name, 0, "rpc_clnt_submit failed");
}
if (!conf->send_gids) {
@@ -366,14 +369,13 @@ client_releasedir (xlator_t *this, fd_t *fd)
args.fd = fd;
proc = &conf->fops->proctable[GF_FOP_RELEASEDIR];
-
if (proc->fn) {
ret = proc->fn (NULL, this, &args);
}
out:
if (ret)
- gf_log (this->name, GF_LOG_WARNING,
- "releasedir fop failed");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ PC_MSG_DIR_OP_FAILED, "releasedir fop failed");
return 0;
}
@@ -391,13 +393,12 @@ client_release (xlator_t *this, fd_t *fd)
args.fd = fd;
proc = &conf->fops->proctable[GF_FOP_RELEASE];
-
if (proc->fn) {
ret = proc->fn (NULL, this, &args);
}
out:
if (ret)
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_FILE_OP_FAILED,
"release fop failed");
return 0;
}
@@ -420,7 +421,6 @@ client_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_LOOKUP];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -449,7 +449,6 @@ client_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_STAT];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -478,7 +477,6 @@ client_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_TRUNCATE];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -508,7 +506,6 @@ client_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_FTRUNCATE];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -538,7 +535,6 @@ client_access (call_frame_t *frame, xlator_t *this, loc_t *loc,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_ACCESS];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -569,7 +565,6 @@ client_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_READLINK];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -600,7 +595,6 @@ client_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_MKNOD];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -631,7 +625,6 @@ client_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_MKDIR];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -662,7 +655,6 @@ client_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc,
args.flags = xflag;
proc = &conf->fops->proctable[GF_FOP_UNLINK];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -691,7 +683,6 @@ client_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_RMDIR];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -723,7 +714,6 @@ client_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_SYMLINK];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -754,7 +744,6 @@ client_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_RENAME];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -785,7 +774,6 @@ client_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_LINK];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -823,7 +811,6 @@ client_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
args.flags = (flags & ~O_DIRECT);
proc = &conf->fops->proctable[GF_FOP_CREATE];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -859,7 +846,6 @@ client_open (call_frame_t *frame, xlator_t *this, loc_t *loc,
args.flags = (flags & ~O_DIRECT);
proc = &conf->fops->proctable[GF_FOP_OPEN];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
@@ -892,7 +878,6 @@ client_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_READ];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
@@ -931,7 +916,6 @@ client_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_WRITE];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -958,7 +942,6 @@ client_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_FLUSH];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -988,7 +971,6 @@ client_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_FSYNC];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1016,7 +998,6 @@ client_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_FSTAT];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1046,7 +1027,6 @@ client_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_OPENDIR];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1075,7 +1055,6 @@ client_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, d
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_FSYNCDIR];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1103,7 +1082,6 @@ client_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_STATFS];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1121,13 +1099,13 @@ is_client_rpc_init_command (dict_t *dict, xlator_t *this,
int dict_ret = -1;
if (!strstr (this->name, "replace-brick")) {
- gf_log (this->name, GF_LOG_TRACE, "name is !replace-brick");
+ gf_msg_trace (this->name, 0, "name is !replace-brick");
goto out;
}
dict_ret = dict_get_str (dict, CLIENT_CMD_CONNECT, value);
if (dict_ret) {
- gf_log (this->name, GF_LOG_TRACE, "key %s not present",
- CLIENT_CMD_CONNECT);
+ gf_msg_trace (this->name, 0, "key %s not present",
+ CLIENT_CMD_CONNECT);
goto out;
}
@@ -1146,14 +1124,14 @@ is_client_rpc_destroy_command (dict_t *dict, xlator_t *this)
char *dummy = NULL;
if (strncmp (this->name, "replace-brick", 13)) {
- gf_log (this->name, GF_LOG_TRACE, "name is !replace-brick");
+ gf_msg_trace (this->name, 0, "name is !replace-brick");
goto out;
}
dict_ret = dict_get_str (dict, CLIENT_CMD_DISCONNECT, &dummy);
if (dict_ret) {
- gf_log (this->name, GF_LOG_TRACE, "key %s not present",
- CLIENT_CMD_DISCONNECT);
+ gf_msg_trace (this->name, 0, "key %s not present",
+ CLIENT_CMD_DISCONNECT);
goto out;
}
@@ -1183,8 +1161,9 @@ client_set_remote_options (char *value, xlator_t *this)
remote_port_str = strtok_r (NULL, ":", &tmp);
if (!subvol) {
- gf_log (this->name, GF_LOG_WARNING,
- "proper value not passed as subvolume");
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ PC_MSG_INVALID_ENTRY, "proper value not passed as "
+ "subvolume");
goto out;
}
@@ -1195,7 +1174,7 @@ client_set_remote_options (char *value, xlator_t *this)
ret = dict_set_dynstr (this->options, "remote-host", host_dup);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED,
"failed to set remote-host with %s", host);
goto out;
}
@@ -1207,7 +1186,7 @@ client_set_remote_options (char *value, xlator_t *this)
ret = dict_set_dynstr (this->options, "remote-subvolume", subvol_dup);
if (ret) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED,
"failed to set remote-host with %s", host);
goto out;
}
@@ -1218,7 +1197,7 @@ client_set_remote_options (char *value, xlator_t *this)
ret = dict_set_int32 (this->options, "remote-port",
remote_port);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED,
"failed to set remote-port to %d", remote_port);
goto out;
}
@@ -1247,7 +1226,8 @@ client_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
if (is_client_rpc_init_command (dict, this, &value) == _gf_true) {
GF_ASSERT (value);
- gf_log (this->name, GF_LOG_INFO, "client rpc init command");
+ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_RPC_INIT,
+ "client rpc init command");
ret = client_set_remote_options (value, this);
if (ret) {
(void) client_destroy_rpc (this);
@@ -1263,7 +1243,8 @@ client_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
}
if (is_client_rpc_destroy_command (dict, this) == _gf_true) {
- gf_log (this->name, GF_LOG_INFO, "client rpc destroy command");
+ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_RPC_DESTROY,
+ "client rpc destroy command");
ret = client_destroy_rpc (this);
if (ret) {
op_ret = 0;
@@ -1286,7 +1267,6 @@ client_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_SETXATTR];
-
if (proc->fn) {
ret = proc->fn (frame, this, &args);
if (ret) {
@@ -1321,7 +1301,6 @@ client_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_FSETXATTR];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1352,7 +1331,6 @@ client_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_FGETXATTR];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1382,7 +1360,6 @@ client_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_GETXATTR];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1413,7 +1390,6 @@ client_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_XATTROP];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1444,7 +1420,6 @@ client_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_FXATTROP];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1474,7 +1449,6 @@ client_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_REMOVEXATTR];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1502,7 +1476,6 @@ client_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_FREMOVEXATTR];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1531,7 +1504,6 @@ client_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_LK];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1562,7 +1534,6 @@ client_inodelk (call_frame_t *frame, xlator_t *this, const char *volume,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_INODELK];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1594,7 +1565,6 @@ client_finodelk (call_frame_t *frame, xlator_t *this, const char *volume,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_FINODELK];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1627,7 +1597,6 @@ client_entrylk (call_frame_t *frame, xlator_t *this, const char *volume,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_ENTRYLK];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1661,7 +1630,6 @@ client_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_FENTRYLK];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1691,7 +1659,6 @@ client_rchecksum (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_RCHECKSUM];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1723,7 +1690,6 @@ client_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_READDIR];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1756,7 +1722,6 @@ client_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd,
args.xdata = dict;
proc = &conf->fops->proctable[GF_FOP_READDIRP];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1786,7 +1751,6 @@ client_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_SETATTR];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1815,7 +1779,6 @@ client_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_FSETATTR];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1845,7 +1808,6 @@ client_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_FALLOCATE];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1874,7 +1836,6 @@ client_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_DISCARD];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1903,7 +1864,6 @@ client_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_ZEROFILL];
-
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1931,12 +1891,6 @@ client_ipc (call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata)
args.xdata = xdata;
proc = &conf->fops->proctable[GF_FOP_IPC];
- if (!proc) {
- gf_log (this->name, GF_LOG_ERROR,
- "rpc procedure not found for %s",
- gf_fop_list[GF_FOP_IPC]);
- goto out;
- }
if (proc->fn)
ret = proc->fn (frame, this, &args);
out:
@@ -1965,7 +1919,6 @@ client_getspec (call_frame_t *frame, xlator_t *this, const char *key,
/* For all other xlators, getspec is an fop, hence its in fops table */
proc = &conf->fops->proctable[GF_FOP_GETSPEC];
-
if (proc->fn) {
/* But at protocol level, this is handshake */
ret = proc->fn (frame, this, &args);
@@ -2010,7 +1963,7 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
this = mydata;
if (!this || !this->private) {
- gf_log ("client", GF_LOG_ERROR,
+ gf_msg ("client", GF_LOG_ERROR, EINVAL, PC_MSG_INVALID_ENTRY,
(this != NULL) ?
"private structure of the xlator is NULL":
"xlator is NULL");
@@ -2027,20 +1980,22 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
ret = dict_get_str (this->options, "disable-handshake",
&handshake);
- gf_log (this->name, GF_LOG_DEBUG, "got RPC_CLNT_CONNECT");
+ gf_msg_debug (this->name, 0, "got RPC_CLNT_CONNECT");
if ((ret < 0) || (strcasecmp (handshake, "on"))) {
ret = client_handshake (this, rpc);
if (ret)
- gf_log (this->name, GF_LOG_WARNING,
- "handshake msg returned %d", ret);
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ PC_MSG_HANDSHAKE_RETURN, "handshake "
+ "msg returned %d", ret);
} else {
//conf->rpc->connected = 1;
ret = client_notify_dispatch_uniq (this,
GF_EVENT_CHILD_UP,
NULL);
if (ret)
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ PC_MSG_CHILD_UP_NOTIFY_FAILED,
"CHILD_UP notify failed");
}
@@ -2050,7 +2005,8 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
conf->grace_timer_needed = _gf_true;
if (conf->grace_timer) {
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ PC_MSG_GRACE_TIMER_CANCELLED,
"Cancelling the grace timer");
gf_timer_call_cancel (this->ctx,
@@ -2071,19 +2027,26 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
if (!conf->skip_notify) {
if (conf->connected) {
- gf_log (this->name,
- ((!conf->disconnect_err_logged)
- ? GF_LOG_INFO : GF_LOG_DEBUG),
- "disconnected from %s. Client process "
- "will keep trying to connect to "
- "glusterd until brick's port is "
- "available",
- conf->rpc->conn.name);
-
+ if (!conf->disconnect_err_logged) {
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ PC_MSG_CLIENT_DISCONNECTED,
+ "disconnected from %s. Client "
+ "process will keep trying to "
+ "connect to glusterd until "
+ "brick's port is available",
+ conf->rpc->conn.name);
+ } else {
+ gf_msg_debug (this->name, 0,
+ "disconnected from %s. "
+ "Client process will keep"
+ " trying to connect to "
+ "glusterd until brick's "
+ "port is available",
+ conf->rpc->conn.name);
+ }
if (conf->portmap_err_logged)
conf->disconnect_err_logged = 1;
}
-
/* If the CHILD_DOWN event goes to parent xlator
multiple times, the logic of parent xlator notify
may get screwed up.. (eg. CHILD_MODIFIED event in
@@ -2093,13 +2056,14 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
GF_EVENT_CHILD_DOWN,
NULL);
if (ret)
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ PC_MSG_CHILD_DOWN_NOTIFY_FAILED,
"CHILD_DOWN notify failed");
} else {
if (conf->connected)
- gf_log (this->name, GF_LOG_DEBUG,
- "disconnected (skipped notify)");
+ gf_msg_debug (this->name, 0,
+ "disconnected (skipped notify)");
}
conf->connected = 0;
@@ -2121,8 +2085,8 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
break;
default:
- gf_log (this->name, GF_LOG_TRACE,
- "got some other RPC event %d", event);
+ gf_msg_trace (this->name, 0,
+ "got some other RPC event %d", event);
break;
}
@@ -2144,7 +2108,7 @@ notify (xlator_t *this, int32_t event, void *data, ...)
switch (event) {
case GF_EVENT_PARENT_UP:
{
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_PARENT_UP,
"parent translators are ready, attempting connect "
"on transport");
@@ -2153,7 +2117,7 @@ notify (xlator_t *this, int32_t event, void *data, ...)
}
case GF_EVENT_PARENT_DOWN:
- gf_log (this->name, GF_LOG_INFO,
+ gf_msg (this->name, GF_LOG_INFO, 0, PC_MSG_PARENT_DOWN,
"current graph is no longer active, destroying "
"rpc_client ");
@@ -2167,8 +2131,8 @@ notify (xlator_t *this, int32_t event, void *data, ...)
break;
default:
- gf_log (this->name, GF_LOG_DEBUG,
- "got %d, calling default_notify ()", event);
+ gf_msg_debug (this->name, 0,
+ "got %d, calling default_notify ()", event);
default_notify (this, event, data);
conf->last_sent_event = event;
@@ -2186,20 +2150,23 @@ client_check_remote_host (xlator_t *this, dict_t *options)
ret = dict_get_str (options, "remote-host", &remote_host);
if (ret < 0) {
- gf_log (this->name, GF_LOG_INFO, "Remote host is not set. "
- "Assuming the volfile server as remote host.");
+ gf_msg (this->name, GF_LOG_INFO, EINVAL,
+ PC_MSG_DICT_GET_FAILED, "Remote host is not set. "
+ "Assuming the volfile server as remote host");
if (!this->ctx->cmd_args.volfile_server) {
- gf_log (this->name, GF_LOG_ERROR,
- "No remote host to connect.");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ PC_MSG_DICT_GET_FAILED, "No remote host to "
+ "connect.");
goto out;
}
ret = dict_set_str (options, "remote-host",
this->ctx->cmd_args.volfile_server);
if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed to set the remote host");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ PC_MSG_DICT_GET_FAILED, "Failed to set the "
+ "remote host");
goto out;
}
}
@@ -2229,7 +2196,8 @@ build_client_config (xlator_t *this, clnt_conf_t *conf)
GF_OPTION_INIT ("remote-subvolume", conf->opt.remote_subvolume,
path, out);
if (!conf->opt.remote_subvolume)
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ PC_MSG_INVALID_ENTRY,
"option 'remote-subvolume' not given");
GF_OPTION_INIT ("filter-O_DIRECT", conf->filter_o_direct,
@@ -2260,8 +2228,8 @@ mem_acct_init (xlator_t *this)
ret = xlator_mem_acct_init (this, gf_client_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, PC_MSG_NO_MEMORY,
+ "Memory accounting init failed");
return ret;
}
@@ -2284,12 +2252,12 @@ client_destroy_rpc (xlator_t *this)
conf->rpc = rpc_clnt_unref (conf->rpc);
ret = 0;
- gf_log (this->name, GF_LOG_DEBUG,
- "Client rpc conn destroyed");
+ gf_msg_debug (this->name, 0,
+ "Client rpc conn destroyed");
goto out;
}
- gf_log (this->name, GF_LOG_WARNING,
+ gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_RPC_INVALID_CALL,
"RPC destroy called on already destroyed "
"connection");
@@ -2306,21 +2274,24 @@ client_init_rpc (xlator_t *this)
conf = this->private;
if (conf->rpc) {
- gf_log (this->name, GF_LOG_WARNING,
- "client rpc already init'ed");
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ PC_MSG_RPC_INITED_ALREADY, "client rpc already "
+ "init'ed");
ret = -1;
goto out;
}
conf->rpc = rpc_clnt_new (this->options, this->ctx, this->name, 0);
if (!conf->rpc) {
- gf_log (this->name, GF_LOG_ERROR, "failed to initialize RPC");
+ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_RPC_INIT_FAILED,
+ "failed to initialize RPC");
goto out;
}
ret = rpc_clnt_register_notify (conf->rpc, client_rpc_notify, this);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to register notify");
+ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_RPC_NOTIFY_FAILED,
+ "failed to register notify");
goto out;
}
@@ -2330,14 +2301,14 @@ client_init_rpc (xlator_t *this)
ret = rpcclnt_cbk_program_register (conf->rpc, &gluster_cbk_prog,
this);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_RPC_CBK_FAILED,
"failed to register callback program");
goto out;
}
ret = 0;
- gf_log (this->name, GF_LOG_DEBUG, "client init successful");
+ gf_msg_debug (this->name, 0, "client init successful");
out:
return ret;
}
@@ -2362,8 +2333,8 @@ client_init_grace_timer (xlator_t *this, dict_t *options,
if (!ret)
gf_string2boolean (lk_heal, &conf->lk_heal);
- gf_log (this->name, GF_LOG_DEBUG, "lk-heal = %s",
- (conf->lk_heal) ? "on" : "off");
+ gf_msg_debug (this->name, 0, "lk-heal = %s",
+ (conf->lk_heal) ? "on" : "off");
ret = dict_get_int32 (options, "grace-timeout", &grace_timeout);
if (!ret)
@@ -2375,8 +2346,8 @@ client_init_grace_timer (xlator_t *this, dict_t *options,
gf_time_fmt (timestr, sizeof timestr, conf->grace_ts.tv_sec,
gf_timefmt_s);
- gf_log (this->name, GF_LOG_DEBUG, "Client grace timeout value = %s",
- timestr);
+ gf_msg_debug (this->name, 0, "Client grace timeout value = %s",
+ timestr);
ret = 0;
out:
@@ -2477,15 +2448,15 @@ init (xlator_t *this)
clnt_conf_t *conf = NULL;
if (this->children) {
- gf_log (this->name, GF_LOG_ERROR,
- "FATAL: client protocol translator cannot have any "
- "subvolumes");
+ gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+ PC_MSG_INVALID_ENTRY, "FATAL: client protocol "
+ "translator cannot have any subvolumes");
goto out;
}
if (!this->parents) {
- gf_log (this->name, GF_LOG_WARNING,
- "Volume is dangling. ");
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ PC_MSG_INVALID_ENTRY, "Volume is dangling. ");
}
conf = GF_CALLOC (1, sizeof (*conf), gf_client_mt_clnt_conf_t);
@@ -2535,7 +2506,7 @@ init (xlator_t *this)
this->local_pool = mem_pool_new (clnt_local_t, 64);
if (!this->local_pool) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM, PC_MSG_NO_MEMORY,
"failed to create local_t's memory pool");
goto out;
}