summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/iobuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/iobuf.c')
-rw-r--r--libglusterfs/src/iobuf.c98
1 files changed, 70 insertions, 28 deletions
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");