Commit 93d2341c authored by Matthew Dobson's avatar Matthew Dobson Committed by Linus Torvalds

[PATCH] mempool: use mempool_create_slab_pool()

Modify well over a dozen mempool users to call mempool_create_slab_pool()
rather than calling mempool_create() with extra arguments, saving about 30
lines of code and increasing readability.
Signed-off-by: default avatarMatthew Dobson <colpatch@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent fec433aa
...@@ -2191,7 +2191,7 @@ static int cfq_init_queue(request_queue_t *q, elevator_t *e) ...@@ -2191,7 +2191,7 @@ static int cfq_init_queue(request_queue_t *q, elevator_t *e)
if (!cfqd->cfq_hash) if (!cfqd->cfq_hash)
goto out_cfqhash; goto out_cfqhash;
cfqd->crq_pool = mempool_create(BLKDEV_MIN_RQ, mempool_alloc_slab, mempool_free_slab, crq_pool); cfqd->crq_pool = mempool_create_slab_pool(BLKDEV_MIN_RQ, crq_pool);
if (!cfqd->crq_pool) if (!cfqd->crq_pool)
goto out_crqpool; goto out_crqpool;
......
...@@ -211,9 +211,7 @@ aoeblk_gdalloc(void *vp) ...@@ -211,9 +211,7 @@ aoeblk_gdalloc(void *vp)
return; return;
} }
d->bufpool = mempool_create(MIN_BUFS, d->bufpool = mempool_create_slab_pool(MIN_BUFS, buf_pool_cache);
mempool_alloc_slab, mempool_free_slab,
buf_pool_cache);
if (d->bufpool == NULL) { if (d->bufpool == NULL) {
printk(KERN_ERR "aoe: aoeblk_gdalloc: cannot allocate bufpool " printk(KERN_ERR "aoe: aoeblk_gdalloc: cannot allocate bufpool "
"for %ld.%ld\n", d->aoemajor, d->aoeminor); "for %ld.%ld\n", d->aoemajor, d->aoeminor);
......
...@@ -616,8 +616,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -616,8 +616,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
} }
} }
cc->io_pool = mempool_create(MIN_IOS, mempool_alloc_slab, cc->io_pool = mempool_create_slab_pool(MIN_IOS, _crypt_io_pool);
mempool_free_slab, _crypt_io_pool);
if (!cc->io_pool) { if (!cc->io_pool) {
ti->error = PFX "Cannot allocate crypt io mempool"; ti->error = PFX "Cannot allocate crypt io mempool";
goto bad3; goto bad3;
......
...@@ -179,8 +179,7 @@ static struct multipath *alloc_multipath(void) ...@@ -179,8 +179,7 @@ static struct multipath *alloc_multipath(void)
m->queue_io = 1; m->queue_io = 1;
INIT_WORK(&m->process_queued_ios, process_queued_ios, m); INIT_WORK(&m->process_queued_ios, process_queued_ios, m);
INIT_WORK(&m->trigger_event, trigger_event, m); INIT_WORK(&m->trigger_event, trigger_event, m);
m->mpio_pool = mempool_create(MIN_IOS, mempool_alloc_slab, m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache);
mempool_free_slab, _mpio_cache);
if (!m->mpio_pool) { if (!m->mpio_pool) {
kfree(m); kfree(m);
return NULL; return NULL;
......
...@@ -1174,8 +1174,7 @@ static int __init dm_snapshot_init(void) ...@@ -1174,8 +1174,7 @@ static int __init dm_snapshot_init(void)
goto bad4; goto bad4;
} }
pending_pool = mempool_create(128, mempool_alloc_slab, pending_pool = mempool_create_slab_pool(128, pending_cache);
mempool_free_slab, pending_cache);
if (!pending_pool) { if (!pending_pool) {
DMERR("Couldn't create pending pool."); DMERR("Couldn't create pending pool.");
r = -ENOMEM; r = -ENOMEM;
......
...@@ -823,13 +823,11 @@ static struct mapped_device *alloc_dev(unsigned int minor, int persistent) ...@@ -823,13 +823,11 @@ static struct mapped_device *alloc_dev(unsigned int minor, int persistent)
md->queue->unplug_fn = dm_unplug_all; md->queue->unplug_fn = dm_unplug_all;
md->queue->issue_flush_fn = dm_flush_all; md->queue->issue_flush_fn = dm_flush_all;
md->io_pool = mempool_create(MIN_IOS, mempool_alloc_slab, md->io_pool = mempool_create_slab_pool(MIN_IOS, _io_cache);
mempool_free_slab, _io_cache);
if (!md->io_pool) if (!md->io_pool)
goto bad2; goto bad2;
md->tio_pool = mempool_create(MIN_IOS, mempool_alloc_slab, md->tio_pool = mempool_create_slab_pool(MIN_IOS, _tio_cache);
mempool_free_slab, _tio_cache);
if (!md->tio_pool) if (!md->tio_pool)
goto bad3; goto bad3;
......
...@@ -227,8 +227,7 @@ static int jobs_init(void) ...@@ -227,8 +227,7 @@ static int jobs_init(void)
if (!_job_cache) if (!_job_cache)
return -ENOMEM; return -ENOMEM;
_job_pool = mempool_create(MIN_JOBS, mempool_alloc_slab, _job_pool = mempool_create_slab_pool(MIN_JOBS, _job_cache);
mempool_free_slab, _job_cache);
if (!_job_pool) { if (!_job_pool) {
kmem_cache_destroy(_job_cache); kmem_cache_destroy(_job_cache);
return -ENOMEM; return -ENOMEM;
......
...@@ -1179,9 +1179,8 @@ static int __init i2o_block_init(void) ...@@ -1179,9 +1179,8 @@ static int __init i2o_block_init(void)
goto exit; goto exit;
} }
i2o_blk_req_pool.pool = mempool_create(I2O_BLOCK_REQ_MEMPOOL_SIZE, i2o_blk_req_pool.pool =
mempool_alloc_slab, mempool_create_slab_pool(I2O_BLOCK_REQ_MEMPOOL_SIZE,
mempool_free_slab,
i2o_blk_req_pool.slab); i2o_blk_req_pool.slab);
if (!i2o_blk_req_pool.pool) { if (!i2o_blk_req_pool.pool) {
osm_err("can't init request mempool\n"); osm_err("can't init request mempool\n");
......
...@@ -3200,8 +3200,8 @@ iscsi_r2tpool_alloc(struct iscsi_session *session) ...@@ -3200,8 +3200,8 @@ iscsi_r2tpool_alloc(struct iscsi_session *session)
* Data-Out PDU's within R2T-sequence can be quite big; * Data-Out PDU's within R2T-sequence can be quite big;
* using mempool * using mempool
*/ */
ctask->datapool = mempool_create(ISCSI_DTASK_DEFAULT_MAX, ctask->datapool = mempool_create_slab_pool(ISCSI_DTASK_DEFAULT_MAX,
mempool_alloc_slab, mempool_free_slab, taskcache); taskcache);
if (ctask->datapool == NULL) { if (ctask->datapool == NULL) {
kfifo_free(ctask->r2tqueue); kfifo_free(ctask->r2tqueue);
iscsi_pool_free(&ctask->r2tpool, (void**)ctask->r2ts); iscsi_pool_free(&ctask->r2tpool, (void**)ctask->r2ts);
......
...@@ -2154,8 +2154,7 @@ qla2x00_allocate_sp_pool(scsi_qla_host_t *ha) ...@@ -2154,8 +2154,7 @@ qla2x00_allocate_sp_pool(scsi_qla_host_t *ha)
int rval; int rval;
rval = QLA_SUCCESS; rval = QLA_SUCCESS;
ha->srb_mempool = mempool_create(SRB_MIN_REQ, mempool_alloc_slab, ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep);
mempool_free_slab, srb_cachep);
if (ha->srb_mempool == NULL) { if (ha->srb_mempool == NULL) {
qla_printk(KERN_INFO, ha, "Unable to allocate SRB mempool.\n"); qla_printk(KERN_INFO, ha, "Unable to allocate SRB mempool.\n");
rval = QLA_FUNCTION_FAILED; rval = QLA_FUNCTION_FAILED;
......
...@@ -1787,8 +1787,7 @@ int __init scsi_init_queue(void) ...@@ -1787,8 +1787,7 @@ int __init scsi_init_queue(void)
sgp->name); sgp->name);
} }
sgp->pool = mempool_create(SG_MEMPOOL_SIZE, sgp->pool = mempool_create_slab_pool(SG_MEMPOOL_SIZE,
mempool_alloc_slab, mempool_free_slab,
sgp->slab); sgp->slab);
if (!sgp->pool) { if (!sgp->pool) {
printk(KERN_ERR "SCSI: can't init sg mempool %s\n", printk(KERN_ERR "SCSI: can't init sg mempool %s\n",
......
...@@ -1141,8 +1141,7 @@ static int biovec_create_pools(struct bio_set *bs, int pool_entries, int scale) ...@@ -1141,8 +1141,7 @@ static int biovec_create_pools(struct bio_set *bs, int pool_entries, int scale)
if (i >= scale) if (i >= scale)
pool_entries >>= 1; pool_entries >>= 1;
*bvp = mempool_create(pool_entries, mempool_alloc_slab, *bvp = mempool_create_slab_pool(pool_entries, bp->slab);
mempool_free_slab, bp->slab);
if (!*bvp) if (!*bvp)
return -ENOMEM; return -ENOMEM;
} }
...@@ -1179,9 +1178,7 @@ struct bio_set *bioset_create(int bio_pool_size, int bvec_pool_size, int scale) ...@@ -1179,9 +1178,7 @@ struct bio_set *bioset_create(int bio_pool_size, int bvec_pool_size, int scale)
if (!bs) if (!bs)
return NULL; return NULL;
bs->bio_pool = mempool_create(bio_pool_size, mempool_alloc_slab, bs->bio_pool = mempool_create_slab_pool(bio_pool_size, bio_slab);
mempool_free_slab, bio_slab);
if (!bs->bio_pool) if (!bs->bio_pool)
goto bad; goto bad;
......
...@@ -738,9 +738,7 @@ cifs_init_request_bufs(void) ...@@ -738,9 +738,7 @@ cifs_init_request_bufs(void)
cERROR(1,("cifs_min_rcv set to maximum (64)")); cERROR(1,("cifs_min_rcv set to maximum (64)"));
} }
cifs_req_poolp = mempool_create(cifs_min_rcv, cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv,
mempool_alloc_slab,
mempool_free_slab,
cifs_req_cachep); cifs_req_cachep);
if(cifs_req_poolp == NULL) { if(cifs_req_poolp == NULL) {
...@@ -771,9 +769,7 @@ cifs_init_request_bufs(void) ...@@ -771,9 +769,7 @@ cifs_init_request_bufs(void)
cFYI(1,("cifs_min_small set to maximum (256)")); cFYI(1,("cifs_min_small set to maximum (256)"));
} }
cifs_sm_req_poolp = mempool_create(cifs_min_small, cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small,
mempool_alloc_slab,
mempool_free_slab,
cifs_sm_req_cachep); cifs_sm_req_cachep);
if(cifs_sm_req_poolp == NULL) { if(cifs_sm_req_poolp == NULL) {
...@@ -808,10 +804,8 @@ cifs_init_mids(void) ...@@ -808,10 +804,8 @@ cifs_init_mids(void)
if (cifs_mid_cachep == NULL) if (cifs_mid_cachep == NULL)
return -ENOMEM; return -ENOMEM;
cifs_mid_poolp = mempool_create(3 /* a reasonable min simultan opers */, /* 3 is a reasonable minimum number of simultaneous operations */
mempool_alloc_slab, cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep);
mempool_free_slab,
cifs_mid_cachep);
if(cifs_mid_poolp == NULL) { if(cifs_mid_poolp == NULL) {
kmem_cache_destroy(cifs_mid_cachep); kmem_cache_destroy(cifs_mid_cachep);
return -ENOMEM; return -ENOMEM;
......
...@@ -220,8 +220,8 @@ int __init metapage_init(void) ...@@ -220,8 +220,8 @@ int __init metapage_init(void)
if (metapage_cache == NULL) if (metapage_cache == NULL)
return -ENOMEM; return -ENOMEM;
metapage_mempool = mempool_create(METAPOOL_MIN_PAGES, mempool_alloc_slab, metapage_mempool = mempool_create_slab_pool(METAPOOL_MIN_PAGES,
mempool_free_slab, metapage_cache); metapage_cache);
if (metapage_mempool == NULL) { if (metapage_mempool == NULL) {
kmem_cache_destroy(metapage_cache); kmem_cache_destroy(metapage_cache);
......
...@@ -663,9 +663,7 @@ int nfs_init_readpagecache(void) ...@@ -663,9 +663,7 @@ int nfs_init_readpagecache(void)
if (nfs_rdata_cachep == NULL) if (nfs_rdata_cachep == NULL)
return -ENOMEM; return -ENOMEM;
nfs_rdata_mempool = mempool_create(MIN_POOL_READ, nfs_rdata_mempool = mempool_create_slab_pool(MIN_POOL_READ,
mempool_alloc_slab,
mempool_free_slab,
nfs_rdata_cachep); nfs_rdata_cachep);
if (nfs_rdata_mempool == NULL) if (nfs_rdata_mempool == NULL)
return -ENOMEM; return -ENOMEM;
......
...@@ -1521,16 +1521,12 @@ int nfs_init_writepagecache(void) ...@@ -1521,16 +1521,12 @@ int nfs_init_writepagecache(void)
if (nfs_wdata_cachep == NULL) if (nfs_wdata_cachep == NULL)
return -ENOMEM; return -ENOMEM;
nfs_wdata_mempool = mempool_create(MIN_POOL_WRITE, nfs_wdata_mempool = mempool_create_slab_pool(MIN_POOL_WRITE,
mempool_alloc_slab,
mempool_free_slab,
nfs_wdata_cachep); nfs_wdata_cachep);
if (nfs_wdata_mempool == NULL) if (nfs_wdata_mempool == NULL)
return -ENOMEM; return -ENOMEM;
nfs_commit_mempool = mempool_create(MIN_POOL_COMMIT, nfs_commit_mempool = mempool_create_slab_pool(MIN_POOL_COMMIT,
mempool_alloc_slab,
mempool_free_slab,
nfs_wdata_cachep); nfs_wdata_cachep);
if (nfs_commit_mempool == NULL) if (nfs_commit_mempool == NULL)
return -ENOMEM; return -ENOMEM;
......
...@@ -375,8 +375,7 @@ xfs_init_zones(void) ...@@ -375,8 +375,7 @@ xfs_init_zones(void)
if (!xfs_ioend_zone) if (!xfs_ioend_zone)
goto out_destroy_vnode_zone; goto out_destroy_vnode_zone;
xfs_ioend_pool = mempool_create(4 * MAX_BUF_PER_PAGE, xfs_ioend_pool = mempool_create_slab_pool(4 * MAX_BUF_PER_PAGE,
mempool_alloc_slab, mempool_free_slab,
xfs_ioend_zone); xfs_ioend_zone);
if (!xfs_ioend_pool) if (!xfs_ioend_pool)
goto out_free_ioend_zone; goto out_free_ioend_zone;
......
...@@ -950,9 +950,7 @@ static inline int i2o_pool_alloc(struct i2o_pool *pool, const char *name, ...@@ -950,9 +950,7 @@ static inline int i2o_pool_alloc(struct i2o_pool *pool, const char *name,
if (!pool->slab) if (!pool->slab)
goto free_name; goto free_name;
pool->mempool = pool->mempool = mempool_create_slab_pool(min_nr, pool->slab);
mempool_create(min_nr, mempool_alloc_slab, mempool_free_slab,
pool->slab);
if (!pool->mempool) if (!pool->mempool)
goto free_slab; goto free_slab;
......
...@@ -1167,15 +1167,11 @@ rpc_init_mempool(void) ...@@ -1167,15 +1167,11 @@ rpc_init_mempool(void)
NULL, NULL); NULL, NULL);
if (!rpc_buffer_slabp) if (!rpc_buffer_slabp)
goto err_nomem; goto err_nomem;
rpc_task_mempool = mempool_create(RPC_TASK_POOLSIZE, rpc_task_mempool = mempool_create_slab_pool(RPC_TASK_POOLSIZE,
mempool_alloc_slab,
mempool_free_slab,
rpc_task_slabp); rpc_task_slabp);
if (!rpc_task_mempool) if (!rpc_task_mempool)
goto err_nomem; goto err_nomem;
rpc_buffer_mempool = mempool_create(RPC_BUFFER_POOLSIZE, rpc_buffer_mempool = mempool_create_slab_pool(RPC_BUFFER_POOLSIZE,
mempool_alloc_slab,
mempool_free_slab,
rpc_buffer_slabp); rpc_buffer_slabp);
if (!rpc_buffer_mempool) if (!rpc_buffer_mempool)
goto err_nomem; goto err_nomem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment