Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 15654
b: refs/heads/master
c: aa7b5cd
h: refs/heads/master
v: v3
  • Loading branch information
Mike Christie authored and James Bottomley committed Dec 15, 2005
1 parent 88260ff commit 04bde9d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0d95716d6a1308c465d8c17ed1a217628936bb0c
refs/heads/master: aa7b5cd750c766f66a92c9f78ba176bc77512b7e
17 changes: 15 additions & 2 deletions trunk/drivers/scsi/scsi_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,16 @@ struct scsi_io_context {
char sense[SCSI_SENSE_BUFFERSIZE];
};

static kmem_cache_t *scsi_io_context_cache;

static void scsi_end_async(struct request *req)
{
struct scsi_io_context *sioc = req->end_io_data;

if (sioc->done)
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);
}

Expand Down Expand Up @@ -452,9 +454,10 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
int err = 0;
int write = (data_direction == DMA_TO_DEVICE);

sioc = kzalloc(sizeof(*sioc), gfp);
sioc = kmem_cache_alloc(scsi_io_context_cache, gfp);
if (!sioc)
return DRIVER_ERROR << 24;
memset(sioc, 0, sizeof(*sioc));

req = blk_get_request(sdev->request_queue, write, gfp);
if (!req)
Expand Down Expand Up @@ -1765,6 +1768,14 @@ int __init scsi_init_queue(void)
{
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++) {
struct scsi_host_sg_pool *sgp = scsi_sg_pools + i;
int size = sgp->size * sizeof(struct scatterlist);
Expand Down Expand Up @@ -1792,6 +1803,8 @@ void scsi_exit_queue(void)
{
int i;

kmem_cache_destroy(scsi_io_context_cache);

for (i = 0; i < SG_MEMPOOL_NR; i++) {
struct scsi_host_sg_pool *sgp = scsi_sg_pools + i;
mempool_destroy(sgp->pool);
Expand Down

0 comments on commit 04bde9d

Please sign in to comment.