diff options
author | Manikandan Selvaganesh <mselvaga@redhat.com> | 2015-04-06 16:21:43 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2015-06-17 05:11:43 -0700 |
commit | 2dcc68df252f9f8313eb8f8b2e1e97f539426643 (patch) | |
tree | 6207411f159898757bc81fd27595b0a182ca35c4 /xlators/protocol/client/src/client.c | |
parent | db3a86b6d1a3a0c50450e2e30a6f7648f0fa94db (diff) |
protocol/client : porting log messages to new framework
Backport of http://review.gluster.org/#/c/10042/
Cherry picked from 379dbbfd683d2b0e1704c098b1f020567328122c
> 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>
Change-Id: I9bf2ca08fef969e566a64475d0f7a16d37e66eeb
BUG: 1217722
Signed-off-by: Manikandan Selvaganesh <mselvaga@redhat.com>
Reviewed-on: http://review.gluster.org/11240
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
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.c | 243 |
1 files changed, 107 insertions, 136 deletions
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index 5745de096e0..fb45128893e 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -25,6 +25,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; @@ -168,7 +169,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); @@ -188,12 +189,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; @@ -247,8 +248,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; } @@ -267,16 +268,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; } @@ -314,7 +317,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) { @@ -371,14 +374,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; } @@ -396,13 +398,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; } @@ -425,7 +426,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: @@ -454,7 +454,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: @@ -483,7 +482,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: @@ -513,7 +511,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: @@ -543,7 +540,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: @@ -574,7 +570,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: @@ -605,7 +600,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: @@ -636,7 +630,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: @@ -667,7 +660,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: @@ -696,7 +688,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: @@ -728,7 +719,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: @@ -759,7 +749,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: @@ -790,7 +779,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: @@ -828,7 +816,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: @@ -864,7 +851,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); @@ -897,7 +883,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); @@ -936,7 +921,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: @@ -963,7 +947,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: @@ -993,7 +976,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: @@ -1021,7 +1003,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: @@ -1051,7 +1032,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: @@ -1080,7 +1060,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: @@ -1108,7 +1087,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: @@ -1126,13 +1104,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; } @@ -1151,14 +1129,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; } @@ -1188,8 +1166,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; } @@ -1200,7 +1179,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; } @@ -1212,7 +1191,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; } @@ -1223,7 +1202,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; } @@ -1252,7 +1231,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); @@ -1268,7 +1248,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; @@ -1291,7 +1272,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) { @@ -1326,7 +1306,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: @@ -1357,7 +1336,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: @@ -1387,7 +1365,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: @@ -1418,7 +1395,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: @@ -1449,7 +1425,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: @@ -1479,7 +1454,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: @@ -1507,7 +1481,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: @@ -1536,7 +1509,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: @@ -1567,7 +1539,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: @@ -1599,7 +1570,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: @@ -1632,7 +1602,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: @@ -1666,7 +1635,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: @@ -1696,7 +1664,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: @@ -1728,7 +1695,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: @@ -1761,7 +1727,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: @@ -1791,7 +1756,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: @@ -1820,7 +1784,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: @@ -1850,7 +1813,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: @@ -1879,7 +1841,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: @@ -1908,7 +1869,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: @@ -1936,12 +1896,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: @@ -1970,7 +1924,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); @@ -2015,7 +1968,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"); @@ -2032,20 +1985,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"); } @@ -2055,7 +2010,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, @@ -2076,19 +2032,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 @@ -2098,13 +2061,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; @@ -2126,8 +2090,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; } @@ -2149,7 +2113,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"); @@ -2158,7 +2122,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 "); @@ -2172,8 +2136,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; @@ -2191,20 +2155,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; } } @@ -2234,7 +2201,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, @@ -2265,8 +2233,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; } @@ -2289,12 +2257,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"); @@ -2311,21 +2279,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; } @@ -2335,14 +2306,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; } @@ -2367,8 +2338,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) @@ -2380,8 +2351,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: @@ -2482,15 +2453,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); @@ -2540,7 +2511,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; } |