diff options
author | Mike Christie <michaelc@cs.wisc.edu> | 2005-11-11 06:31:41 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.(none)> | 2005-12-14 22:09:09 -0500 |
commit | aa7b5cd750c766f66a92c9f78ba176bc77512b7e (patch) | |
tree | f9825729d1928b7171c09fcec6a4fc45f759e168 /drivers | |
parent | 0d95716d6a1308c465d8c17ed1a217628936bb0c (diff) |
[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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/scsi_lib.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 3e136bfe4219..54a72f197487 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -306,6 +306,8 @@ struct scsi_io_context { | |||
306 | char sense[SCSI_SENSE_BUFFERSIZE]; | 306 | char sense[SCSI_SENSE_BUFFERSIZE]; |
307 | }; | 307 | }; |
308 | 308 | ||
309 | static kmem_cache_t *scsi_io_context_cache; | ||
310 | |||
309 | static void scsi_end_async(struct request *req) | 311 | static void scsi_end_async(struct request *req) |
310 | { | 312 | { |
311 | struct scsi_io_context *sioc = req->end_io_data; | 313 | struct scsi_io_context *sioc = req->end_io_data; |
@@ -313,7 +315,7 @@ static void scsi_end_async(struct request *req) | |||
313 | if (sioc->done) | 315 | if (sioc->done) |
314 | sioc->done(sioc->data, sioc->sense, req->errors, req->data_len); | 316 | sioc->done(sioc->data, sioc->sense, req->errors, req->data_len); |
315 | 317 | ||
316 | kfree(sioc); | 318 | kmem_cache_free(scsi_io_context_cache, sioc); |
317 | __blk_put_request(req->q, req); | 319 | __blk_put_request(req->q, req); |
318 | } | 320 | } |
319 | 321 | ||
@@ -452,9 +454,10 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd, | |||
452 | int err = 0; | 454 | int err = 0; |
453 | int write = (data_direction == DMA_TO_DEVICE); | 455 | int write = (data_direction == DMA_TO_DEVICE); |
454 | 456 | ||
455 | sioc = kzalloc(sizeof(*sioc), gfp); | 457 | sioc = kmem_cache_alloc(scsi_io_context_cache, gfp); |
456 | if (!sioc) | 458 | if (!sioc) |
457 | return DRIVER_ERROR << 24; | 459 | return DRIVER_ERROR << 24; |
460 | memset(sioc, 0, sizeof(*sioc)); | ||
458 | 461 | ||
459 | req = blk_get_request(sdev->request_queue, write, gfp); | 462 | req = blk_get_request(sdev->request_queue, write, gfp); |
460 | if (!req) | 463 | if (!req) |
@@ -1765,6 +1768,14 @@ int __init scsi_init_queue(void) | |||
1765 | { | 1768 | { |
1766 | int i; | 1769 | int i; |
1767 | 1770 | ||
1771 | scsi_io_context_cache = kmem_cache_create("scsi_io_context", | ||
1772 | sizeof(struct scsi_io_context), | ||
1773 | 0, 0, NULL, NULL); | ||
1774 | if (!scsi_io_context_cache) { | ||
1775 | printk(KERN_ERR "SCSI: can't init scsi io context cache\n"); | ||
1776 | return -ENOMEM; | ||
1777 | } | ||
1778 | |||
1768 | for (i = 0; i < SG_MEMPOOL_NR; i++) { | 1779 | for (i = 0; i < SG_MEMPOOL_NR; i++) { |
1769 | struct scsi_host_sg_pool *sgp = scsi_sg_pools + i; | 1780 | struct scsi_host_sg_pool *sgp = scsi_sg_pools + i; |
1770 | int size = sgp->size * sizeof(struct scatterlist); | 1781 | int size = sgp->size * sizeof(struct scatterlist); |
@@ -1792,6 +1803,8 @@ void scsi_exit_queue(void) | |||
1792 | { | 1803 | { |
1793 | int i; | 1804 | int i; |
1794 | 1805 | ||
1806 | kmem_cache_destroy(scsi_io_context_cache); | ||
1807 | |||
1795 | for (i = 0; i < SG_MEMPOOL_NR; i++) { | 1808 | for (i = 0; i < SG_MEMPOOL_NR; i++) { |
1796 | struct scsi_host_sg_pool *sgp = scsi_sg_pools + i; | 1809 | struct scsi_host_sg_pool *sgp = scsi_sg_pools + i; |
1797 | mempool_destroy(sgp->pool); | 1810 | mempool_destroy(sgp->pool); |