diff options
author | Anand V. Avati <avati@gluster.com> | 2009-04-13 14:03:13 +0530 |
---|---|---|
committer | Anand V. Avati <avati@amp.gluster.com> | 2009-04-13 14:55:19 +0530 |
commit | 688db6452befde5d7cd2b35f86b770b4c19c53fc (patch) | |
tree | 03a8637bd290f98857b7bbaa3b548c4caa2a0c40 /libglusterfs/src/iobuf.c | |
parent | 4f0d487c96b84123289d3c48fd84188efe136293 (diff) |
add @filled list in iobuf_pool to keep away filled list from getting searched in iobuf_select_arena
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfs/src/iobuf.c')
-rw-r--r-- | libglusterfs/src/iobuf.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c index b54f31243..7da029bd1 100644 --- a/libglusterfs/src/iobuf.c +++ b/libglusterfs/src/iobuf.c @@ -199,6 +199,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); iobuf_pool->arena_size = arena_size; iobuf_pool->page_size = page_size; @@ -281,7 +282,10 @@ __iobuf_unref (struct iobuf *iobuf) struct iobuf * __iobuf_get (struct iobuf_arena *iobuf_arena) { - struct iobuf *iobuf = NULL; + struct iobuf *iobuf = NULL; + struct iobuf_pool *iobuf_pool = NULL; + + iobuf_pool = iobuf_arena->iobuf_pool; list_for_each_entry (iobuf, &iobuf_arena->passive.list, list) break; @@ -292,6 +296,11 @@ __iobuf_get (struct iobuf_arena *iobuf_arena) list_add (&iobuf->list, &iobuf_arena->active.list); iobuf_arena->active_cnt++; + if (iobuf_arena->passive_cnt == 0) { + list_del (&iobuf_arena->list); + list_add (&iobuf_arena->list, &iobuf_pool->filled.list); + } + return iobuf; } @@ -325,6 +334,15 @@ unlock: void __iobuf_put (struct iobuf *iobuf, struct iobuf_arena *iobuf_arena) { + struct iobuf_pool *iobuf_pool = NULL; + + iobuf_pool = iobuf_arena->iobuf_pool; + + if (iobuf_arena->passive_cnt == 0) { + list_del (&iobuf_arena->list); + list_add_tail (&iobuf_arena->list, &iobuf_pool->arenas.list); + } + list_del_init (&iobuf->list); iobuf_arena->active_cnt--; |