summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/iobuf.c
diff options
context:
space:
mode:
authorAnand V. Avati <avati@amp.gluster.com>2009-04-18 02:49:03 +0530
committerAnand V. Avati <avati@amp.gluster.com>2009-04-18 02:49:03 +0530
commit9a4a2e2286cb372ca462f6f25f78de686ea3e4ce (patch)
treeb97d1468ae17f79b1425632396e667a47d3a6e5a /libglusterfs/src/iobuf.c
parent307528ef9a33a4d294b3ea49bbf5f0b16b27aa0f (diff)
pruning buffer margin - do not destroy if no other non-filled arenas are in the pool
Diffstat (limited to 'libglusterfs/src/iobuf.c')
-rw-r--r--libglusterfs/src/iobuf.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c
index 84e3b5efec6..7cbc1702e7e 100644
--- a/libglusterfs/src/iobuf.c
+++ b/libglusterfs/src/iobuf.c
@@ -144,11 +144,30 @@ err:
struct iobuf_arena *
+__iobuf_arena_unprune (struct iobuf_pool *iobuf_pool)
+{
+ struct iobuf_arena *iobuf_arena = NULL;
+ struct iobuf_arena *tmp = NULL;
+
+ list_for_each_entry (tmp, &iobuf_pool->purge.list, list) {
+ list_del_init (&tmp->list);
+ iobuf_arena = tmp;
+ break;
+ }
+
+ return iobuf_arena;
+}
+
+
+struct iobuf_arena *
__iobuf_pool_add_arena (struct iobuf_pool *iobuf_pool)
{
struct iobuf_arena *iobuf_arena = NULL;
- iobuf_arena = __iobuf_arena_alloc (iobuf_pool);
+ iobuf_arena = __iobuf_arena_unprune (iobuf_pool);
+
+ if (!iobuf_arena)
+ iobuf_arena = __iobuf_arena_alloc (iobuf_pool);
if (!iobuf_arena)
return NULL;
@@ -221,13 +240,17 @@ iobuf_pool_new (size_t arena_size, size_t page_size)
}
-
void
__iobuf_pool_prune (struct iobuf_pool *iobuf_pool)
{
struct iobuf_arena *iobuf_arena = NULL;
struct iobuf_arena *tmp = NULL;
+ if (list_empty (&iobuf_pool->arenas.list))
+ /* buffering - preserve this one arena (if at all)
+ for __iobuf_arena_unprune */
+ return;
+
list_for_each_entry_safe (iobuf_arena, tmp, &iobuf_pool->purge.list,
list) {
if (iobuf_arena->active_cnt)