mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
[SCSI] add kmemcache for scsi_io_context
Add kmemcache of scsi io contexts. In the future when we finalize on where these functions will live we can add a mempool for it and do a bioset for out REQ_BLOCK_PC bios. This is needed becuase the dm-multipath handlers will want to use the scsi_exectute* functions for failover and we cannot have them and the bio device allocating from the same mempool. Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
This commit is contained in:
parent
0d95716d6a
commit
aa7b5cd750
1 changed files with 15 additions and 2 deletions
|
@ -306,6 +306,8 @@ struct scsi_io_context {
|
||||||
char sense[SCSI_SENSE_BUFFERSIZE];
|
char sense[SCSI_SENSE_BUFFERSIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static kmem_cache_t *scsi_io_context_cache;
|
||||||
|
|
||||||
static void scsi_end_async(struct request *req)
|
static void scsi_end_async(struct request *req)
|
||||||
{
|
{
|
||||||
struct scsi_io_context *sioc = req->end_io_data;
|
struct scsi_io_context *sioc = req->end_io_data;
|
||||||
|
@ -313,7 +315,7 @@ static void scsi_end_async(struct request *req)
|
||||||
if (sioc->done)
|
if (sioc->done)
|
||||||
sioc->done(sioc->data, sioc->sense, req->errors, req->data_len);
|
sioc->done(sioc->data, sioc->sense, req->errors, req->data_len);
|
||||||
|
|
||||||
kfree(sioc);
|
kmem_cache_free(scsi_io_context_cache, sioc);
|
||||||
__blk_put_request(req->q, req);
|
__blk_put_request(req->q, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,9 +454,10 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
|
||||||
int err = 0;
|
int err = 0;
|
||||||
int write = (data_direction == DMA_TO_DEVICE);
|
int write = (data_direction == DMA_TO_DEVICE);
|
||||||
|
|
||||||
sioc = kzalloc(sizeof(*sioc), gfp);
|
sioc = kmem_cache_alloc(scsi_io_context_cache, gfp);
|
||||||
if (!sioc)
|
if (!sioc)
|
||||||
return DRIVER_ERROR << 24;
|
return DRIVER_ERROR << 24;
|
||||||
|
memset(sioc, 0, sizeof(*sioc));
|
||||||
|
|
||||||
req = blk_get_request(sdev->request_queue, write, gfp);
|
req = blk_get_request(sdev->request_queue, write, gfp);
|
||||||
if (!req)
|
if (!req)
|
||||||
|
@ -1765,6 +1768,14 @@ int __init scsi_init_queue(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
scsi_io_context_cache = kmem_cache_create("scsi_io_context",
|
||||||
|
sizeof(struct scsi_io_context),
|
||||||
|
0, 0, NULL, NULL);
|
||||||
|
if (!scsi_io_context_cache) {
|
||||||
|
printk(KERN_ERR "SCSI: can't init scsi io context cache\n");
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < SG_MEMPOOL_NR; i++) {
|
for (i = 0; i < SG_MEMPOOL_NR; i++) {
|
||||||
struct scsi_host_sg_pool *sgp = scsi_sg_pools + i;
|
struct scsi_host_sg_pool *sgp = scsi_sg_pools + i;
|
||||||
int size = sgp->size * sizeof(struct scatterlist);
|
int size = sgp->size * sizeof(struct scatterlist);
|
||||||
|
@ -1792,6 +1803,8 @@ void scsi_exit_queue(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
kmem_cache_destroy(scsi_io_context_cache);
|
||||||
|
|
||||||
for (i = 0; i < SG_MEMPOOL_NR; i++) {
|
for (i = 0; i < SG_MEMPOOL_NR; i++) {
|
||||||
struct scsi_host_sg_pool *sgp = scsi_sg_pools + i;
|
struct scsi_host_sg_pool *sgp = scsi_sg_pools + i;
|
||||||
mempool_destroy(sgp->pool);
|
mempool_destroy(sgp->pool);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue