提交 0cde8d95 编写于 作者: J Jens Axboe

scsi: simplify scsi_free_sgtable()

Just pass in the command, no point in passing in the scatterlist
and scatterlist pool index seperately.
Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
上级 4c2f6d4c
...@@ -741,13 +741,14 @@ struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask) ...@@ -741,13 +741,14 @@ struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask)
EXPORT_SYMBOL(scsi_alloc_sgtable); EXPORT_SYMBOL(scsi_alloc_sgtable);
void scsi_free_sgtable(struct scatterlist *sgl, int index) void scsi_free_sgtable(struct scsi_cmnd *cmd)
{ {
struct scatterlist *sgl = cmd->request_buffer;
struct scsi_host_sg_pool *sgp; struct scsi_host_sg_pool *sgp;
BUG_ON(index >= SG_MEMPOOL_NR); BUG_ON(cmd->sglist_len >= SG_MEMPOOL_NR);
sgp = scsi_sg_pools + index; sgp = scsi_sg_pools + cmd->sglist_len;
mempool_free(sgl, sgp->pool); mempool_free(sgl, sgp->pool);
} }
...@@ -773,7 +774,7 @@ EXPORT_SYMBOL(scsi_free_sgtable); ...@@ -773,7 +774,7 @@ EXPORT_SYMBOL(scsi_free_sgtable);
static void scsi_release_buffers(struct scsi_cmnd *cmd) static void scsi_release_buffers(struct scsi_cmnd *cmd)
{ {
if (cmd->use_sg) if (cmd->use_sg)
scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); scsi_free_sgtable(cmd);
/* /*
* Zero these out. They now point to freed memory, and it is * Zero these out. They now point to freed memory, and it is
......
...@@ -332,7 +332,7 @@ static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd) ...@@ -332,7 +332,7 @@ static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd)
scsi_tgt_uspace_send_status(cmd, tcmd->itn_id, tcmd->tag); scsi_tgt_uspace_send_status(cmd, tcmd->itn_id, tcmd->tag);
if (cmd->request_buffer) if (cmd->request_buffer)
scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); scsi_free_sgtable(cmd);
queue_work(scsi_tgtd, &tcmd->work); queue_work(scsi_tgtd, &tcmd->work);
} }
...@@ -373,7 +373,7 @@ static int scsi_tgt_init_cmd(struct scsi_cmnd *cmd, gfp_t gfp_mask) ...@@ -373,7 +373,7 @@ static int scsi_tgt_init_cmd(struct scsi_cmnd *cmd, gfp_t gfp_mask)
} }
eprintk("cmd %p cnt %d\n", cmd, cmd->use_sg); eprintk("cmd %p cnt %d\n", cmd, cmd->use_sg);
scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); scsi_free_sgtable(cmd);
return -EINVAL; return -EINVAL;
} }
......
...@@ -129,7 +129,7 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, ...@@ -129,7 +129,7 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
extern void scsi_kunmap_atomic_sg(void *virt); extern void scsi_kunmap_atomic_sg(void *virt);
extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t); extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t);
extern void scsi_free_sgtable(struct scatterlist *, int); extern void scsi_free_sgtable(struct scsi_cmnd *);
extern int scsi_dma_map(struct scsi_cmnd *cmd); extern int scsi_dma_map(struct scsi_cmnd *cmd);
extern void scsi_dma_unmap(struct scsi_cmnd *cmd); extern void scsi_dma_unmap(struct scsi_cmnd *cmd);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册