*/
static kmem_cache_t *request_cachep;
+/*
+ * For queue allocation
+ */
+static kmem_cache_t *requestq_cachep;
+
+/*
+ * For io context allocations
+ */
+static kmem_cache_t *iocontext_cachep;
+
static wait_queue_head_t congestion_wqh[2] = {
__WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[0]),
__WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1])
if (blk_queue_tagged(q))
blk_queue_free_tags(q);
- kfree(q);
+ kmem_cache_free(requestq_cachep, q);
}
EXPORT_SYMBOL(blk_cleanup_queue);
request_queue_t *blk_alloc_queue(int gfp_mask)
{
- request_queue_t *q = kmalloc(sizeof(*q), gfp_mask);
+ request_queue_t *q = kmem_cache_alloc(requestq_cachep, gfp_mask);
if (!q)
return NULL;
out_elv:
blk_cleanup_queue(q);
out_init:
- kfree(q);
+ kmem_cache_free(requestq_cachep, q);
return NULL;
}
if (!request_cachep)
panic("Can't create request pool slab cache\n");
+ requestq_cachep = kmem_cache_create("blkdev_queue",
+ sizeof(request_queue_t), 0, 0, NULL, NULL);
+ if (!requestq_cachep)
+ panic("Can't create request queue slab cache\n");
+
+ iocontext_cachep = kmem_cache_create("blkdev_ioc",
+ sizeof(struct io_context), 0, 0, NULL, NULL);
+ if (!iocontext_cachep)
+ panic("Can't create io context slab cache\n");
+
blk_max_low_pfn = max_low_pfn;
blk_max_pfn = max_pfn;
return 0;
if (atomic_dec_and_test(&ioc->refcount)) {
if (ioc->aic && ioc->aic->dtor)
ioc->aic->dtor(ioc->aic);
- kfree(ioc);
+ kmem_cache_free(iocontext_cachep, ioc);
}
}
local_irq_save(flags);
ret = tsk->io_context;
if (ret == NULL) {
- ret = kmalloc(sizeof(*ret), GFP_ATOMIC);
+ ret = kmem_cache_alloc(iocontext_cachep, GFP_ATOMIC);
if (ret) {
atomic_set(&ret->refcount, 1);
ret->pid = tsk->pid;