[SCSI] tgt: use scsi_init_io instead of scsi_alloc_sgtable
If we export scsi_init_io()/scsi_release_buffers() instead of scsi_{alloc,free}_sgtable() from scsi_lib than tgt code is much more insulated from scsi_lib changes. As a bonus it will also gain bidi capability when it comes. [jejb: rebase on to sg_table and fix up rejections] Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
This commit is contained in:
committed by
James Bottomley
parent
03e7925d07
commit
bb52d82f45
@@ -331,8 +331,7 @@ static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd)
|
||||
|
||||
scsi_tgt_uspace_send_status(cmd, tcmd->itn_id, tcmd->tag);
|
||||
|
||||
if (scsi_sglist(cmd))
|
||||
scsi_free_sgtable(cmd);
|
||||
scsi_release_buffers(cmd);
|
||||
|
||||
queue_work(scsi_tgtd, &tcmd->work);
|
||||
}
|
||||
@@ -353,25 +352,6 @@ static int scsi_tgt_transfer_response(struct scsi_cmnd *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int scsi_tgt_init_cmd(struct scsi_cmnd *cmd, gfp_t gfp_mask)
|
||||
{
|
||||
struct request *rq = cmd->request;
|
||||
int count;
|
||||
|
||||
cmd->use_sg = rq->nr_phys_segments;
|
||||
if (scsi_alloc_sgtable(cmd, gfp_mask))
|
||||
return -ENOMEM;
|
||||
|
||||
cmd->request_bufflen = rq->data_len;
|
||||
|
||||
dprintk("cmd %p cnt %d %lu\n", cmd, scsi_sg_count(cmd),
|
||||
rq_data_dir(rq));
|
||||
count = blk_rq_map_sg(rq->q, rq, scsi_sglist(cmd));
|
||||
BUG_ON(count > cmd->use_sg);
|
||||
cmd->use_sg = count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* TODO: test this crap and replace bio_map_user with new interface maybe */
|
||||
static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
|
||||
unsigned long uaddr, unsigned int len, int rw)
|
||||
@@ -397,9 +377,11 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
|
||||
}
|
||||
|
||||
tcmd->bio = rq->bio;
|
||||
err = scsi_tgt_init_cmd(cmd, GFP_KERNEL);
|
||||
if (err)
|
||||
err = scsi_init_io(cmd, GFP_KERNEL);
|
||||
if (err) {
|
||||
scsi_release_buffers(cmd);
|
||||
goto unmap_rq;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
Reference in New Issue
Block a user