Skip to content

Commit f10ab66

Browse files
FUJITA Tomonorijejb
authored andcommitted
[SCSI] tgt: convert to use the data buffer accessors
- 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>
1 parent 1237c98 commit f10ab66

4 files changed

Lines changed: 20 additions & 18 deletions

File tree

‎drivers/scsi/ibmvscsi/ibmvstgt.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ static int ibmvstgt_cmd_done(struct scsi_cmnd *sc,
292292
dprintk("%p %p %x %u\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0],
293293
cmd->usg_sg);
294294

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

298298
spin_lock_irqsave(&target->lock, flags);

‎drivers/scsi/libsrp.c‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,18 @@ static int srp_direct_data(struct scsi_cmnd *sc, struct srp_direct_buf *md,
192192

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

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

200-
nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg,
200+
nsg = dma_map_sg(iue->target->dev, sg, scsi_sg_count(sc),
201201
DMA_BIDIRECTIONAL);
202202
if (!nsg) {
203-
printk("fail to map %p %d\n", iue, sc->use_sg);
203+
printk("fail to map %p %d\n", iue, scsi_sg_count(sc));
204204
return 0;
205205
}
206-
len = min(sc->request_bufflen, md->len);
206+
len = min(scsi_bufflen(sc), md->len);
207207
} else
208208
len = md->len;
209209

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

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

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

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

269269
rdma:
270270
if (dma_map) {
271-
nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg, DMA_BIDIRECTIONAL);
271+
nsg = dma_map_sg(iue->target->dev, sg, scsi_sg_count(sc),
272+
DMA_BIDIRECTIONAL);
272273
if (!nsg) {
273-
eprintk("fail to map %p %d\n", iue, sc->use_sg);
274+
eprintk("fail to map %p %d\n", iue, scsi_sg_count(sc));
274275
err = -EIO;
275276
goto free_mem;
276277
}
277-
len = min(sc->request_bufflen, id->len);
278+
len = min(scsi_bufflen(sc), id->len);
278279
} else
279280
len = id->len;
280281

‎drivers/scsi/scsi_tgt_if.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, u64 itn_id,
112112
memset(&ev, 0, sizeof(ev));
113113
ev.p.cmd_req.host_no = shost->host_no;
114114
ev.p.cmd_req.itn_id = itn_id;
115-
ev.p.cmd_req.data_len = cmd->request_bufflen;
115+
ev.p.cmd_req.data_len = scsi_bufflen(cmd);
116116
memcpy(ev.p.cmd_req.scb, cmd->cmnd, sizeof(ev.p.cmd_req.scb));
117117
memcpy(ev.p.cmd_req.lun, lun, sizeof(ev.p.cmd_req.lun));
118118
ev.p.cmd_req.attribute = cmd->tag;

‎drivers/scsi/scsi_tgt_lib.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd)
331331

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

334-
if (cmd->request_buffer)
334+
if (scsi_sglist(cmd))
335335
scsi_free_sgtable(cmd);
336336

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

366366
cmd->request_bufflen = rq->data_len;
367367

368-
dprintk("cmd %p cnt %d %lu\n", cmd, cmd->use_sg, rq_data_dir(rq));
369-
count = blk_rq_map_sg(rq->q, rq, cmd->request_buffer);
370-
if (likely(count <= cmd->use_sg)) {
368+
dprintk("cmd %p cnt %d %lu\n", cmd, scsi_sg_count(cmd),
369+
rq_data_dir(rq));
370+
count = blk_rq_map_sg(rq->q, rq, scsi_sglist(cmd));
371+
if (likely(count <= scsi_sg_count(cmd))) {
371372
cmd->use_sg = count;
372373
return 0;
373374
}
374375

375-
eprintk("cmd %p cnt %d\n", cmd, cmd->use_sg);
376+
eprintk("cmd %p cnt %d\n", cmd, scsi_sg_count(cmd));
376377
scsi_free_sgtable(cmd);
377378
return -EINVAL;
378379
}

0 commit comments

Comments
 (0)