diff options
| author | Yaniv Kaul <ykaul@redhat.com> | 2018-11-04 13:47:25 +0200 | 
|---|---|---|
| committer | Amar Tumballi <amarts@redhat.com> | 2018-11-06 04:18:50 +0000 | 
| commit | ed83a4ee7b73e6b04694d1ac11ed25d2983ac943 (patch) | |
| tree | 9ca93fb76aa6938eb56131a0bd70e4455130e4be /libglusterfs/src/iobuf.c | |
| parent | ba52abc6931baecb73d690b289f8feb32205424f (diff) | |
libglusterfs/src/iobuf.c: take the pool lock once in new pool
When creating a new pool, take the pool lock once and create
all arenas, instead of taking and releasing for each arena.
Compile-tested only!
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Change-Id: I7daa39de960e47e66a32ecab724cf3a61ccdc01b
Diffstat (limited to 'libglusterfs/src/iobuf.c')
| -rw-r--r-- | libglusterfs/src/iobuf.c | 33 | 
1 files changed, 9 insertions, 24 deletions
diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c index 2f1a8fe6f01..604dc7072b2 100644 --- a/libglusterfs/src/iobuf.c +++ b/libglusterfs/src/iobuf.c @@ -261,24 +261,6 @@ __iobuf_pool_add_arena(struct iobuf_pool *iobuf_pool, const size_t page_size,      return iobuf_arena;  } -struct iobuf_arena * -iobuf_pool_add_arena(struct iobuf_pool *iobuf_pool, size_t page_size, -                     int32_t num_pages) -{ -    struct iobuf_arena *iobuf_arena = NULL; - -    GF_VALIDATE_OR_GOTO("iobuf", iobuf_pool, out); - -    pthread_mutex_lock(&iobuf_pool->mutex); -    { -        iobuf_arena = __iobuf_pool_add_arena(iobuf_pool, page_size, num_pages); -    } -    pthread_mutex_unlock(&iobuf_pool->mutex); - -out: -    return iobuf_arena; -} -  /* This function destroys all the iobufs and the iobuf_pool */  void  iobuf_pool_destroy(struct iobuf_pool *iobuf_pool) @@ -391,15 +373,18 @@ iobuf_pool_new(void)          iobuf_pool->mr_list[i] = NULL;      } -    arena_size = 0; -    for (i = 0; i < IOBUF_ARENA_MAX_INDEX; i++) { -        page_size = gf_iobuf_init_config[i].pagesize; -        num_pages = gf_iobuf_init_config[i].num_pages; +    pthread_mutex_lock(&iobuf_pool->mutex); +    { +        for (i = 0; i < IOBUF_ARENA_MAX_INDEX; i++) { +            page_size = gf_iobuf_init_config[i].pagesize; +            num_pages = gf_iobuf_init_config[i].num_pages; -        iobuf_pool_add_arena(iobuf_pool, page_size, num_pages); +            __iobuf_pool_add_arena(iobuf_pool, page_size, num_pages); -        arena_size += page_size * num_pages; +            arena_size += page_size * num_pages; +        }      } +    pthread_mutex_unlock(&iobuf_pool->mutex);      /* Need an arena to handle all the bigger iobuf requests */      iobuf_create_stdalloc_arena(iobuf_pool);  | 
