Skip to content

Commit

Permalink
[SCSI] tgt: convert to use the data buffer accessors
Browse files Browse the repository at this point in the history
- convert to use the new accessors for the sg lists and the
parameters.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
  • Loading branch information
FUJITA Tomonori authored and James Bottomley committed Jan 12, 2008
1 parent 1237c98 commit f10ab66
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion drivers/scsi/ibmvscsi/ibmvstgt.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ static int ibmvstgt_cmd_done(struct scsi_cmnd *sc,
dprintk("%p %p %x %u\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0],
cmd->usg_sg);

if (sc->use_sg)
if (scsi_sg_count(sc))
err = srp_transfer_data(sc, &vio_iu(iue)->srp.cmd, ibmvstgt_rdma, 1, 1);

spin_lock_irqsave(&target->lock, flags);
Expand Down
23 changes: 12 additions & 11 deletions drivers/scsi/libsrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,18 @@ static int srp_direct_data(struct scsi_cmnd *sc, struct srp_direct_buf *md,

if (dma_map) {
iue = (struct iu_entry *) sc->SCp.ptr;
sg = sc->request_buffer;
sg = scsi_sglist(sc);

dprintk("%p %u %u %d\n", iue, sc->request_bufflen,
md->len, sc->use_sg);
dprintk("%p %u %u %d\n", iue, scsi_bufflen(sc),
md->len, scsi_sg_count(sc));

nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg,
nsg = dma_map_sg(iue->target->dev, sg, scsi_sg_count(sc),
DMA_BIDIRECTIONAL);
if (!nsg) {
printk("fail to map %p %d\n", iue, sc->use_sg);
printk("fail to map %p %d\n", iue, scsi_sg_count(sc));
return 0;
}
len = min(sc->request_bufflen, md->len);
len = min(scsi_bufflen(sc), md->len);
} else
len = md->len;

Expand All @@ -229,10 +229,10 @@ static int srp_indirect_data(struct scsi_cmnd *sc, struct srp_cmd *cmd,

if (dma_map || ext_desc) {
iue = (struct iu_entry *) sc->SCp.ptr;
sg = sc->request_buffer;
sg = scsi_sglist(sc);

dprintk("%p %u %u %d %d\n",
iue, sc->request_bufflen, id->len,
iue, scsi_bufflen(sc), id->len,
cmd->data_in_desc_cnt, cmd->data_out_desc_cnt);
}

Expand Down Expand Up @@ -268,13 +268,14 @@ static int srp_indirect_data(struct scsi_cmnd *sc, struct srp_cmd *cmd,

rdma:
if (dma_map) {
nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg, DMA_BIDIRECTIONAL);
nsg = dma_map_sg(iue->target->dev, sg, scsi_sg_count(sc),
DMA_BIDIRECTIONAL);
if (!nsg) {
eprintk("fail to map %p %d\n", iue, sc->use_sg);
eprintk("fail to map %p %d\n", iue, scsi_sg_count(sc));
err = -EIO;
goto free_mem;
}
len = min(sc->request_bufflen, id->len);
len = min(scsi_bufflen(sc), id->len);
} else
len = id->len;

Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/scsi_tgt_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, u64 itn_id,
memset(&ev, 0, sizeof(ev));
ev.p.cmd_req.host_no = shost->host_no;
ev.p.cmd_req.itn_id = itn_id;
ev.p.cmd_req.data_len = cmd->request_bufflen;
ev.p.cmd_req.data_len = scsi_bufflen(cmd);
memcpy(ev.p.cmd_req.scb, cmd->cmnd, sizeof(ev.p.cmd_req.scb));
memcpy(ev.p.cmd_req.lun, lun, sizeof(ev.p.cmd_req.lun));
ev.p.cmd_req.attribute = cmd->tag;
Expand Down
11 changes: 6 additions & 5 deletions drivers/scsi/scsi_tgt_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd)

scsi_tgt_uspace_send_status(cmd, tcmd->itn_id, tcmd->tag);

if (cmd->request_buffer)
if (scsi_sglist(cmd))
scsi_free_sgtable(cmd);

queue_work(scsi_tgtd, &tcmd->work);
Expand Down Expand Up @@ -365,14 +365,15 @@ static int scsi_tgt_init_cmd(struct scsi_cmnd *cmd, gfp_t gfp_mask)

cmd->request_bufflen = rq->data_len;

dprintk("cmd %p cnt %d %lu\n", cmd, cmd->use_sg, rq_data_dir(rq));
count = blk_rq_map_sg(rq->q, rq, cmd->request_buffer);
if (likely(count <= cmd->use_sg)) {
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));
if (likely(count <= scsi_sg_count(cmd))) {
cmd->use_sg = count;
return 0;
}

eprintk("cmd %p cnt %d\n", cmd, cmd->use_sg);
eprintk("cmd %p cnt %d\n", cmd, scsi_sg_count(cmd));
scsi_free_sgtable(cmd);
return -EINVAL;
}
Expand Down

0 comments on commit f10ab66

Please sign in to comment.