summaryrefslogtreecommitdiffstats
path: root/libglusterfs
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
parent307528ef9a33a4d294b3ea49bbf5f0b16b27aa0f (diff)
pruning buffer margin - do not destroy if no other non-filled arenas are in the pool
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/iobuf.c27
-rw-r--r--libglusterfs/src/iobuf.h2
2 files changed, 26 insertions, 3 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)
diff --git a/libglusterfs/src/iobuf.h b/libglusterfs/src/iobuf.h
index 4c34770849e..71b115c5d40 100644
--- a/libglusterfs/src/iobuf.h
+++ b/libglusterfs/src/iobuf.h
@@ -86,7 +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 */
+ struct iobuf_arena purge; /* arenas which can be purged */
};