summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/fd.c
diff options
context:
space:
mode:
authorMohamed Ashiq <ashiq333@gmail.com>2015-05-19 15:34:43 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-06-18 01:34:58 -0700
commitd32b221747cf6742cffaff5a60e16269dffd04cc (patch)
treeb440795763e7469024c95f2fe41d31946ae6b702 /libglusterfs/src/fd.c
parentdaf22a3b59f42c897f345dab74c3852ddf9bddef (diff)
fd,inode/libglusterfs : porting to a new logging framework
Change-Id: I4beba3b50456f802824374b6e3fa8079d72f2c00 BUG: 1194640 Signed-off-by: Mohamed Ashiq <ashiq333@gmail.com> Reviewed-on: http://review.gluster.org/10825 Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'libglusterfs/src/fd.c')
-rw-r--r--libglusterfs/src/fd.c82
1 files changed, 52 insertions, 30 deletions
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c
index 1a191f340eb..af0d66da1ec 100644
--- a/libglusterfs/src/fd.c
+++ b/libglusterfs/src/fd.c
@@ -13,7 +13,7 @@
#include "inode.h"
#include "dict.h"
#include "statedump.h"
-
+#include "libglusterfs-messages.h"
static int
@@ -30,7 +30,8 @@ gf_fd_chain_fd_entries (fdentry_t *entries, uint32_t startidx,
uint32_t i = 0;
if (!entries) {
- gf_log_callingfn ("fd", GF_LOG_WARNING, "!entries");
+ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL,
+ LG_MSG_INVALID_ARG, "!entries");
return -1;
}
@@ -55,7 +56,8 @@ gf_fd_fdtable_expand (fdtable_t *fdtable, uint32_t nr)
int ret = -1;
if (fdtable == NULL || nr > UINT32_MAX) {
- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
ret = EINVAL;
goto out;
}
@@ -122,7 +124,8 @@ __gf_fd_fdtable_get_all_fds (fdtable_t *fdtable, uint32_t *count)
fdentry_t *fdentries = NULL;
if (count == NULL) {
- gf_log_callingfn ("fd", GF_LOG_WARNING, "!count");
+ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL,
+ LG_MSG_INVALID_ARG, "!count");
goto out;
}
@@ -161,7 +164,8 @@ __gf_fd_fdtable_copy_all_fds (fdtable_t *fdtable, uint32_t *count)
int i = 0;
if (count == NULL) {
- gf_log_callingfn ("fd", GF_LOG_WARNING, "!count");
+ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL,
+ LG_MSG_INVALID_ARG, "!count");
goto out;
}
@@ -213,7 +217,8 @@ gf_fd_fdtable_destroy (fdtable_t *fdtable)
INIT_LIST_HEAD (&list);
if (!fdtable) {
- gf_log_callingfn ("fd", GF_LOG_WARNING, "!fdtable");
+ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL,
+ LG_MSG_INVALID_ARG, "!fdtable");
return;
}
@@ -248,7 +253,8 @@ gf_fd_unused_get (fdtable_t *fdtable, fd_t *fdptr)
int alloc_attempts = 0;
if (fdtable == NULL || fdptr == NULL) {
- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return EINVAL;
}
@@ -266,7 +272,8 @@ gf_fd_unused_get (fdtable_t *fdtable, fd_t *fdptr)
* seriously wrong with our data structures.
*/
if (alloc_attempts >= 2) {
- gf_log ("fd", GF_LOG_ERROR,
+ gf_msg ("fd", GF_LOG_ERROR, 0,
+ LG_MSG_EXPAND_FD_TABLE_FAILED,
"multiple attempts to expand fd table"
" have failed.");
goto out;
@@ -274,7 +281,8 @@ gf_fd_unused_get (fdtable_t *fdtable, fd_t *fdptr)
error = gf_fd_fdtable_expand (fdtable,
fdtable->max_fds + 1);
if (error) {
- gf_log ("fd", GF_LOG_ERROR,
+ gf_msg ("fd", GF_LOG_ERROR, 0,
+ LG_MSG_EXPAND_FD_TABLE_FAILED,
"Cannot expand fdtable: %s",
strerror (error));
goto out;
@@ -307,12 +315,14 @@ gf_fd_put (fdtable_t *fdtable, int32_t fd)
return;
if (fdtable == NULL || fd < 0) {
- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return;
}
if (!(fd < fdtable->max_fds)) {
- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return;
}
@@ -349,7 +359,8 @@ gf_fdptr_put (fdtable_t *fdtable, fd_t *fd)
int32_t i = 0;
if ((fdtable == NULL) || (fd == NULL)) {
- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return;
}
@@ -363,8 +374,10 @@ gf_fdptr_put (fdtable_t *fdtable, fd_t *fd)
}
if (fde == NULL) {
- gf_log_callingfn ("fd", GF_LOG_WARNING,
- "fd (%p) is not present in fdtable", fd);
+ gf_msg_callingfn ("fd", GF_LOG_WARNING, 0,
+ LG_MSG_FD_NOT_FOUND_IN_FDTABLE,
+ "fd (%p) is not present in fdtable",
+ fd);
goto unlock_out;
}
@@ -396,13 +409,15 @@ gf_fd_fdptr_get (fdtable_t *fdtable, int64_t fd)
fd_t *fdptr = NULL;
if (fdtable == NULL || fd < 0) {
- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
errno = EINVAL;
return NULL;
}
if (!(fd < fdtable->max_fds)) {
- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
errno = EINVAL;
return NULL;
}
@@ -435,7 +450,8 @@ fd_ref (fd_t *fd)
fd_t *refed_fd = NULL;
if (!fd) {
- gf_log_callingfn ("fd", GF_LOG_ERROR, "null fd");
+ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "null fd");
return NULL;
}
@@ -470,12 +486,15 @@ fd_destroy (fd_t *fd)
xlator_t *old_THIS = NULL;
if (fd == NULL){
- gf_log_callingfn ("xlator", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("xlator", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
goto out;
}
if (fd->inode == NULL){
- gf_log_callingfn ("xlator", GF_LOG_ERROR, "fd->inode is NULL");
+ gf_msg_callingfn ("xlator", GF_LOG_ERROR, 0,
+ LG_MSG_FD_INODE_NULL,
+ "fd->inode is NULL");
goto out;
}
if (!fd->_ctx)
@@ -528,7 +547,8 @@ fd_unref (fd_t *fd)
int32_t refcount = 0;
if (!fd) {
- gf_log_callingfn ("fd", GF_LOG_ERROR, "fd is NULL");
+ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "fd is NULL");
return;
}
@@ -562,7 +582,8 @@ fd_t *
fd_bind (fd_t *fd)
{
if (!fd || !fd->inode) {
- gf_log_callingfn ("fd", GF_LOG_ERROR, "!fd || !fd->inode");
+ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "!fd || !fd->inode");
return NULL;
}
@@ -582,7 +603,8 @@ __fd_create (inode_t *inode, uint64_t pid)
fd_t *fd = NULL;
if (inode == NULL) {
- gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
+ gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL,
+ LG_MSG_INVALID_ARG, "invalid argument");
return NULL;
}
@@ -682,7 +704,8 @@ fd_lookup (inode_t *inode, pid_t pid)
fd_t *fd = NULL;
if (!inode) {
- gf_log_callingfn ("fd", GF_LOG_WARNING, "!inode");
+ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL,
+ LG_MSG_INVALID_ARG, "!inode");
return NULL;
}
@@ -701,7 +724,8 @@ fd_lookup_uint64 (inode_t *inode, uint64_t pid)
fd_t *fd = NULL;
if (!inode) {
- gf_log_callingfn ("fd", GF_LOG_WARNING, "!inode");
+ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL,
+ LG_MSG_INVALID_ARG, "!inode");
return NULL;
}
@@ -781,7 +805,8 @@ fd_lookup_anonymous (inode_t *inode)
fd_t *fd = NULL;
if (!inode) {
- gf_log_callingfn ("fd", GF_LOG_WARNING, "!inode");
+ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL,
+ LG_MSG_INVALID_ARG, "!inode");
return NULL;
}
@@ -850,10 +875,6 @@ __fd_ctx_set (fd_t *fd, xlator_t *xlator, uint64_t value)
(sizeof (struct _fd_ctx)
* new_xl_count));
if (tmp == NULL) {
- gf_log_callingfn (THIS->name, GF_LOG_WARNING,
- "realloc of fd->_ctx for fd "
- "(ptr: %p) failed, cannot set the key"
- , fd);
ret = -1;
goto out;
}
@@ -885,7 +906,8 @@ fd_ctx_set (fd_t *fd, xlator_t *xlator, uint64_t value)
int ret = 0;
if (!fd || !xlator) {
- gf_log_callingfn ("", GF_LOG_WARNING, "%p %p", fd, xlator);
+ gf_msg_callingfn ("fd", GF_LOG_WARNING, EINVAL,
+ LG_MSG_INVALID_ARG, "%p %p", fd, xlator);
return -1;
}