summaryrefslogtreecommitdiff
path: root/smalloc.c
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2008-04-16 19:43:17 +0200
committerJens Axboe <jens.axboe@oracle.com>2008-04-16 19:43:17 +0200
commitadf57099338307b3a4a129475a12aad31e35ade3 (patch)
treea9be80cb94807eb0c7fc522378417243ce8ca4db /smalloc.c
parent5036fc1ecd69989198d576d87624964a529610c7 (diff)
downloadfio-adf57099338307b3a4a129475a12aad31e35ade3.tar.gz
smalloc: when adding a new pool, make it big enough to hold the failing alloc
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'smalloc.c')
-rw-r--r--smalloc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/smalloc.c b/smalloc.c
index 5baf5a43..28f82633 100644
--- a/smalloc.c
+++ b/smalloc.c
@@ -220,7 +220,7 @@ fail:
#endif
}
-static int add_pool(struct pool *pool)
+static int add_pool(struct pool *pool, unsigned int alloc_size)
{
struct mem_hdr *hdr;
void *ptr;
@@ -231,7 +231,11 @@ static int add_pool(struct pool *pool)
if (fd < 0)
goto out_close;
- pool->size = smalloc_pool_size;
+ if (alloc_size > smalloc_pool_size)
+ pool->size = alloc_size;
+ else
+ pool->size = smalloc_pool_size;
+
if (ftruncate(fd, pool->size) < 0)
goto out_unlink;
@@ -275,7 +279,7 @@ void sinit(void)
#ifdef MP_SAFE
lock = fio_mutex_rw_init();
#endif
- ret = add_pool(&mp[0]);
+ ret = add_pool(&mp[0], INITIAL_SIZE);
assert(!ret);
}
@@ -458,7 +462,7 @@ void *smalloc(unsigned int size)
else {
i = nr_pools;
global_read_unlock();
- if (add_pool(&mp[nr_pools]))
+ if (add_pool(&mp[nr_pools], size))
goto out;
global_read_lock();
}