diff options
author | Anand V. Avati <avati@gluster.com> | 2009-04-13 14:03:28 +0530 |
---|---|---|
committer | Anand V. Avati <avati@amp.gluster.com> | 2009-04-13 14:55:25 +0530 |
commit | dc9cdbdc1c03c231ba405e540fac7d6483159bb2 (patch) | |
tree | 212b3d03d84748b49a3915d6b54340a4589b5966 /libglusterfs | |
parent | b9a210a419ff28f2d75b10a680520fd6cc37ac5a (diff) |
add purge list support to make iobuf_pool_purge() in expensive, and actually call it in iobuf_put :-)
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/iobuf.c | 10 | ||||
-rw-r--r-- | libglusterfs/src/iobuf.h | 1 |
2 files changed, 10 insertions, 1 deletions
diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c index a233387fc..cc2f972f5 100644 --- a/libglusterfs/src/iobuf.c +++ b/libglusterfs/src/iobuf.c @@ -200,6 +200,7 @@ iobuf_pool_new (size_t arena_size, size_t page_size) pthread_mutex_init (&iobuf_pool->mutex, NULL); INIT_LIST_HEAD (&iobuf_pool->arenas.list); INIT_LIST_HEAD (&iobuf_pool->filled.list); + INIT_LIST_HEAD (&iobuf_pool->purge.list); iobuf_pool->arena_size = arena_size; iobuf_pool->page_size = page_size; @@ -217,7 +218,7 @@ __iobuf_pool_prune (struct iobuf_pool *iobuf_pool) struct iobuf_arena *iobuf_arena = NULL; struct iobuf_arena *tmp = NULL; - list_for_each_entry_safe (iobuf_arena, tmp, &iobuf_pool->arenas.list, + list_for_each_entry_safe (iobuf_arena, tmp, &iobuf_pool->purge.list, list) { if (iobuf_arena->active_cnt) continue; @@ -351,6 +352,11 @@ __iobuf_put (struct iobuf *iobuf, struct iobuf_arena *iobuf_arena) list_add (&iobuf->list, &iobuf_arena->passive.list); iobuf_arena->passive_cnt++; + + if (iobuf_arena->active_cnt == 0) { + list_del (&iobuf_arena->list); + list_add_tail (&iobuf_arena->list, &iobuf_pool->purge.list); + } } @@ -376,6 +382,8 @@ iobuf_put (struct iobuf *iobuf) __iobuf_put (iobuf, iobuf_arena); } pthread_mutex_unlock (&iobuf_pool->mutex); + + iobuf_pool_prune (iobuf_pool); } diff --git a/libglusterfs/src/iobuf.h b/libglusterfs/src/iobuf.h index 08831bbe9..2ad640bbc 100644 --- a/libglusterfs/src/iobuf.h +++ b/libglusterfs/src/iobuf.h @@ -86,6 +86,7 @@ struct iobuf_pool { struct iobuf_arena arenas; /* head node arena (unused by itself) */ struct iobuf_arena filled; /* arenas without free iobufs */ + struct iobuf_arena purge; /* arenas to be purged right away */ }; |