summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libglusterfs/src/call-stub.c141
-rw-r--r--libglusterfs/src/common-utils.c32
-rw-r--r--libglusterfs/src/common-utils.h55
-rw-r--r--libglusterfs/src/compat.c60
-rw-r--r--libglusterfs/src/dict.c262
-rw-r--r--libglusterfs/src/event.c101
-rw-r--r--libglusterfs/src/fd.c58
-rw-r--r--libglusterfs/src/globals.c7
-rw-r--r--libglusterfs/src/graph-print.c2
-rw-r--r--libglusterfs/src/graph.c33
-rw-r--r--libglusterfs/src/inode.c136
-rw-r--r--libglusterfs/src/iobuf.c98
-rw-r--r--libglusterfs/src/rbthash.c2
-rw-r--r--libglusterfs/src/stack.c2
-rw-r--r--libglusterfs/src/statedump.c5
-rw-r--r--libglusterfs/src/timer.c13
-rw-r--r--libglusterfs/src/xlator.c49
17 files changed, 537 insertions, 519 deletions
diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c
index 50a06502c8d..3715dfffa2b 100644
--- a/libglusterfs/src/call-stub.c
+++ b/libglusterfs/src/call-stub.c
@@ -1519,12 +1519,11 @@ fop_inodelk_stub (call_frame_t *frame, fop_inodelk_t fn,
{
call_stub_t *stub = NULL;
- if (!frame || !lock)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
+ GF_VALIDATE_OR_GOTO ("call-stub", lock, out);
stub = stub_new (frame, 1, GF_FOP_INODELK);
- if (!stub)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.inodelk.fn = fn;
@@ -1534,7 +1533,7 @@ fop_inodelk_stub (call_frame_t *frame, fop_inodelk_t fn,
loc_copy (&stub->args.inodelk.loc, loc);
stub->args.inodelk.cmd = cmd;
stub->args.inodelk.lock = *lock;
-
+out:
return stub;
}
@@ -1544,17 +1543,16 @@ fop_inodelk_cbk_stub (call_frame_t *frame, fop_inodelk_cbk_t fn,
{
call_stub_t *stub = NULL;
- if (!frame)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_INODELK);
- if (!stub)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.inodelk_cbk.fn = fn;
stub->args.inodelk_cbk.op_ret = op_ret;
stub->args.inodelk_cbk.op_errno = op_errno;
+out:
return stub;
}
@@ -1565,12 +1563,11 @@ fop_finodelk_stub (call_frame_t *frame, fop_finodelk_t fn,
{
call_stub_t *stub = NULL;
- if (!frame || !lock)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
+ GF_VALIDATE_OR_GOTO ("call-stub", lock, out);
stub = stub_new (frame, 1, GF_FOP_FINODELK);
- if (!stub)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.finodelk.fn = fn;
@@ -1583,6 +1580,7 @@ fop_finodelk_stub (call_frame_t *frame, fop_finodelk_t fn,
stub->args.finodelk.cmd = cmd;
stub->args.finodelk.lock = *lock;
+out:
return stub;
}
@@ -1593,17 +1591,16 @@ fop_finodelk_cbk_stub (call_frame_t *frame, fop_inodelk_cbk_t fn,
{
call_stub_t *stub = NULL;
- if (!frame)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_FINODELK);
- if (!stub)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.finodelk_cbk.fn = fn;
stub->args.finodelk_cbk.op_ret = op_ret;
stub->args.finodelk_cbk.op_errno = op_errno;
+out:
return stub;
}
@@ -1615,12 +1612,10 @@ fop_entrylk_stub (call_frame_t *frame, fop_entrylk_t fn,
{
call_stub_t *stub = NULL;
- if (!frame)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 1, GF_FOP_ENTRYLK);
- if (!stub)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.entrylk.fn = fn;
@@ -1634,6 +1629,7 @@ fop_entrylk_stub (call_frame_t *frame, fop_entrylk_t fn,
if (name)
stub->args.entrylk.name = gf_strdup (name);
+out:
return stub;
}
@@ -1643,17 +1639,16 @@ fop_entrylk_cbk_stub (call_frame_t *frame, fop_entrylk_cbk_t fn,
{
call_stub_t *stub = NULL;
- if (!frame)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_ENTRYLK);
- if (!stub)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.entrylk_cbk.fn = fn;
stub->args.entrylk_cbk.op_ret = op_ret;
stub->args.entrylk_cbk.op_errno = op_errno;
+out:
return stub;
}
@@ -1665,12 +1660,10 @@ fop_fentrylk_stub (call_frame_t *frame, fop_fentrylk_t fn,
{
call_stub_t *stub = NULL;
- if (!frame)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 1, GF_FOP_FENTRYLK);
- if (!stub)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.fentrylk.fn = fn;
@@ -1684,6 +1677,7 @@ fop_fentrylk_stub (call_frame_t *frame, fop_fentrylk_t fn,
if (name)
stub->args.fentrylk.name = gf_strdup (name);
+out:
return stub;
}
@@ -1693,17 +1687,16 @@ fop_fentrylk_cbk_stub (call_frame_t *frame, fop_fentrylk_cbk_t fn,
{
call_stub_t *stub = NULL;
- if (!frame)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_FENTRYLK);
- if (!stub)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.fentrylk_cbk.fn = fn;
stub->args.fentrylk_cbk.op_ret = op_ret;
stub->args.fentrylk_cbk.op_errno = op_errno;
+out:
return stub;
}
@@ -1731,8 +1724,7 @@ fop_readdirp_cbk_stub (call_frame_t *frame,
/* This check must come after the init of head above
* so we're sure the list is empty for list_empty.
*/
- if (!entries)
- goto out;
+ GF_VALIDATE_OR_GOTO ("call-stub", entries, out);
if (op_ret > 0) {
list_for_each_entry (entry, &entries->list, list) {
@@ -1774,8 +1766,7 @@ fop_readdir_cbk_stub (call_frame_t *frame,
/* This check must come after the init of head above
* so we're sure the list is empty for list_empty.
*/
- if (!entries)
- goto out;
+ GF_VALIDATE_OR_GOTO ("call-stub", entries, out);
if (op_ret > 0) {
list_for_each_entry (entry, &entries->list, list) {
@@ -1803,11 +1794,14 @@ fop_readdir_stub (call_frame_t *frame,
call_stub_t *stub = NULL;
stub = stub_new (frame, 1, GF_FOP_READDIR);
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
+
stub->args.readdir.fn = fn;
stub->args.readdir.fd = fd_ref (fd);
stub->args.readdir.size = size;
stub->args.readdir.off = off;
+out:
return stub;
}
@@ -1821,11 +1815,14 @@ fop_readdirp_stub (call_frame_t *frame,
call_stub_t *stub = NULL;
stub = stub_new (frame, 1, GF_FOP_READDIRP);
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
+
stub->args.readdirp.fn = fn;
stub->args.readdirp.fd = fd_ref (fd);
stub->args.readdirp.size = size;
stub->args.readdirp.off = off;
+out:
return stub;
}
@@ -1917,6 +1914,8 @@ fop_fxattrop_cbk_stub (call_frame_t *frame,
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_FXATTROP);
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
+
stub->args.fxattrop_cbk.fn = fn;
stub->args.fxattrop_cbk.op_ret = op_ret;
stub->args.fxattrop_cbk.op_errno = op_errno;
@@ -1937,12 +1936,11 @@ fop_xattrop_stub (call_frame_t *frame,
{
call_stub_t *stub = NULL;
- if (!frame || !xattr)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
+ GF_VALIDATE_OR_GOTO ("call-stub", xattr, out);
stub = stub_new (frame, 1, GF_FOP_XATTROP);
- if (!stub)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.xattrop.fn = fn;
@@ -1951,6 +1949,7 @@ fop_xattrop_stub (call_frame_t *frame,
stub->args.xattrop.optype = optype;
stub->args.xattrop.xattr = dict_ref (xattr);
+out:
return stub;
}
@@ -1963,12 +1962,11 @@ fop_fxattrop_stub (call_frame_t *frame,
{
call_stub_t *stub = NULL;
- if (!frame || !xattr)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
+ GF_VALIDATE_OR_GOTO ("call-stub", xattr, out);
stub = stub_new (frame, 1, GF_FOP_FXATTROP);
- if (!stub)
- return NULL;
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.fxattrop.fn = fn;
@@ -1977,6 +1975,7 @@ fop_fxattrop_stub (call_frame_t *frame,
stub->args.fxattrop.optype = optype;
stub->args.fxattrop.xattr = dict_ref (xattr);
+out:
return stub;
}
@@ -1991,12 +1990,10 @@ fop_setattr_cbk_stub (call_frame_t *frame,
{
call_stub_t *stub = NULL;
- if (frame == NULL)
- goto out;
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_SETATTR);
- if (stub == NULL)
- goto out;
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.setattr_cbk.fn = fn;
@@ -2022,12 +2019,10 @@ fop_fsetattr_cbk_stub (call_frame_t *frame,
{
call_stub_t *stub = NULL;
- if (frame == NULL)
- goto out;
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_FSETATTR);
- if (stub == NULL)
- goto out;
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.fsetattr_cbk.fn = fn;
@@ -2051,15 +2046,11 @@ fop_setattr_stub (call_frame_t *frame,
{
call_stub_t *stub = NULL;
- if (frame == NULL)
- goto out;
-
- if (fn == NULL)
- goto out;
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
+ GF_VALIDATE_OR_GOTO ("call-stub", fn, out);
stub = stub_new (frame, 1, GF_FOP_SETATTR);
- if (stub == NULL)
- goto out;
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.setattr.fn = fn;
@@ -2083,15 +2074,11 @@ fop_fsetattr_stub (call_frame_t *frame,
{
call_stub_t *stub = NULL;
- if (frame == NULL)
- goto out;
-
- if (fn == NULL)
- goto out;
+ GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
+ GF_VALIDATE_OR_GOTO ("call-stub", fn, out);
stub = stub_new (frame, 1, GF_FOP_FSETATTR);
- if (stub == NULL)
- goto out;
+ GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.fsetattr.fn = fn;
@@ -2495,8 +2482,9 @@ call_resume_wind (call_stub_t *stub)
}
default:
{
- gf_log ("call-stub", GF_LOG_ERROR, "Invalid value of FOP (%d)",
- stub->fop);
+ gf_log_callingfn ("call-stub", GF_LOG_ERROR,
+ "Invalid value of FOP (%d)",
+ stub->fop);
break;
}
@@ -3290,8 +3278,9 @@ call_resume_unwind (call_stub_t *stub)
}
default:
{
- gf_log ("call-stub", GF_LOG_ERROR, "Invalid value of FOP (%d)",
- stub->fop);
+ gf_log_callingfn ("call-stub", GF_LOG_ERROR,
+ "Invalid value of FOP (%d)",
+ stub->fop);
break;
}
}
@@ -3601,8 +3590,9 @@ call_stub_destroy_wind (call_stub_t *stub)
}
default:
{
- gf_log ("call-stub", GF_LOG_ERROR, "Invalid value of FOP (%d)",
- stub->fop);
+ gf_log_callingfn ("call-stub", GF_LOG_ERROR,
+ "Invalid value of FOP (%d)",
+ stub->fop);
break;
}
}
@@ -3822,8 +3812,9 @@ call_stub_destroy_unwind (call_stub_t *stub)
default:
{
- gf_log ("call-stub", GF_LOG_ERROR, "Invalid value of FOP (%d)",
- stub->fop);
+ gf_log_callingfn ("call-stub", GF_LOG_ERROR,
+ "Invalid value of FOP (%d)",
+ stub->fop);
break;
}
}
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 3ae0f54c78c..21506636cd7 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -85,7 +85,7 @@ gf_resolve_ip6 (const char *hostname,
char service[NI_MAXSERV], host[NI_MAXHOST];
if (!hostname) {
- gf_log ("resolver", GF_LOG_WARNING, "hostname is NULL");
+ gf_log_callingfn ("resolver", GF_LOG_WARNING, "hostname is NULL");
return -1;
}
@@ -141,13 +141,12 @@ gf_resolve_ip6 (const char *hostname,
service, sizeof (service),
NI_NUMERICHOST);
if (ret != 0) {
- gf_log ("resolver",
- GF_LOG_ERROR,
+ gf_log ("resolver", GF_LOG_ERROR,
"getnameinfo failed (%s)", gai_strerror (ret));
goto err;
}
- gf_log ("resolver", GF_LOG_TRACE,
+ gf_log ("resolver", GF_LOG_DEBUG,
"returning ip-%s (port-%s) for hostname: %s and port: %d",
host, service, hostname, port);
@@ -163,13 +162,12 @@ gf_resolve_ip6 (const char *hostname,
service, sizeof (service),
NI_NUMERICHOST);
if (ret != 0) {
- gf_log ("resolver",
- GF_LOG_ERROR,
+ gf_log ("resolver", GF_LOG_ERROR,
"getnameinfo failed (%s)", gai_strerror (ret));
goto err;
}
- gf_log ("resolver", GF_LOG_TRACE,
+ gf_log ("resolver", GF_LOG_DEBUG,
"next DNS query will return: ip-%s port-%s", host, service);
}
@@ -452,8 +450,8 @@ gf_strsplit (const char *str, const char *delim,
int i = 0;
int j = 0;
- if (str == NULL || delim == NULL || tokens == NULL || token_count == NULL)
- {
+ if (str == NULL || delim == NULL || tokens == NULL || token_count == NULL) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "arguement invalid");
return -1;
}
@@ -524,6 +522,7 @@ gf_strstr (const char *str, const char *delim, const char *match)
tmp_str = strdup (str);
if (str == NULL || delim == NULL || match == NULL || tmp_str == NULL) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "arguement invalid");
ret = -1;
goto out;
}
@@ -553,8 +552,8 @@ gf_volume_name_validate (const char *volume_name)
{
const char *vname = NULL;
- if (volume_name == NULL)
- {
+ if (volume_name == NULL) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "arguement invalid");
return -1;
}
@@ -583,6 +582,7 @@ gf_string2time (const char *str, uint32_t *n)
if (str == NULL || n == NULL)
{
+ gf_log_callingfn ("", GF_LOG_WARNING, "arguement invalid");
errno = EINVAL;
return -1;
}
@@ -637,6 +637,7 @@ gf_string2percent (const char *str, uint32_t *n)
if (str == NULL || n == NULL)
{
+ gf_log_callingfn ("", GF_LOG_WARNING, "arguement invalid");
errno = EINVAL;
return -1;
}
@@ -689,6 +690,7 @@ _gf_string2long (const char *str, long *n, int base)
if (str == NULL || n == NULL)
{
+ gf_log_callingfn ("", GF_LOG_WARNING, "arguement invalid");
errno = EINVAL;
return -1;
}
@@ -728,6 +730,7 @@ _gf_string2ulong (const char *str, unsigned long *n, int base)
if (str == NULL || n == NULL)
{
+ gf_log_callingfn ("", GF_LOG_WARNING, "arguement invalid");
errno = EINVAL;
return -1;
}
@@ -782,6 +785,7 @@ _gf_string2uint (const char *str, unsigned int *n, int base)
if (str == NULL || n == NULL)
{
+ gf_log_callingfn ("", GF_LOG_WARNING, "arguement invalid");
errno = EINVAL;
return -1;
}
@@ -834,6 +838,7 @@ _gf_string2double (const char *str, double *n)
int old_errno = 0;
if (str == NULL || n == NULL) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "arguement invalid");
errno = EINVAL;
return -1;
}
@@ -868,6 +873,7 @@ _gf_string2longlong (const char *str, long long *n, int base)
if (str == NULL || n == NULL)
{
+ gf_log_callingfn ("", GF_LOG_WARNING, "arguement invalid");
errno = EINVAL;
return -1;
}
@@ -907,6 +913,7 @@ _gf_string2ulonglong (const char *str, unsigned long long *n, int base)
if (str == NULL || n == NULL)
{
+ gf_log_callingfn ("", GF_LOG_WARNING, "arguement invalid");
errno = EINVAL;
return -1;
}
@@ -1261,6 +1268,7 @@ gf_string2bytesize (const char *str, uint64_t *n)
if (str == NULL || n == NULL)
{
+ gf_log_callingfn ("", GF_LOG_WARNING, "arguement invalid");
errno = EINVAL;
return -1;
}
@@ -1371,6 +1379,7 @@ int
gf_string2boolean (const char *str, gf_boolean_t *b)
{
if (str == NULL) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "arguement invalid");
return -1;
}
@@ -1676,6 +1685,7 @@ valid_internet_address (char *address)
int length = 0;
if (address == NULL) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "arguement invalid");
goto out;
}
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index 178eceea2b6..7a18b12cda2 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -94,40 +94,41 @@ extern char *gf_mgmt_list[GF_MGMT_MAXVALUE];
#define VALIDATE_OR_GOTO(arg,label) do { \
if (!arg) { \
errno = EINVAL; \
- gf_log ((this ? this->name : "(Govinda! Govinda!)"), \
- GF_LOG_ERROR, \
- "invalid argument: " #arg); \
+ gf_log_callingfn ((this ? (this->name) : \
+ "(Govinda! Govinda!)"), \
+ GF_LOG_WARNING, \
+ "invalid argument: " #arg); \
goto label; \
} \
} while (0);
-#define GF_VALIDATE_OR_GOTO(name,arg,label) do { \
- if (!arg) { \
- errno = EINVAL; \
- gf_log (name, GF_LOG_ERROR, \
- "invalid argument: " #arg); \
- goto label; \
- } \
+#define GF_VALIDATE_OR_GOTO(name,arg,label) do { \
+ if (!arg) { \
+ errno = EINVAL; \
+ gf_log_callingfn (name, GF_LOG_ERROR, \
+ "invalid argument: " #arg); \
+ goto label; \
+ } \
} while (0);
#define GF_VALIDATE_OR_GOTO_WITH_ERROR(name, arg, label, errno, error) do { \
if (!arg) { \
errno = error; \
- gf_log (name, GF_LOG_ERROR, \
- "invalid argument: " #arg); \
+ gf_log_callingfn (name, GF_LOG_ERROR, \
+ "invalid argument: " #arg); \
goto label; \
} \
}while (0);
-#define GF_VALIDATE_ABSOLUTE_PATH_OR_GOTO(name,arg,label) \
- do { \
- GF_VALIDATE_OR_GOTO (name, arg, label); \
- if ((arg[0]) != '/') { \
- errno = EINVAL; \
- gf_log (name, GF_LOG_ERROR, \
- "invalid argument: " #arg); \
- goto label; \
- } \
+#define GF_VALIDATE_ABSOLUTE_PATH_OR_GOTO(name,arg,label) \
+ do { \
+ GF_VALIDATE_OR_GOTO (name, arg, label); \
+ if ((arg[0]) != '/') { \
+ errno = EINVAL; \
+ gf_log_callingfn (name, GF_LOG_ERROR, \
+ "invalid argument: " #arg); \
+ goto label; \
+ } \
} while (0);
#define GF_FILE_CONTENT_REQUESTED(_xattr_req,_content_limit) \
@@ -136,12 +137,12 @@ extern char *gf_mgmt_list[GF_MGMT_MAXVALUE];
#ifdef DEBUG
#define GF_ASSERT(x) assert (x);
#else
-#define GF_ASSERT(x)\
- do { \
- if (!(x)) { \
- gf_log_callingfn ("", GF_LOG_ERROR, \
- "Assertion failed: " #x); \
- } \
+#define GF_ASSERT(x) \
+ do { \
+ if (!(x)) { \
+ gf_log_callingfn ("", GF_LOG_ERROR, \
+ "Assertion failed: " #x); \
+ } \
} while (0);
#endif
diff --git a/libglusterfs/src/compat.c b/libglusterfs/src/compat.c
index a24f3aabd65..42c20f52756 100644
--- a/libglusterfs/src/compat.c
+++ b/libglusterfs/src/compat.c
@@ -40,10 +40,7 @@
#ifdef GF_SOLARIS_HOST_OS
int
-solaris_fsetxattr(int fd,
- const char* key,
- const char *value,
- size_t size,
+solaris_fsetxattr(int fd, const char* key, const char *value, size_t size,
int flags)
{
int attrfd = -1;
@@ -67,10 +64,7 @@ solaris_fsetxattr(int fd,
int
-solaris_fgetxattr(int fd,
- const char* key,
- char *value,
- size_t size)
+solaris_fgetxattr(int fd, const char* key, char *value, size_t size)
{
int attrfd = -1;
int ret = 0;
@@ -86,12 +80,12 @@ solaris_fgetxattr(int fd,
}
close (attrfd);
} else {
- if (errno == ENOENT)
- errno = ENODATA;
if (errno != ENOENT)
- gf_log ("libglusterfs", GF_LOG_DEBUG,
+ gf_log ("libglusterfs", GF_LOG_INFO,
"Couldn't read extended attribute for the file %d (%d)",
fd, errno);
+ if (errno == ENOENT)
+ errno = ENODATA;
return -1;
}
@@ -219,11 +213,8 @@ out:
}
int
-solaris_setxattr(const char *path,
- const char* key,
- const char *value,
- size_t size,
- int flags)
+solaris_setxattr(const char *path, const char* key, const char *value,
+ size_t size, int flags)
{
int attrfd = -1;
int ret = 0;
@@ -255,9 +246,7 @@ solaris_setxattr(const char *path,
int
-solaris_listxattr(const char *path,
- char *list,
- size_t size)
+solaris_listxattr(const char *path, char *list, size_t size)
{
int attrdirfd = -1;
ssize_t len = 0;
@@ -279,15 +268,18 @@ solaris_listxattr(const char *path,
if (dirptr) {
while ((dent = readdir(dirptr))) {
size_t listlen = strlen(dent->d_name);
- if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) {
+ if (!strcmp(dent->d_name, ".") ||
+ !strcmp(dent->d_name, "..")) {
/* we don't want "." and ".." here */
continue;
}
if (size == 0) {
- /* return the current size of the list of extended attribute names*/
+ /* return the current size of the list
+ of extended attribute names*/
len += listlen + 1;
} else {
- /* check size and copy entrie + nul into list. */
+ /* check size and copy entry + null
+ into list. */
if ((len + listlen + 1) > size) {
errno = ERANGE;
len = -1;
@@ -321,9 +313,7 @@ out:
int
-solaris_flistxattr(int fd,
- char *list,
- size_t size)
+solaris_flistxattr(int fd, char *list, size_t size)
{
int attrdirfd = -1;
ssize_t len = 0;
@@ -338,15 +328,18 @@ solaris_flistxattr(int fd,
if (dirptr) {
while ((dent = readdir(dirptr))) {
size_t listlen = strlen(dent->d_name);
- if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) {
+ if (!strcmp(dent->d_name, ".") ||
+ !strcmp(dent->d_name, "..")) {
/* we don't want "." and ".." here */
continue;
}
if (size == 0) {
- /* return the current size of the list of extended attribute names*/
+ /* return the current size of the list
+ of extended attribute names*/
len += listlen + 1;
} else {
- /* check size and copy entrie + nul into list. */
+ /* check size and copy entry + null
+ into list. */
if ((len + listlen + 1) > size) {
errno = ERANGE;
len = -1;
@@ -375,8 +368,7 @@ solaris_flistxattr(int fd,
int
-solaris_removexattr(const char *path,
- const char* key)
+solaris_removexattr(const char *path, const char* key)
{
int ret = -1;
int attrfd = -1;
@@ -430,12 +422,12 @@ solaris_getxattr(const char *path,
}
close (attrfd);
} else {
+ if (errno != ENOENT)
+ gf_log ("libglusterfs", GF_LOG_INFO,
+ "Couldn't read extended attribute for the file %s (%s)",
+ path, strerror (errno));
if (errno == ENOENT)
errno = ENODATA;
- if (errno != ENOENT)
- gf_log ("libglusterfs", GF_LOG_DEBUG,
- "Couldn't read extended attribute for the file %s (%d)",
- path, errno);
ret = -1;
}
if (mapped_path)
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index 64ba7a0ac96..56ea68cd00e 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -43,9 +43,6 @@ get_new_data_pair ()
data_pair_ptr = (data_pair_t *) GF_CALLOC (1, sizeof (data_pair_t),
gf_common_mt_data_pair_t);
- if (!data_pair_ptr)
- gf_log ("dict", GF_LOG_ERROR, "memory alloc failed");
-
return data_pair_ptr;
}
@@ -56,8 +53,6 @@ get_new_data ()
data = (data_t *) GF_CALLOC (1, sizeof (data_t), gf_common_mt_data_t);
if (!data) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "calloc () returned NULL");
return NULL;
}
@@ -71,8 +66,6 @@ get_new_dict_full (int size_hint)
dict_t *dict = GF_CALLOC (1, sizeof (dict_t), gf_common_mt_dict_t);
if (!dict) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "calloc () returned NULL");
return NULL;
}
@@ -81,8 +74,7 @@ get_new_dict_full (int size_hint)
gf_common_mt_data_pair_t);
if (!dict->members) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "calloc () returned NULL");
+ GF_FREE (dict);
return NULL;
}
@@ -115,6 +107,7 @@ int32_t
is_data_equal (data_t *one,
data_t *two)
{
+ /* LOG-TODO */
if (!one || !two || !one->data || !two->data)
return 1;
@@ -160,8 +153,8 @@ data_t *
data_copy (data_t *old)
{
if (!old) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@old is NULL");
+ gf_log_callingfn ("dict", GF_LOG_WARNING,
+ "old is NULL");
return NULL;
}
@@ -169,8 +162,6 @@ data_copy (data_t *old)
gf_common_mt_data_t);
if (!newdata) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@newdata - NULL returned by CALLOC");
return NULL;
}
@@ -200,8 +191,6 @@ err_out:
FREE (newdata->vec);
GF_FREE (newdata);
- gf_log ("dict", GF_LOG_CRITICAL,
- "@newdata->data || @newdata->vec got NULL from CALLOC()");
return NULL;
}
@@ -209,8 +198,8 @@ static data_pair_t *
_dict_lookup (dict_t *this, char *key)
{
if (!this || !key) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@this=%p @key=%p", this, key);
+ gf_log_callingfn ("dict", GF_LOG_WARNING,
+ "!this || !key (%s)", key);
return NULL;
}
@@ -240,7 +229,7 @@ _dict_set (dict_t *this,
if (!key) {
ret = gf_asprintf (&key, "ref:%p", value);
if (-1 == ret) {
- gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
+ gf_log ("dict", GF_LOG_WARNING, "asprintf failed %s", key);
return -1;
}
key_free = 1;
@@ -262,16 +251,12 @@ _dict_set (dict_t *this,
pair = (data_pair_t *) GF_CALLOC (1, sizeof (*pair),
gf_common_mt_data_pair_t);
if (!pair) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@pair - NULL returned by CALLOC");
return -1;
}
pair->key = (char *) GF_CALLOC (1, strlen (key) + 1,
gf_common_mt_char);
if (!pair->key) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@pair->key - NULL returned by CALLOC");
GF_FREE (pair);
if (key_free)
@@ -305,8 +290,8 @@ dict_set (dict_t *this,
int32_t ret;
if (!this || !value) {
- gf_log ("dict", GF_LOG_ERROR,
- "@this=%p @value=%p, key=%s", this, value, key);
+ gf_log_callingfn ("dict", GF_LOG_WARNING,
+ "!this || !value for key=%s", key);
return -1;
}
@@ -321,14 +306,13 @@ dict_set (dict_t *this,
data_t *
-dict_get (dict_t *this,
- char *key)
+dict_get (dict_t *this, char *key)
{
data_pair_t *pair;
if (!this || !key) {
- gf_log_callingfn ("dict", GF_LOG_DEBUG,
- "@this=%p key=%s", this, (key) ? key : "()");
+ gf_log_callingfn ("dict", GF_LOG_INFO,
+ "!this || key=%s", (key) ? key : "()");
return NULL;
}
@@ -345,12 +329,11 @@ dict_get (dict_t *this,
}
void
-dict_del (dict_t *this,
- char *key)
+dict_del (dict_t *this, char *key)
{
if (!this || !key) {
- gf_log ("dict", GF_LOG_DEBUG,
- "@this=%p @key=%p", this, key);
+ gf_log_callingfn ("dict", GF_LOG_WARNING,
+ "!this || key=%s", key);
return;
}
@@ -396,8 +379,7 @@ void
dict_destroy (dict_t *this)
{
if (!this) {
- gf_log ("dict", GF_LOG_DEBUG,
- "@this=%p", this);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL");
return;
}
@@ -433,8 +415,7 @@ dict_unref (dict_t *this)
int32_t ref;
if (!this) {
- gf_log ("dict", GF_LOG_DEBUG,
- "@this=%p", this);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL");
return;
}
@@ -453,8 +434,7 @@ dict_t *
dict_ref (dict_t *this)
{
if (!this) {
- gf_log ("dict", GF_LOG_DEBUG,
- "@this=%p", this);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL");
return NULL;
}
@@ -473,8 +453,7 @@ data_unref (data_t *this)
int32_t ref;
if (!this) {
- gf_log ("dict", GF_LOG_DEBUG,
- "@this=%p", this);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL");
return;
}
@@ -493,8 +472,7 @@ data_t *
data_ref (data_t *this)
{
if (!this) {
- gf_log ("dict", GF_LOG_DEBUG,
- "@this=%p", this);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL");
return NULL;
}
@@ -524,8 +502,7 @@ dict_serialized_length_old (dict_t *this)
{
if (!this) {
- gf_log ("dict", GF_LOG_DEBUG,
- "@this=%p", this);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL");
return -1;
}
@@ -555,8 +532,7 @@ int32_t
dict_serialize_old (dict_t *this, char *buf)
{
if (!this || !buf) {
- gf_log ("dict", GF_LOG_DEBUG,
- "@this=%p @buf=%p", this, buf);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL");
return -1;
}
@@ -592,9 +568,7 @@ dict_unserialize_old (char *buf, int32_t size, dict_t **fill)
int32_t cnt = 0;
if (!buf || !fill || !(*fill)) {
- gf_log ("dict", GF_LOG_ERROR,
- "@buf=%p @fill=%p @*fill=%p",
- buf, fill, (fill) ? (*fill) : NULL);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "buf is NULL");
return NULL;
}
@@ -603,17 +577,13 @@ dict_unserialize_old (char *buf, int32_t size, dict_t **fill)
(*fill)->count = 0;
if (!ret){
- gf_log ("dict",
- GF_LOG_ERROR,
- "sscanf on buf failed");
+ gf_log ("dict", GF_LOG_ERROR, "sscanf on buf failed");
goto err;
}
buf += 9;
if (count == 0) {
- gf_log ("dict",
- GF_LOG_ERROR,
- "count == 0");
+ gf_log ("dict", GF_LOG_ERROR, "count == 0");
goto err;
}
@@ -624,8 +594,7 @@ dict_unserialize_old (char *buf, int32_t size, dict_t **fill)
ret = sscanf (buf, "%"SCNx64":%"SCNx64"\n", &key_len, &value_len);
if (ret != 2) {
- gf_log ("dict",
- GF_LOG_ERROR,
+ gf_log ("dict", GF_LOG_ERROR,
"sscanf for key_len and value_len failed");
goto err;
}
@@ -658,8 +627,7 @@ int32_t
dict_iovec_len (dict_t *this)
{
if (!this) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@this=%p", this);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL");
return -1;
}
@@ -687,8 +655,7 @@ dict_to_iovec (dict_t *this,
int32_t count)
{
if (!this || !vec) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@this=%p @vec=%p", this, vec);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL");
return -1;
}
@@ -755,14 +722,12 @@ int_to_data (int64_t value)
data_t *data = get_new_data ();
if (!data) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data - NULL returned by CALLOC");
return NULL;
}
ret = gf_asprintf (&data->data, "%"PRId64, value);
if (-1 == ret) {
- gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
+ gf_log ("dict", GF_LOG_DEBUG, "asprintf failed");
return NULL;
}
data->len = strlen (data->data) + 1;
@@ -777,13 +742,11 @@ data_from_int64 (int64_t value)
data_t *data = get_new_data ();
if (!data) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data - NULL returned by CALLOC");
return NULL;
}
ret = gf_asprintf (&data->data, "%"PRId64, value);
if (-1 == ret) {
- gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
+ gf_log ("dict", GF_LOG_DEBUG, "asprintf failed");
return NULL;
}
data->len = strlen (data->data) + 1;
@@ -798,13 +761,11 @@ data_from_int32 (int32_t value)
data_t *data = get_new_data ();
if (!data) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data - NULL returned by CALLOC");
return NULL;
}
ret = gf_asprintf (&data->data, "%"PRId32, value);
if (-1 == ret) {
- gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
+ gf_log ("dict", GF_LOG_DEBUG, "asprintf failed");
return NULL;
}
@@ -820,13 +781,11 @@ data_from_int16 (int16_t value)
data_t *data = get_new_data ();
if (!data) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data - NULL returned by CALLOC");
return NULL;
}
ret = gf_asprintf (&data->data, "%"PRId16, value);
if (-1 == ret) {
- gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
+ gf_log ("dict", GF_LOG_DEBUG, "asprintf failed");
return NULL;
}
@@ -842,13 +801,11 @@ data_from_int8 (int8_t value)
data_t *data = get_new_data ();
if (!data) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data - NULL returned by CALLOC");
return NULL;
}
ret = gf_asprintf (&data->data, "%d", value);
if (-1 == ret) {
- gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
+ gf_log ("dict", GF_LOG_DEBUG, "asprintf failed");
return NULL;
}
@@ -864,13 +821,11 @@ data_from_uint64 (uint64_t value)
data_t *data = get_new_data ();
if (!data) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data - NULL returned by CALLOC");
return NULL;
}
ret = gf_asprintf (&data->data, "%"PRIu64, value);
if (-1 == ret) {
- gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
+ gf_log ("dict", GF_LOG_DEBUG, "asprintf failed");
return NULL;
}
@@ -888,15 +843,11 @@ data_from_double (double value)
data = get_new_data ();
if (!data) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data - NULL returned by CALLOC");
return NULL;
}
ret = gf_asprintf (&data->data, "%f", value);
if (ret == -1) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data - allocation failed by ASPRINTF");
return NULL;
}
data->len = strlen (data->data) + 1;
@@ -912,13 +863,11 @@ data_from_uint32 (uint32_t value)
data_t *data = get_new_data ();
if (!data) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data - NULL returned by CALLOC");
return NULL;
}
ret = gf_asprintf (&data->data, "%"PRIu32, value);
if (-1 == ret) {
- gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
+ gf_log ("dict", GF_LOG_DEBUG, "asprintf failed");
return NULL;
}
@@ -935,13 +884,10 @@ data_from_uint16 (uint16_t value)
data_t *data = get_new_data ();
if (!data) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data - NULL returned by CALLOC");
return NULL;
}
ret = gf_asprintf (&data->data, "%"PRIu16, value);
if (-1 == ret) {
- gf_log ("dict", GF_LOG_ERROR, "asprintf failed");
return NULL;
}
@@ -955,16 +901,13 @@ data_t *
data_from_ptr (void *value)
{
if (!value) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@value=%p", value);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "value is NULL");
return NULL;
}
data_t *data = get_new_data ();
if (!data) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data - NULL returned by CALLOC");
return NULL;
}
@@ -987,8 +930,6 @@ data_from_static_ptr (void *value)
data_t *data = get_new_data ();
if (!data) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data - NULL returned by CALLOC");
return NULL;
}
@@ -1002,15 +943,12 @@ data_t *
str_to_data (char *value)
{
if (!value) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@value=%p", value);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "value is NULL");
return NULL;
}
data_t *data = get_new_data ();
if (!data) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data - NULL returned by CALLOC");
return NULL;
}
data->len = strlen (value) + 1;
@@ -1025,8 +963,7 @@ data_t *
data_from_dynstr (char *value)
{
if (!value) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@value=%p", value);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "value is NULL");
return NULL;
}
@@ -1042,8 +979,7 @@ data_t *
data_from_dynmstr (char *value)
{
if (!value) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@value=%p", value);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "value is NULL");
return NULL;
}
@@ -1061,6 +997,9 @@ data_from_dynptr (void *value, int32_t len)
{
data_t *data = get_new_data ();
+ if (!data)
+ return NULL;
+
data->len = len;
data->data = value;
@@ -1071,13 +1010,15 @@ data_t *
bin_to_data (void *value, int32_t len)
{
if (!value) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@value=%p", value);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "value is NULL");
return NULL;
}
data_t *data = get_new_data ();
+ if (!data)
+ return NULL;
+
data->is_static = 1;
data->len = len;
data->data = value;
@@ -1088,8 +1029,10 @@ bin_to_data (void *value, int32_t len)
int64_t
data_to_int64 (data_t *data)
{
- if (!data)
+ if (!data) {
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL");
return -1;
+ }
char *str = alloca (data->len + 1);
if (!str)
@@ -1103,8 +1046,10 @@ data_to_int64 (data_t *data)
int32_t
data_to_int32 (data_t *data)
{
- if (!data)
+ if (!data) {
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL");
return -1;
+ }
char *str = alloca (data->len + 1);
if (!str)
@@ -1119,8 +1064,10 @@ data_to_int32 (data_t *data)
int16_t
data_to_int16 (data_t *data)
{
- if (!data)
+ if (!data) {
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL");
return -1;
+ }
char *str = alloca (data->len + 1);
if (!str)
@@ -1136,8 +1083,10 @@ data_to_int16 (data_t *data)
int8_t
data_to_int8 (data_t *data)
{
- if (!data)
+ if (!data) {
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL");
return -1;
+ }
char *str = alloca (data->len + 1);
if (!str)
@@ -1201,8 +1150,7 @@ char *
data_to_str (data_t *data)
{
if (!data) {
- gf_log ("dict", GF_LOG_WARNING,
- "@data=%p", data);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL");
return NULL;
}
return data->data;
@@ -1212,6 +1160,7 @@ void *
data_to_ptr (data_t *data)
{
if (!data) {
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL");
return NULL;
}
return data->data;
@@ -1221,8 +1170,7 @@ void *
data_to_bin (data_t *data)
{
if (!data) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data=%p", data);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL");
return NULL;
}
return data->data;
@@ -1237,8 +1185,8 @@ dict_foreach (dict_t *dict,
void *data)
{
if (!data || !dict) {
- gf_log_callingfn ("dict", GF_LOG_CRITICAL,
- "@data=%p, @dict=%p", data, dict);
+ gf_log_callingfn ("dict", GF_LOG_WARNING,
+ "data OR dict is NULL");
return;
}
@@ -1268,8 +1216,7 @@ dict_copy (dict_t *dict,
dict_t *new)
{
if (!dict) {
- gf_log ("dict", GF_LOG_CRITICAL,
- "@data=%p", dict);
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL");
return NULL;
}
@@ -1319,6 +1266,8 @@ dict_get_with_ref (dict_t *this, char *key, data_t **data)
int ret = -ENOENT;
if (!this || !key || !data) {
+ gf_log_callingfn ("dict", GF_LOG_WARNING,
+ "dict OR key (%s) is NULL", key);
ret = -EINVAL;
goto err;
}
@@ -2433,7 +2382,7 @@ dict_serialized_length (dict_t *this)
int ret = -EINVAL;
if (!this) {
- gf_log ("dict", GF_LOG_ERROR, "this is null!");
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is null!");
goto out;
}
@@ -2463,14 +2412,8 @@ dict_serialize (dict_t *this, char *buf)
{
int ret = -1;
- if (!this) {
- gf_log ("dict", GF_LOG_ERROR,
- "this is null!");
- goto out;
- }
- if (!buf) {
- gf_log ("dict", GF_LOG_ERROR,
- "buf is null!");
+ if (!this || !buf) {
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is null!");
goto out;
}
@@ -2512,32 +2455,34 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill)
buf = orig_buf;
if (!buf) {
- gf_log ("dict", GF_LOG_ERROR,
- "buf is null!");
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "buf is null!");
goto out;
}
if (size == 0) {
- gf_log ("dict", GF_LOG_ERROR,
+ gf_log_callingfn ("dict", GF_LOG_ERROR,
"size is 0!");
goto out;
}
if (!fill) {
- gf_log ("dict", GF_LOG_ERROR,
+ gf_log_callingfn ("dict", GF_LOG_ERROR,
"fill is null!");
goto out;
}
if (!*fill) {
- gf_log ("dict", GF_LOG_ERROR,
+ gf_log_callingfn ("dict", GF_LOG_ERROR,
"*fill is null!");
goto out;
}
if ((buf + DICT_HDR_LEN) > (orig_buf + size)) {
- gf_log ("dict", GF_LOG_ERROR,
- "undersized buffer passed");
+ gf_log_callingfn ("dict", GF_LOG_ERROR,
+ "undersized buffer passed. "
+ "available (%lu) < required (%lu)",
+ (long)(orig_buf + size),
+ (long)(buf + DICT_HDR_LEN));
goto out;
}
@@ -2556,11 +2501,11 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill)
for (i = 0; i < count; i++) {
if ((buf + DICT_DATA_HDR_KEY_LEN) > (orig_buf + size)) {
- gf_log ("dict", GF_LOG_DEBUG,
- "No room for keylen (size %d).",
- DICT_DATA_HDR_KEY_LEN);
- gf_log ("dict", GF_LOG_ERROR,
- "undersized buffer passed");
+ gf_log_callingfn ("dict", GF_LOG_ERROR,
+ "undersized buffer passed. "
+ "available (%lu) < required (%lu)",
+ (long)(orig_buf + size),
+ (long)(buf + DICT_DATA_HDR_KEY_LEN));
goto out;
}
memcpy (&hostord, buf, sizeof(hostord));
@@ -2568,11 +2513,11 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill)
buf += DICT_DATA_HDR_KEY_LEN;
if ((buf + DICT_DATA_HDR_VAL_LEN) > (orig_buf + size)) {
- gf_log ("dict", GF_LOG_DEBUG,
- "No room for vallen (size %d).",
- DICT_DATA_HDR_VAL_LEN);
- gf_log ("dict", GF_LOG_ERROR,
- "undersized buffer passed");
+ gf_log_callingfn ("dict", GF_LOG_ERROR,
+ "undersized buffer passed. "
+ "available (%lu) < required (%lu)",
+ (long)(orig_buf + size),
+ (long)(buf + DICT_DATA_HDR_VAL_LEN));
goto out;
}
memcpy (&hostord, buf, sizeof(hostord));
@@ -2580,21 +2525,22 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill)
buf += DICT_DATA_HDR_VAL_LEN;
if ((buf + keylen) > (orig_buf + size)) {
- gf_log ("dict", GF_LOG_DEBUG,
- "No room for key (size %d).", keylen);
- gf_log ("dict", GF_LOG_ERROR,
- "undersized buffer passed");
+ gf_log_callingfn ("dict", GF_LOG_ERROR,
+ "undersized buffer passed. "
+ "available (%lu) < required (%lu)",
+ (long)(orig_buf + size),
+ (long)(buf + keylen));
goto out;
}
key = buf;
buf += keylen + 1; /* for '\0' */
if ((buf + vallen) > (orig_buf + size)) {
- gf_log ("dict", GF_LOG_DEBUG,
- "No room for value (size %d).", vallen);
- gf_log ("dict", GF_LOG_ERROR,
- "undersized buffer passed");
- goto out;
+ gf_log_callingfn ("dict", GF_LOG_ERROR,
+ "undersized buffer passed. "
+ "available (%lu) < required (%lu)",
+ (long)(orig_buf + size),
+ (long)(buf + vallen));
}
value = get_new_data ();
value->len = vallen;
@@ -2628,14 +2574,9 @@ dict_allocate_and_serialize (dict_t *this, char **buf, size_t *length)
int ret = -EINVAL;
ssize_t len = 0;
- if (!this) {
- gf_log ("dict", GF_LOG_DEBUG,
- "NULL passed as this pointer");
- goto out;
- }
- if (!buf) {
- gf_log ("dict", GF_LOG_DEBUG,
- "NULL passed as buf");
+ if (!this || !buf) {
+ gf_log_callingfn ("dict", GF_LOG_DEBUG,
+ "dict OR buf is NULL");
goto out;
}
@@ -2650,7 +2591,6 @@ dict_allocate_and_serialize (dict_t *this, char **buf, size_t *length)
*buf = GF_CALLOC (1, len, gf_common_mt_char);
if (*buf == NULL) {
ret = -ENOMEM;
- gf_log ("dict", GF_LOG_ERROR, "out of memory");
goto unlock;
}
diff --git a/libglusterfs/src/event.c b/libglusterfs/src/event.c
index 4f64966b2d9..1692832f8e1 100644
--- a/libglusterfs/src/event.c
+++ b/libglusterfs/src/event.c
@@ -28,7 +28,7 @@
#include "logging.h"
#include "event.h"
#include "mem-pool.h"
-
+#include "common-utils.h"
#ifndef _CONFIG_H
#define _CONFIG_H
@@ -70,10 +70,7 @@ __event_getindex (struct event_pool *event_pool, int fd, int idx)
int ret = -1;
int i = 0;
- if (event_pool == NULL) {
- gf_log ("event", GF_LOG_ERROR, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("event", event_pool, out);
if (idx > -1 && idx < event_pool->used) {
if (event_pool->reg[idx].fd == fd)
@@ -87,6 +84,7 @@ __event_getindex (struct event_pool *event_pool, int fd, int idx)
}
}
+out:
return ret;
}
@@ -109,8 +107,6 @@ event_pool_new_poll (int count)
gf_common_mt_reg);
if (!event_pool->reg) {
- gf_log ("poll", GF_LOG_CRITICAL,
- "failed to allocate event registry");
GF_FREE (event_pool);
return NULL;
}
@@ -181,10 +177,7 @@ event_register_poll (struct event_pool *event_pool, int fd,
{
int idx = -1;
- if (event_pool == NULL) {
- gf_log ("event", GF_LOG_ERROR, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("event", event_pool, out);
pthread_mutex_lock (&event_pool->mutex);
{
@@ -244,6 +237,7 @@ event_register_poll (struct event_pool *event_pool, int fd,
unlock:
pthread_mutex_unlock (&event_pool->mutex);
+out:
return idx;
}
@@ -253,10 +247,7 @@ event_unregister_poll (struct event_pool *event_pool, int fd, int idx_hint)
{
int idx = -1;
- if (event_pool == NULL) {
- gf_log ("event", GF_LOG_ERROR, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("event", event_pool, out);
pthread_mutex_lock (&event_pool->mutex);
{
@@ -276,6 +267,7 @@ event_unregister_poll (struct event_pool *event_pool, int fd, int idx_hint)
unlock:
pthread_mutex_unlock (&event_pool->mutex);
+out:
return idx;
}
@@ -286,10 +278,7 @@ event_select_on_poll (struct event_pool *event_pool, int fd, int idx_hint,
{
int idx = -1;
- if (event_pool == NULL) {
- gf_log ("event", GF_LOG_ERROR, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("event", event_pool, out);
pthread_mutex_lock (&event_pool->mutex);
{
@@ -339,6 +328,7 @@ event_select_on_poll (struct event_pool *event_pool, int fd, int idx_hint,
unlock:
pthread_mutex_unlock (&event_pool->mutex);
+out:
return idx;
}
@@ -433,11 +423,7 @@ event_dispatch_poll (struct event_pool *event_pool)
int i = 0;
int ret = -1;
-
- if (event_pool == NULL) {
- gf_log ("event", GF_LOG_ERROR, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("event", event_pool, out);
while (1) {
size = event_dispatch_poll_resize (event_pool, ufds, size);
@@ -461,6 +447,7 @@ event_dispatch_poll (struct event_pool *event_pool)
}
}
+out:
return -1;
}
@@ -489,7 +476,7 @@ event_pool_new_epoll (int count)
gf_common_mt_event_pool);
if (!event_pool)
- return NULL;
+ goto out;
event_pool->count = count;
event_pool->reg = GF_CALLOC (event_pool->count,
@@ -497,10 +484,9 @@ event_pool_new_epoll (int count)
gf_common_mt_reg);
if (!event_pool->reg) {
- gf_log ("epoll", GF_LOG_CRITICAL,
- "event registry allocation failed");
GF_FREE (event_pool);
- return NULL;
+ event_pool = NULL;
+ goto out;
}
epfd = epoll_create (count);
@@ -510,7 +496,8 @@ event_pool_new_epoll (int count)
strerror (errno));
GF_FREE (event_pool->reg);
GF_FREE (event_pool);
- return NULL;
+ event_pool = NULL;
+ goto out;
}
event_pool->fd = epfd;
@@ -520,6 +507,7 @@ event_pool_new_epoll (int count)
pthread_mutex_init (&event_pool->mutex, NULL);
pthread_cond_init (&event_pool->cond, NULL);
+out:
return event_pool;
}
@@ -535,10 +523,7 @@ event_register_epoll (struct event_pool *event_pool, int fd,
struct event_data *ev_data = (void *)&epoll_event.data;
- if (event_pool == NULL) {
- gf_log ("event", GF_LOG_ERROR, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("event", event_pool, out);
pthread_mutex_lock (&event_pool->mutex);
{
@@ -617,6 +602,7 @@ event_register_epoll (struct event_pool *event_pool, int fd,
unlock:
pthread_mutex_unlock (&event_pool->mutex);
+out:
return ret;
}
@@ -631,10 +617,7 @@ event_unregister_epoll (struct event_pool *event_pool, int fd, int idx_hint)
struct event_data *ev_data = (void *)&epoll_event.data;
int lastidx = -1;
- if (event_pool == NULL) {
- gf_log ("event", GF_LOG_ERROR, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("event", event_pool, out);
pthread_mutex_lock (&event_pool->mutex);
{
@@ -692,6 +675,7 @@ event_unregister_epoll (struct event_pool *event_pool, int fd, int idx_hint)
unlock:
pthread_mutex_unlock (&event_pool->mutex);
+out:
return ret;
}
@@ -707,10 +691,7 @@ event_select_on_epoll (struct event_pool *event_pool, int fd, int idx_hint,
struct event_data *ev_data = (void *)&epoll_event.data;
- if (event_pool == NULL) {
- gf_log ("event", GF_LOG_ERROR, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("event", event_pool, out);
pthread_mutex_lock (&event_pool->mutex);
{
@@ -771,6 +752,7 @@ event_select_on_epoll (struct event_pool *event_pool, int fd, int idx_hint,
unlock:
pthread_mutex_unlock (&event_pool->mutex);
+out:
return ret;
}
@@ -825,11 +807,7 @@ event_dispatch_epoll (struct event_pool *event_pool)
int i = 0;
int ret = -1;
-
- if (event_pool == NULL) {
- gf_log ("event", GF_LOG_ERROR, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("event", event_pool, out);
while (1) {
pthread_mutex_lock (&event_pool->mutex);
@@ -850,6 +828,8 @@ event_dispatch_epoll (struct event_pool *event_pool)
events = GF_CALLOC (event_pool->evcache_size,
sizeof (struct epoll_event),
gf_common_mt_epoll_event);
+ if (!events)
+ break;
event_pool->evcache = events;
}
@@ -878,7 +858,8 @@ event_dispatch_epoll (struct event_pool *event_pool)
}
}
- return -1;
+out:
+ return ret;
}
@@ -905,7 +886,7 @@ event_pool_new (int count)
event_pool->ops = &event_ops_epoll;
} else {
gf_log ("event", GF_LOG_WARNING,
- "failing back to poll based event handling");
+ "falling back to poll based event handling");
}
#endif
@@ -927,13 +908,11 @@ event_register (struct event_pool *event_pool, int fd,
{
int ret = -1;
- if (event_pool == NULL) {
- gf_log ("event", GF_LOG_ERROR, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("event", event_pool, out);
ret = event_pool->ops->event_register (event_pool, fd, handler, data,
poll_in, poll_out);
+out:
return ret;
}
@@ -943,13 +922,11 @@ event_unregister (struct event_pool *event_pool, int fd, int idx)
{
int ret = -1;
- if (event_pool == NULL) {
- gf_log ("event", GF_LOG_ERROR, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("event", event_pool, out);
ret = event_pool->ops->event_unregister (event_pool, fd, idx);
+out:
return ret;
}
@@ -960,13 +937,11 @@ event_select_on (struct event_pool *event_pool, int fd, int idx_hint,
{
int ret = -1;
- if (event_pool == NULL) {
- gf_log ("event", GF_LOG_ERROR, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("event", event_pool, out);
ret = event_pool->ops->event_select_on (event_pool, fd, idx_hint,
poll_in, poll_out);
+out:
return ret;
}
@@ -976,12 +951,10 @@ event_dispatch (struct event_pool *event_pool)
{
int ret = -1;
- if (event_pool == NULL) {
- gf_log ("event", GF_LOG_ERROR, "invalid argument");
- return -1;
- }
+ GF_VALIDATE_OR_GOTO ("event", event_pool, out);
ret = event_pool->ops->event_dispatch (event_pool);
+out:
return ret;
}
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c
index b793eaae1f2..1e65f2d8206 100644
--- a/libglusterfs/src/fd.c
+++ b/libglusterfs/src/fd.c
@@ -47,9 +47,7 @@ gf_roundup_power_of_two (uint32_t nr)
uint32_t result = 1;
if (nr < 0) {
- gf_log ("server-protocol/fd",
- GF_LOG_ERROR,
- "Negative number passed");
+ gf_log ("fd", GF_LOG_ERROR, "negative number passed");
return -1;
}
@@ -66,8 +64,10 @@ gf_fd_chain_fd_entries (fdentry_t *entries, uint32_t startidx,
{
uint32_t i = 0;
- if (!entries)
+ if (!entries) {
+ gf_log_callingfn ("fd", GF_LOG_WARNING, "!entries");
return -1;
+ }
/* Chain only till the second to last entry because we want to
* ensure that the last entry has GF_FDTABLE_END.
@@ -90,7 +90,7 @@ gf_fd_fdtable_expand (fdtable_t *fdtable, uint32_t nr)
int ret = -1;
if (fdtable == NULL || nr < 0) {
- gf_log ("fd", GF_LOG_ERROR, "invalid argument");
+ gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
ret = EINVAL;
goto out;
}
@@ -157,6 +157,7 @@ __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");
goto out;
}
@@ -199,8 +200,10 @@ gf_fd_fdtable_destroy (fdtable_t *fdtable)
INIT_LIST_HEAD (&list);
- if (!fdtable)
+ if (!fdtable) {
+ gf_log_callingfn ("fd", GF_LOG_WARNING, "!fdtable");
return;
+ }
pthread_mutex_lock (&fdtable->lock);
{
@@ -232,9 +235,8 @@ gf_fd_unused_get (fdtable_t *fdtable, fd_t *fdptr)
int error;
int alloc_attempts = 0;
- if (fdtable == NULL || fdptr == NULL)
- {
- gf_log ("fd", GF_LOG_ERROR, "invalid argument");
+ if (fdtable == NULL || fdptr == NULL) {
+ gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
return EINVAL;
}
@@ -252,17 +254,17 @@ gf_fd_unused_get (fdtable_t *fdtable, fd_t *fdptr)
* seriously wrong with our data structures.
*/
if (alloc_attempts >= 2) {
- gf_log ("server-protocol.c", GF_LOG_ERROR,
- "Multiple attempts to expand fd table"
+ gf_log ("fd", GF_LOG_ERROR,
+ "multiple attempts to expand fd table"
" have failed.");
goto out;
}
error = gf_fd_fdtable_expand (fdtable,
fdtable->max_fds + 1);
if (error) {
- gf_log ("server-protocol.c",
- GF_LOG_ERROR,
- "Cannot expand fdtable:%s", strerror (error));
+ gf_log ("fd", GF_LOG_ERROR,
+ "Cannot expand fdtable: %s",
+ strerror (error));
goto out;
}
++alloc_attempts;
@@ -289,12 +291,12 @@ gf_fd_put (fdtable_t *fdtable, int32_t fd)
fdentry_t *fde = NULL;
if (fdtable == NULL || fd < 0) {
- gf_log ("fd", GF_LOG_ERROR, "invalid argument");
+ gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
return;
}
if (!(fd < fdtable->max_fds)) {
- gf_log ("fd", GF_LOG_ERROR, "invalid argument");
+ gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
return;
}
@@ -330,13 +332,13 @@ gf_fd_fdptr_get (fdtable_t *fdtable, int64_t fd)
fd_t *fdptr = NULL;
if (fdtable == NULL || fd < 0) {
- gf_log ("fd", GF_LOG_ERROR, "invalid argument");
+ gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
errno = EINVAL;
return NULL;
}
if (!(fd < fdtable->max_fds)) {
- gf_log ("fd", GF_LOG_ERROR, "invalid argument");
+ gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
errno = EINVAL;
return NULL;
}
@@ -369,7 +371,7 @@ fd_ref (fd_t *fd)
fd_t *refed_fd = NULL;
if (!fd) {
- gf_log ("fd", GF_LOG_ERROR, "@fd=%p", fd);
+ gf_log_callingfn ("fd", GF_LOG_ERROR, "null fd");
return NULL;
}
@@ -405,12 +407,12 @@ fd_destroy (fd_t *fd)
struct mem_pool *tmp_pool = NULL;
if (fd == NULL){
- gf_log ("xlator", GF_LOG_ERROR, "invalid arugument");
+ gf_log_callingfn ("xlator", GF_LOG_ERROR, "invalid arugument");
goto out;
}
if (fd->inode == NULL){
- gf_log ("xlator", GF_LOG_ERROR, "fd->inode is NULL");
+ gf_log_callingfn ("xlator", GF_LOG_ERROR, "fd->inode is NULL");
goto out;
}
if (!fd->_ctx)
@@ -460,7 +462,7 @@ fd_unref (fd_t *fd)
int32_t refcount = 0;
if (!fd) {
- gf_log ("fd.c", GF_LOG_ERROR, "fd is NULL");
+ gf_log_callingfn ("fd", GF_LOG_ERROR, "fd is NULL");
return;
}
@@ -506,7 +508,7 @@ fd_create (inode_t *inode, pid_t pid)
fd_t *fd = NULL;
if (inode == NULL) {
- gf_log ("fd", GF_LOG_ERROR, "invalid argument");
+ gf_log_callingfn ("fd", GF_LOG_ERROR, "invalid argument");
return NULL;
}
@@ -546,8 +548,10 @@ fd_lookup (inode_t *inode, pid_t pid)
fd_t *fd = NULL;
fd_t *iter_fd = NULL;
- if (!inode)
+ if (!inode) {
+ gf_log_callingfn ("fd", GF_LOG_WARNING, "!inode");
return NULL;
+ }
LOCK (&inode->lock);
{
@@ -612,6 +616,7 @@ __fd_ctx_set (fd_t *fd, xlator_t *xlator, uint64_t value)
}
if (set_idx == -1) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "%p %s", fd, xlator->name);
ret = -1;
goto out;
}
@@ -629,8 +634,10 @@ fd_ctx_set (fd_t *fd, xlator_t *xlator, uint64_t value)
{
int ret = 0;
- if (!fd || !xlator)
+ if (!fd || !xlator) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "%p %p", fd, xlator);
return -1;
+ }
LOCK (&fd->lock);
{
@@ -828,7 +835,6 @@ fd_ctx_dump (fd_t *fd, char *prefix)
sizeof (*fd_ctx),
gf_common_mt_fd_ctx);
if (fd_ctx == NULL) {
- gf_log ("fd", GF_LOG_ERROR, "out of memory");
goto unlock;
}
diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c
index 90e4bc41336..fe0b92dda9e 100644
--- a/libglusterfs/src/globals.c
+++ b/libglusterfs/src/globals.c
@@ -99,8 +99,10 @@ glusterfs_ctx_init ()
{
int ret = 0;
- if (glusterfs_ctx)
+ if (glusterfs_ctx) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "init called again");
goto out;
+ }
glusterfs_ctx = CALLOC (1, sizeof (*glusterfs_ctx));
if (!glusterfs_ctx) {
@@ -144,6 +146,7 @@ glusterfs_this_init ()
ret = pthread_key_create (&this_xlator_key, glusterfs_this_destroy);
if (ret != 0) {
+ gf_log ("", GF_LOG_WARNING, "failed to create the pthread key");
return ret;
}
@@ -170,6 +173,8 @@ __glusterfs_this_location ()
ret = pthread_setspecific (this_xlator_key, this_location);
if (ret != 0) {
+ gf_log ("", GF_LOG_WARNING, "pthread setspecific failed");
+
FREE (this_location);
this_location = NULL;
goto out;
diff --git a/libglusterfs/src/graph-print.c b/libglusterfs/src/graph-print.c
index 65a36b2640b..f9a2f6cb6f4 100644
--- a/libglusterfs/src/graph-print.c
+++ b/libglusterfs/src/graph-print.c
@@ -182,8 +182,6 @@ glusterfs_graph_print_buf (glusterfs_graph_t *graph)
buf = GF_CALLOC (1, len + 1, gf_graph_mt_buf);
if (!buf) {
- gf_log ("graph-print", GF_LOG_ERROR, "Out of memory");
-
return NULL;
}
iov.iov_base = buf;
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
index fb829d48441..5538df04d6d 100644
--- a/libglusterfs/src/graph.c
+++ b/libglusterfs/src/graph.c
@@ -446,18 +446,24 @@ glusterfs_graph_prepare (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
/* XXX: attach to -n volname */
ret = glusterfs_graph_settop (graph, ctx);
- if (ret)
+ if (ret) {
+ gf_log ("graph", GF_LOG_ERROR, "glusterfs graph settop failed");
return -1;
+ }
/* XXX: RO VOLUME */
ret = glusterfs_graph_readonly (graph, ctx);
- if (ret)
+ if (ret) {
+ gf_log ("graph", GF_LOG_ERROR, "glusterfs graph readonly failed");
return -1;
+ }
/* XXX: MAC COMPAT */
ret = glusterfs_graph_mac_compat (graph, ctx);
- if (ret)
+ if (ret) {
+ gf_log ("graph", GF_LOG_ERROR, "glusterfs graph mac compat failed");
return -1;
+ }
/* XXX: this->ctx setting */
for (trav = graph->first; trav; trav = trav->next) {
@@ -484,17 +490,23 @@ glusterfs_graph_activate (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
/* XXX: all xlator options validation */
ret = glusterfs_graph_validate_options (graph);
- if (ret)
+ if (ret) {
+ gf_log ("graph", GF_LOG_ERROR, "validate options failed");
return ret;
+ }
/* XXX: perform init () */
ret = glusterfs_graph_init (graph);
- if (ret)
+ if (ret) {
+ gf_log ("graph", GF_LOG_ERROR, "init failed");
return ret;
+ }
ret = glusterfs_graph_unknown_options (graph);
- if (ret)
+ if (ret) {
+ gf_log ("graph", GF_LOG_ERROR, "unknown options failed");
return ret;
+ }
/* XXX: log full graph (_gf_dump_details) */
@@ -504,14 +516,17 @@ glusterfs_graph_activate (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
/* XXX: attach to master and set active pointer */
if (ctx->master)
ret = xlator_notify (ctx->master, GF_EVENT_GRAPH_NEW, graph);
- if (ret)
+ if (ret) {
+ gf_log ("graph", GF_LOG_ERROR, "graph new notification failed");
return ret;
+ }
/* XXX: perform parent up */
ret = glusterfs_graph_parent_up (graph);
- if (ret)
+ if (ret) {
+ gf_log ("graph", GF_LOG_ERROR, "parent up notification failed");
return ret;
-
+ }
return 0;
}
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
index dac314b977d..a8354464346 100644
--- a/libglusterfs/src/inode.c
+++ b/libglusterfs/src/inode.c
@@ -42,8 +42,8 @@
int i = 1; \
inode_t *inode = NULL; \
list_for_each_entry (inode, head, list) { \
- gf_proc_dump_build_key(key_buf, key_prefix, "%s.%d",list_type, \
- i++); \
+ gf_proc_dump_build_key(key_buf, key_prefix, \
+ "%s.%d",list_type, i++); \
gf_proc_dump_add_section(key_buf); \
inode_dump(inode, key); \
} \
@@ -93,8 +93,10 @@ __dentry_hash (dentry_t *dentry)
inode_table_t *table = NULL;
int hash = 0;
- if (!dentry)
+ if (!dentry) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "dentry not found");
return;
+ }
table = dentry->inode->table;
hash = hash_dentry (dentry->parent, dentry->name,
@@ -108,8 +110,10 @@ __dentry_hash (dentry_t *dentry)
static int
__is_dentry_hashed (dentry_t *dentry)
{
- if (!dentry)
+ if (!dentry) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "dentry not found");
return 0;
+ }
return !list_empty (&dentry->hash);
}
@@ -118,8 +122,10 @@ __is_dentry_hashed (dentry_t *dentry)
static void
__dentry_unhash (dentry_t *dentry)
{
- if (!dentry)
+ if (!dentry) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "dentry not found");
return;
+ }
list_del_init (&dentry->hash);
}
@@ -130,8 +136,10 @@ __dentry_unset (dentry_t *dentry)
{
struct mem_pool *tmp_pool = NULL;
- if (!dentry)
+ if (!dentry) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "dentry not found");
return;
+ }
tmp_pool = dentry->inode->table->dentry_pool;
__dentry_unhash (dentry);
@@ -162,16 +170,22 @@ __foreach_ancestor_dentry (dentry_t *dentry,
dentry_t *each = NULL;
int ret = 0;
- if (!dentry)
+ if (!dentry) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "dentry not found");
return 0;
+ }
ret = per_dentry_fn (dentry, data);
- if (ret)
+ if (ret) {
+ gf_log ("", GF_LOG_WARNING, "per dentry fn returned %d", ret);
goto out;
+ }
parent = dentry->parent;
- if (!parent)
+ if (!parent) {
+ gf_log ("", GF_LOG_WARNING, "parent not found");
goto out;
+ }
list_for_each_entry (each, &parent->dentry_list, inode_list) {
ret = __foreach_ancestor_dentry (each, per_dentry_fn, data);
@@ -225,8 +239,10 @@ __is_dentry_cyclic (dentry_t *dentry)
static void
__inode_unhash (inode_t *inode)
{
- if (!inode)
+ if (!inode) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode not found");
return;
+ }
list_del_init (&inode->hash);
}
@@ -235,8 +251,10 @@ __inode_unhash (inode_t *inode)
static int
__is_inode_hashed (inode_t *inode)
{
- if (!inode)
+ if (!inode) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode not found");
return 0;
+ }
return !list_empty (&inode->hash);
}
@@ -248,8 +266,10 @@ __inode_hash (inode_t *inode)
inode_table_t *table = NULL;
int hash = 0;
- if (!inode)
+ if (!inode) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode not found");
return;
+ }
table = inode->table;
hash = hash_gfid (inode->gfid, 65536);
@@ -265,8 +285,10 @@ __dentry_search_for_inode (inode_t *inode, ino_t par, const char *name)
dentry_t *dentry = NULL;
dentry_t *tmp = NULL;
- if (!inode || !name)
+ if (!inode || !name) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode || name not found");
return NULL;
+ }
list_for_each_entry (tmp, &inode->dentry_list, inode_list) {
if (tmp->parent->ino == par && !strcmp (tmp->name, name)) {
@@ -287,11 +309,15 @@ __inode_destroy (inode_t *inode)
xlator_t *old_THIS = NULL;
struct mem_pool *tmp_pool = NULL;
- if (!inode)
+ if (!inode) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode not found");
return;
+ }
- if (!inode->_ctx)
+ if (!inode->_ctx) {
+ gf_log ("", GF_LOG_WARNING, "_ctx not found");
goto noctx;
+ }
tmp_pool = inode->table->inode_pool;
@@ -333,8 +359,10 @@ __inode_passivate (inode_t *inode)
dentry_t *dentry = NULL;
dentry_t *t = NULL;
- if (!inode)
+ if (!inode) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode not found");
return;
+ }
list_move_tail (&inode->list, &inode->table->lru);
inode->table->lru_size++;
@@ -352,8 +380,10 @@ __inode_retire (inode_t *inode)
dentry_t *dentry = NULL;
dentry_t *t = NULL;
- if (!inode)
+ if (!inode) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode not found");
return;
+ }
list_move_tail (&inode->list, &inode->table->purge);
inode->table->purge_size++;
@@ -455,13 +485,14 @@ __dentry_create (inode_t *inode, inode_t *parent, const char *name)
{
dentry_t *newd = NULL;
- if (!inode || !parent || !name)
+ if (!inode || !parent || !name) {
+ gf_log_callingfn ("", GF_LOG_WARNING,
+ "inode || parent || name not found");
return NULL;
+ }
newd = mem_get0 (parent->table->dentry_pool);
-
if (newd == NULL) {
- gf_log ("inode", GF_LOG_ERROR, "out of memory");
goto out;
}
@@ -470,7 +501,6 @@ __dentry_create (inode_t *inode, inode_t *parent, const char *name)
newd->name = gf_strdup (name);
if (newd->name == NULL) {
- gf_log ("inode", GF_LOG_ERROR, "out of memory");
mem_put (parent->table->dentry_pool, newd);
newd = NULL;
goto out;
@@ -492,12 +522,13 @@ __inode_create (inode_table_t *table)
{
inode_t *newi = NULL;
- if (!table)
+ if (!table) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "table not found");
return NULL;
+ }
newi = mem_get0 (table->inode_pool);
if (!newi) {
- gf_log ("inode", GF_LOG_ERROR, "out of memory");
goto out;
}
@@ -515,7 +546,6 @@ __inode_create (inode_table_t *table)
gf_common_mt_inode_ctx);
if (newi->_ctx == NULL) {
- gf_log ("inode", GF_LOG_ERROR, "out of memory");
LOCK_DESTROY (&newi->lock);
mem_put (table->inode_pool, newi);
newi = NULL;
@@ -536,8 +566,10 @@ inode_new (inode_table_t *table)
{
inode_t *inode = NULL;
- if (!table)
+ if (!table) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode not found");
return NULL;
+ }
pthread_mutex_lock (&table->lock);
{
@@ -610,8 +642,11 @@ inode_grep (inode_table_t *table, inode_t *parent, const char *name)
inode_t *inode = NULL;
dentry_t *dentry = NULL;
- if (!table || !parent || !name)
+ if (!table || !parent || !name) {
+ gf_log_callingfn ("", GF_LOG_WARNING,
+ "table || parent || name not found");
return NULL;
+ }
pthread_mutex_lock (&table->lock);
{
@@ -658,8 +693,10 @@ __inode_find (inode_table_t *table, uuid_t gfid)
inode_t *tmp = NULL;
int hash = 0;
- if (!table)
+ if (!table) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "table not found");
goto out;
+ }
if (__is_root_gfid (gfid) == 0)
return table->root;
@@ -683,8 +720,10 @@ inode_find (inode_table_t *table, uuid_t gfid)
{
inode_t *inode = NULL;
- if (!table)
+ if (!table) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "table not found");
return NULL;
+ }
pthread_mutex_lock (&table->lock);
{
@@ -765,8 +804,10 @@ inode_link (inode_t *inode, inode_t *parent, const char *name,
inode_table_t *table = NULL;
inode_t *linked_inode = NULL;
- if (!inode)
+ if (!inode) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode not found");
return NULL;
+ }
table = inode->table;
@@ -790,8 +831,10 @@ inode_lookup (inode_t *inode)
{
inode_table_t *table = NULL;
- if (!inode)
+ if (!inode) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode not found");
return -1;
+ }
table = inode->table;
@@ -810,8 +853,10 @@ inode_forget (inode_t *inode, uint64_t nlookup)
{
inode_table_t *table = NULL;
- if (!inode)
+ if (!inode) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode not found");
return -1;
+ }
table = inode->table;
@@ -848,8 +893,10 @@ inode_unlink (inode_t *inode, inode_t *parent, const char *name)
{
inode_table_t *table = NULL;
- if (!inode)
+ if (!inode) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode not found");
return;
+ }
table = inode->table;
@@ -868,8 +915,10 @@ inode_rename (inode_table_t *table, inode_t *srcdir, const char *srcname,
inode_t *dstdir, const char *dstname, inode_t *inode,
struct iatt *iatt)
{
- if (!inode)
+ if (!inode) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode not found");
return -1;
+ }
table = inode->table;
@@ -920,8 +969,10 @@ inode_parent (inode_t *inode, ino_t par, const char *name)
inode_table_t *table = NULL;
dentry_t *dentry = NULL;
- if (!inode)
+ if (!inode) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode not found");
return NULL;
+ }
table = inode->table;
@@ -955,8 +1006,10 @@ inode_path (inode_t *inode, const char *name, char **bufp)
int len = 0;
char *buf = NULL;
- if (!inode)
+ if (!inode) {
+ gf_log_callingfn ("", GF_LOG_WARNING, "inode not found");
return -1;
+ }
table = inode->table;
@@ -977,7 +1030,7 @@ inode_path (inode_t *inode, const char *name, char **bufp)
if ((inode->ino != 1) &&
(i == 0)) {
- gf_log (table->name, GF_LOG_DEBUG,
+ gf_log (table->name, GF_LOG_WARNING,
"no dentry for non-root inode %"PRId64,
inode->ino);
ret = -ENOENT;
@@ -1012,8 +1065,6 @@ inode_path (inode_t *inode, const char *name, char **bufp)
}
*bufp = buf;
} else {
- gf_log (table->name, GF_LOG_ERROR,
- "out of memory");
ret = -ENOMEM;
}
}
@@ -1030,8 +1081,6 @@ unlock:
strcpy (buf, "/");
*bufp = buf;
} else {
- gf_log (table->name, GF_LOG_ERROR,
- "out of memory");
ret = -ENOMEM;
}
}
@@ -1206,7 +1255,6 @@ inode_from_path (inode_table_t *itable, const char *path)
/* top-down approach */
pathname = gf_strdup (path);
if (pathname == NULL) {
- gf_log ("inode", GF_LOG_ERROR, "out of memory");
goto out;
}
@@ -1453,7 +1501,7 @@ inode_dump (inode_t *inode, char *prefix)
if (ret != 0) {
gf_log ("", GF_LOG_WARNING, "Unable to dump inode"
- " errno: %d", errno);
+ " errno: %s", strerror (errno));
return;
}
@@ -1473,7 +1521,6 @@ inode_dump (inode_t *inode, char *prefix)
sizeof (*inode_ctx),
gf_common_mt_inode_ctx);
if (inode_ctx == NULL) {
- gf_log ("", GF_LOG_ERROR, "out of memory");
goto unlock;
}
@@ -1490,7 +1537,6 @@ inode_dump (inode_t *inode, char *prefix)
fd_wrapper = GF_CALLOC (1, sizeof (*fd_wrapper),
gf_common_mt_char);
if (fd_wrapper == NULL) {
- gf_log ("", GF_LOG_ERROR, "out of memory");
goto unlock;
}
@@ -1547,7 +1593,7 @@ inode_table_dump (inode_table_t *itable, char *prefix)
if (ret != 0) {
gf_log("", GF_LOG_WARNING, "Unable to dump inode table"
- " errno: %d", errno);
+ " errno: %s", strerror (errno));
return;
}
diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c
index a717792ce98..42b7f426789 100644
--- a/libglusterfs/src/iobuf.c
+++ b/libglusterfs/src/iobuf.c
@@ -77,8 +77,10 @@ __iobuf_arena_destroy_iobufs (struct iobuf_arena *iobuf_arena)
page_size = iobuf_arena->iobuf_pool->page_size;
iobuf_cnt = arena_size / page_size;
- if (!iobuf_arena->iobufs)
+ if (!iobuf_arena->iobufs) {
+ gf_log ("", GF_LOG_DEBUG, "iobufs not found");
return;
+ }
iobuf = iobuf_arena->iobufs;
for (i = 0; i < iobuf_cnt; i++) {
@@ -97,9 +99,10 @@ __iobuf_arena_destroy (struct iobuf_arena *iobuf_arena)
{
struct iobuf_pool *iobuf_pool = NULL;
- if (!iobuf_arena)
+ if (!iobuf_arena) {
+ gf_log ("", GF_LOG_DEBUG, "iobufs not found");
return;
-
+ }
iobuf_pool = iobuf_arena->iobuf_pool;
__iobuf_arena_destroy_iobufs (iobuf_arena);
@@ -131,12 +134,16 @@ __iobuf_arena_alloc (struct iobuf_pool *iobuf_pool)
arena_size = iobuf_pool->arena_size;
iobuf_arena->mem_base = mmap (NULL, arena_size, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
- if (iobuf_arena->mem_base == MAP_FAILED)
+ if (iobuf_arena->mem_base == MAP_FAILED) {
+ gf_log ("", GF_LOG_WARNING, "maping failed");
goto err;
+ }
__iobuf_arena_init_iobufs (iobuf_arena);
- if (!iobuf_arena->iobufs)
+ if (!iobuf_arena->iobufs) {
+ gf_log ("", GF_LOG_DEBUG, "init failed");
goto err;
+ }
iobuf_pool->arena_cnt++;
@@ -174,8 +181,10 @@ __iobuf_pool_add_arena (struct iobuf_pool *iobuf_pool)
if (!iobuf_arena)
iobuf_arena = __iobuf_arena_alloc (iobuf_pool);
- if (!iobuf_arena)
+ if (!iobuf_arena) {
+ gf_log ("", GF_LOG_WARNING, "arena not found");
return NULL;
+ }
list_add_tail (&iobuf_arena->list, &iobuf_pool->arenas.list);
@@ -204,8 +213,10 @@ iobuf_pool_destroy (struct iobuf_pool *iobuf_pool)
struct iobuf_arena *iobuf_arena = NULL;
struct iobuf_arena *tmp = NULL;
- if (!iobuf_pool)
+ if (!iobuf_pool) {
+ gf_log ("", GF_LOG_WARNING, "iobuf pool not found");
return;
+ }
list_for_each_entry_safe (iobuf_arena, tmp, &iobuf_pool->arenas.list,
list) {
@@ -223,8 +234,12 @@ iobuf_pool_new (size_t arena_size, size_t page_size)
{
struct iobuf_pool *iobuf_pool = NULL;
- if (arena_size < page_size)
+ if (arena_size < page_size) {
+ gf_log ("", GF_LOG_WARNING,
+ "arena size (%zu) is less than page size(%zu)",
+ arena_size, page_size);
return NULL;
+ }
iobuf_pool = GF_CALLOC (sizeof (*iobuf_pool), 1,
gf_common_mt_iobuf_pool);
@@ -357,12 +372,16 @@ iobuf_get (struct iobuf_pool *iobuf_pool)
{
/* most eligible arena for picking an iobuf */
iobuf_arena = __iobuf_select_arena (iobuf_pool);
- if (!iobuf_arena)
+ if (!iobuf_arena) {
+ gf_log ("", GF_LOG_WARNING, "arena not found");
goto unlock;
+ }
iobuf = __iobuf_get (iobuf_arena);
- if (!iobuf)
+ if (!iobuf) {
+ gf_log ("", GF_LOG_WARNING, "iobuf not found");
goto unlock;
+ }
__iobuf_ref (iobuf);
}
@@ -404,16 +423,22 @@ iobuf_put (struct iobuf *iobuf)
struct iobuf_arena *iobuf_arena = NULL;
struct iobuf_pool *iobuf_pool = NULL;
- if (!iobuf)
+ if (!iobuf) {
+ gf_log ("", GF_LOG_WARNING, "iobuf not found");
return;
+ }
iobuf_arena = iobuf->iobuf_arena;
- if (!iobuf_arena)
+ if (!iobuf_arena) {
+ gf_log ("", GF_LOG_WARNING, "arena not found");
return;
+ }
iobuf_pool = iobuf_arena->iobuf_pool;
- if (!iobuf_pool)
+ if (!iobuf_pool) {
+ gf_log ("", GF_LOG_WARNING, "iobuf pool not found");
return;
+ }
pthread_mutex_lock (&iobuf_pool->mutex);
{
@@ -430,8 +455,10 @@ iobuf_unref (struct iobuf *iobuf)
{
int ref = 0;
- if (!iobuf)
+ if (!iobuf) {
+ gf_log ("", GF_LOG_WARNING, "iobuf not found");
return;
+ }
LOCK (&iobuf->lock);
{
@@ -448,8 +475,10 @@ iobuf_unref (struct iobuf *iobuf)
struct iobuf *
iobuf_ref (struct iobuf *iobuf)
{
- if (!iobuf)
+ if (!iobuf) {
+ gf_log ("", GF_LOG_WARNING, "iobuf not found");
return NULL;
+ }
LOCK (&iobuf->lock);
{
@@ -482,8 +511,10 @@ iobref_new ()
struct iobref *
iobref_ref (struct iobref *iobref)
{
- if (!iobref)
+ if (!iobref) {
+ gf_log ("", GF_LOG_WARNING, "iobref not found");
return NULL;
+ }
LOCK (&iobref->lock);
{
@@ -521,8 +552,10 @@ iobref_unref (struct iobref *iobref)
{
int ref = 0;
- if (!iobref)
+ if (!iobref) {
+ gf_log ("", GF_LOG_WARNING, "iobref not found");
return;
+ }
LOCK (&iobref->lock);
{
@@ -558,11 +591,10 @@ iobref_add (struct iobref *iobref, struct iobuf *iobuf)
{
int ret = 0;
- if (!iobref)
- return -EINVAL;
-
- if (!iobuf)
+ if (!iobref || !iobuf) {
+ gf_log ("", GF_LOG_WARNING, "(iobref || iobuf) not found");
return -EINVAL;
+ }
LOCK (&iobref->lock);
{
@@ -606,14 +638,20 @@ iobuf_size (struct iobuf *iobuf)
{
size_t size = 0;
- if (!iobuf)
+ if (!iobuf) {
+ gf_log ("", GF_LOG_WARNING, "iobuf not found");
goto out;
+ }
- if (!iobuf->iobuf_arena)
+ if (!iobuf->iobuf_arena) {
+ gf_log ("", GF_LOG_WARNING, "arena not found");
goto out;
+ }
- if (!iobuf->iobuf_arena->iobuf_pool)
+ if (!iobuf->iobuf_arena->iobuf_pool) {
+ gf_log ("", GF_LOG_WARNING, "pool not found");
goto out;
+ }
size = iobuf->iobuf_arena->iobuf_pool->page_size;
out:
@@ -627,8 +665,10 @@ iobref_size (struct iobref *iobref)
size_t size = 0;
int i = 0;
- if (!iobref)
+ if (!iobref) {
+ gf_log ("", GF_LOG_WARNING, "iobref not found");
goto out;
+ }
LOCK (&iobref->lock);
{
@@ -649,15 +689,17 @@ iobuf_info_dump (struct iobuf *iobuf, const char *key_prefix)
struct iobuf my_iobuf;
int ret = 0;
- if (!iobuf)
+ if (!iobuf) {
+ gf_log ("", GF_LOG_WARNING, "iobuf not found");
return;
+ }
memset(&my_iobuf, 0, sizeof(my_iobuf));
ret = TRY_LOCK(&iobuf->lock);
if (ret) {
gf_log("", GF_LOG_WARNING, "Unable to dump iobuf"
- " errno: %d", errno);
+ " errno: %s", strerror (errno));
return;
}
memcpy(&my_iobuf, iobuf, sizeof(my_iobuf));
@@ -712,7 +754,7 @@ iobuf_stats_dump (struct iobuf_pool *iobuf_pool)
if (ret) {
gf_log("", GF_LOG_WARNING, "Unable to dump iobuf pool"
- " errno: %d", errno);
+ " errno: %s", strerror (errno));
return;
}
gf_proc_dump_add_section("iobuf.global");
diff --git a/libglusterfs/src/rbthash.c b/libglusterfs/src/rbthash.c
index dc2f7395259..2f41d9825b4 100644
--- a/libglusterfs/src/rbthash.c
+++ b/libglusterfs/src/rbthash.c
@@ -124,7 +124,6 @@ rbthash_table_init (int buckets, rbt_hasher_t hfunc,
newtab->buckets = GF_CALLOC (buckets, sizeof (struct rbthash_bucket),
gf_common_mt_rbthash_bucket);
if (!newtab->buckets) {
- gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to allocate memory");
goto free_newtab;
}
@@ -189,7 +188,6 @@ rbthash_init_entry (rbthash_table_t *tbl, void *data, void *key, int keylen)
entry->data = data;
entry->key = GF_CALLOC (keylen, sizeof (char), gf_common_mt_char);
if (!entry->key) {
- gf_log (GF_RBTHASH, GF_LOG_ERROR, "Memory allocation failed");
goto free_entry;
}
diff --git a/libglusterfs/src/stack.c b/libglusterfs/src/stack.c
index 3f8cf08c9b7..ebaf814ad05 100644
--- a/libglusterfs/src/stack.c
+++ b/libglusterfs/src/stack.c
@@ -59,7 +59,7 @@ gf_proc_dump_call_frame (call_frame_t *call_frame, const char *key_buf,...)
ret = TRY_LOCK(&call_frame->lock);
if (ret) {
gf_log("", GF_LOG_WARNING, "Unable to dump call frame"
- " errno: %d", errno);
+ " errno: %s", strerror (errno));
return;
}
diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c
index 4a49353ef40..58d81625749 100644
--- a/libglusterfs/src/statedump.c
+++ b/libglusterfs/src/statedump.c
@@ -28,6 +28,11 @@
#include <malloc.h>
#endif /* MALLOC_H */
+/* We don't want gf_log in this function because it may cause
+ 'deadlock' with statedump */
+#ifdef gf_log
+# undef gf_log
+#endif
#define GF_PROC_DUMP_IS_OPTION_ENABLED(opt) \
(dump_options.dump_##opt == _gf_true)
diff --git a/libglusterfs/src/timer.c b/libglusterfs/src/timer.c
index 20d45bbb377..d8766d38ba3 100644
--- a/libglusterfs/src/timer.c
+++ b/libglusterfs/src/timer.c
@@ -42,20 +42,19 @@ gf_timer_call_after (glusterfs_ctx_t *ctx,
if (ctx == NULL)
{
- gf_log ("timer", GF_LOG_ERROR, "invalid argument");
+ gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument");
return NULL;
}
reg = gf_timer_registry_init (ctx);
if (!reg) {
- gf_log ("timer", GF_LOG_ERROR, "!reg");
+ gf_log_callingfn ("timer", GF_LOG_ERROR, "!reg");
return NULL;
}
event = GF_CALLOC (1, sizeof (*event), gf_common_mt_gf_timer_t);
if (!event) {
- gf_log ("timer", GF_LOG_CRITICAL, "Not enough memory");
return NULL;
}
gettimeofday (&event->at, NULL);
@@ -89,7 +88,7 @@ gf_timer_call_stale (gf_timer_registry_t *reg,
{
if (reg == NULL || event == NULL)
{
- gf_log ("timer", GF_LOG_ERROR, "invalid argument");
+ gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument");
return 0;
}
@@ -111,7 +110,7 @@ gf_timer_call_cancel (glusterfs_ctx_t *ctx,
if (ctx == NULL || event == NULL)
{
- gf_log ("timer", GF_LOG_ERROR, "invalid argument");
+ gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument");
return 0;
}
@@ -140,7 +139,7 @@ gf_timer_proc (void *ctx)
if (ctx == NULL)
{
- gf_log ("timer", GF_LOG_ERROR, "invalid argument");
+ gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument");
return NULL;
}
@@ -203,7 +202,7 @@ gf_timer_registry_t *
gf_timer_registry_init (glusterfs_ctx_t *ctx)
{
if (ctx == NULL) {
- gf_log ("timer", GF_LOG_ERROR, "invalid argument");
+ gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument");
return NULL;
}
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index 01a902d4c9a..fd10eb0975e 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -45,7 +45,7 @@ static void
fill_defaults (xlator_t *xl)
{
if (xl == NULL) {
- gf_log ("xlator", GF_LOG_DEBUG, "invalid argument");
+ gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
return;
}
@@ -556,8 +556,8 @@ validate_xlator_volume_options (xlator_t *xl, volume_option_t *opt)
int32_t
xlator_set_type_virtual (xlator_t *xl, const char *type)
{
- if (xl == NULL || type == NULL) {
- gf_log ("xlator", GF_LOG_DEBUG, "invalid argument");
+ if ((xl == NULL) || (type == NULL)) {
+ gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
return -1;
}
@@ -588,35 +588,35 @@ xlator_dynload (xlator_t *xl)
handle = dlopen (name, RTLD_NOW|RTLD_GLOBAL);
if (!handle) {
- gf_log ("xlator", GF_LOG_DEBUG, "%s", dlerror ());
+ gf_log ("xlator", GF_LOG_WARNING, "%s", dlerror ());
GF_FREE (name);
return -1;
}
xl->dlhandle = handle;
if (!(xl->fops = dlsym (handle, "fops"))) {
- gf_log ("xlator", GF_LOG_DEBUG, "dlsym(fops) on %s",
+ gf_log ("xlator", GF_LOG_WARNING, "dlsym(fops) on %s",
dlerror ());
GF_FREE (name);
return -1;
}
if (!(xl->cbks = dlsym (handle, "cbks"))) {
- gf_log ("xlator", GF_LOG_DEBUG, "dlsym(cbks) on %s",
+ gf_log ("xlator", GF_LOG_WARNING, "dlsym(cbks) on %s",
dlerror ());
GF_FREE (name);
return -1;
}
if (!(xl->init = dlsym (handle, "init"))) {
- gf_log ("xlator", GF_LOG_DEBUG, "dlsym(init) on %s",
+ gf_log ("xlator", GF_LOG_WARNING, "dlsym(init) on %s",
dlerror ());
GF_FREE (name);
return -1;
}
if (!(xl->fini = dlsym (handle, "fini"))) {
- gf_log ("xlator", GF_LOG_DEBUG, "dlsym(fini) on %s",
+ gf_log ("xlator", GF_LOG_WARNING, "dlsym(fini) on %s",
dlerror ());
GF_FREE (name);
return -1;
@@ -696,8 +696,8 @@ xlator_foreach (xlator_t *this,
{
xlator_t *first = NULL;
- if (this == NULL || fn == NULL || data == NULL) {
- gf_log ("xlator", GF_LOG_DEBUG, "invalid argument");
+ if ((this == NULL) || (fn == NULL) || (data == NULL)) {
+ gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
return;
}
@@ -718,8 +718,8 @@ xlator_search_by_name (xlator_t *any, const char *name)
{
xlator_t *search = NULL;
- if (any == NULL || name == NULL) {
- gf_log ("xlator", GF_LOG_DEBUG, "invalid argument");
+ if ((any == NULL) || (name == NULL)) {
+ gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
return NULL;
}
@@ -761,7 +761,7 @@ xlator_init (xlator_t *xl)
int32_t ret = 0;
if (xl == NULL) {
- gf_log ("xlator", GF_LOG_DEBUG, "invalid argument");
+ gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
return 0;
}
@@ -771,7 +771,7 @@ xlator_init (xlator_t *xl)
xl->mem_acct_init (xl);
if (!xl->init) {
- gf_log (xl->name, GF_LOG_DEBUG, "No init() found");
+ gf_log (xl->name, GF_LOG_WARNING, "No init() found");
goto out;
}
@@ -799,7 +799,7 @@ xlator_fini_rec (xlator_t *xl)
xlator_list_t *trav = NULL;
if (xl == NULL) {
- gf_log ("xlator", GF_LOG_DEBUG, "invalid argument");
+ gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
return;
}
@@ -832,8 +832,8 @@ xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl)
xlator_list_t *trav2 = NULL;
int32_t ret = 0;
- if (old_xl == NULL || new_xl == NULL) {
- gf_log ("xlator", GF_LOG_DEBUG, "invalid argument");
+ if ((old_xl == NULL) || (new_xl == NULL)) {
+ gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
return -1;
}
@@ -842,7 +842,6 @@ xlator_reconfigure_rec (xlator_t *old_xl, xlator_t *new_xl)
while (trav1 && trav2) {
ret = xlator_reconfigure_rec (trav1->xlator, trav2->xlator);
-
if (ret)
goto out;
@@ -870,15 +869,17 @@ xlator_validate_rec (xlator_t *xlator, char **op_errstr)
xlator_list_t *trav = NULL;
if (xlator == NULL ) {
- gf_log ("xlator", GF_LOG_DEBUG, "invalid argument");
+ gf_log_callingfn ("xlator", GF_LOG_WARNING, "invalid argument");
return -1;
}
trav = xlator->children;
while (trav) {
- if (xlator_validate_rec (trav->xlator, op_errstr) )
+ if (xlator_validate_rec (trav->xlator, op_errstr)) {
+ gf_log ("xlator", GF_LOG_WARNING, "validate_rec failed");
return -1;
+ }
trav = trav->next;
}
@@ -889,7 +890,7 @@ xlator_validate_rec (xlator_t *xlator, char **op_errstr)
if (xlator->validate_options) {
if (xlator->validate_options (xlator, xlator->options,
op_errstr)) {
- gf_log ("", GF_LOG_DEBUG, "%s", *op_errstr);
+ gf_log ("", GF_LOG_INFO, "%s", *op_errstr);
return -1;
}
gf_log (xlator->name, GF_LOG_DEBUG, "Validated option");
@@ -947,10 +948,9 @@ xlator_mem_acct_init (xlator_t *xl, int num_types)
xl->mem_acct.num_types = num_types;
- xl->mem_acct.rec = calloc(num_types, sizeof(struct mem_acct_rec));
+ xl->mem_acct.rec = CALLOC(num_types, sizeof(struct mem_acct_rec));
if (!xl->mem_acct.rec) {
- gf_log("xlator", GF_LOG_ERROR, "Out of Memory");
return -1;
}
@@ -961,9 +961,6 @@ xlator_mem_acct_init (xlator_t *xl, int num_types)
}
}
- gf_log(xl->name, GF_LOG_DEBUG, "Allocated mem_acct_rec for %d types",
- num_types);
-
return 0;
}