aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2006-06-03 07:21:13 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-06-06 11:07:25 -0400
commit5d5ff44fe6775ccb922fd1f7d478b2ba9ca95068 (patch)
treed8569caefe1cb5ecced30929ef98d3e1fe642425 /drivers/scsi
parente4a082c7c1f9a7b11fece6918e7ee5519b39ac46 (diff)
[SCSI] fix up request buffer reference in various scsi drivers
Various scsi drivers use scsi_cmnd.buffer and scsi_cmnd.bufflen in their queuecommand functions. Those fields are internal storage for the midlayer only and are used to restore the original payload after request_buffer and request_bufflen have been overwritten for EH. Using the buffer and bufflen fields means they do very broken things in error handling. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/3w-9xxx.c2
-rw-r--r--drivers/scsi/3w-xxxx.c2
-rw-r--r--drivers/scsi/NCR5380.c2
-rw-r--r--drivers/scsi/aacraid/aachba.c4
-rw-r--r--drivers/scsi/atp870u.c2
-rw-r--r--drivers/scsi/gdth.c2
-rw-r--r--drivers/scsi/in2000.c2
-rw-r--r--drivers/scsi/ips.c2
-rw-r--r--drivers/scsi/libata-scsi.c4
-rw-r--r--drivers/scsi/megaraid.c4
-rw-r--r--drivers/scsi/ncr53c8xx.c6
-rw-r--r--drivers/scsi/nsp32.c2
-rw-r--r--drivers/scsi/sd.c2
-rw-r--r--drivers/scsi/sr.c2
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c6
15 files changed, 22 insertions, 22 deletions
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index caeb6d246e57..b003baf8d404 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -1388,7 +1388,7 @@ static int twa_map_scsi_sg_data(TW_Device_Extension *tw_dev, int request_id)
1388 if (cmd->use_sg == 0) 1388 if (cmd->use_sg == 0)
1389 goto out; 1389 goto out;
1390 1390
1391 use_sg = pci_map_sg(pdev, cmd->buffer, cmd->use_sg, DMA_BIDIRECTIONAL); 1391 use_sg = pci_map_sg(pdev, cmd->request_buffer, cmd->use_sg, DMA_BIDIRECTIONAL);
1392 1392
1393 if (use_sg == 0) { 1393 if (use_sg == 0) {
1394 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1c, "Failed to map scatter gather list"); 1394 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1c, "Failed to map scatter gather list");
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index e8e41e6eb42a..37a58c6dad29 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -1286,7 +1286,7 @@ static int tw_map_scsi_sg_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
1286 if (cmd->use_sg == 0) 1286 if (cmd->use_sg == 0)
1287 return 0; 1287 return 0;
1288 1288
1289 use_sg = pci_map_sg(pdev, cmd->buffer, cmd->use_sg, DMA_BIDIRECTIONAL); 1289 use_sg = pci_map_sg(pdev, cmd->request_buffer, cmd->use_sg, DMA_BIDIRECTIONAL);
1290 1290
1291 if (use_sg == 0) { 1291 if (use_sg == 0) {
1292 printk(KERN_WARNING "3w-xxxx: tw_map_scsi_sg_data(): pci_map_sg() failed.\n"); 1292 printk(KERN_WARNING "3w-xxxx: tw_map_scsi_sg_data(): pci_map_sg() failed.\n");
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index 9f0ddbe6dc76..fa57e0b4a5fd 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -296,7 +296,7 @@ static __inline__ void initialize_SCp(Scsi_Cmnd * cmd)
296 */ 296 */
297 297
298 if (cmd->use_sg) { 298 if (cmd->use_sg) {
299 cmd->SCp.buffer = (struct scatterlist *) cmd->buffer; 299 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer;
300 cmd->SCp.buffers_residual = cmd->use_sg - 1; 300 cmd->SCp.buffers_residual = cmd->use_sg - 1;
301 cmd->SCp.ptr = page_address(cmd->SCp.buffer->page)+ 301 cmd->SCp.ptr = page_address(cmd->SCp.buffer->page)+
302 cmd->SCp.buffer->offset; 302 cmd->SCp.buffer->offset;
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index be8dde4c0f0c..e4b38f896cbd 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -961,7 +961,7 @@ static void io_callback(void *context, struct fib * fibptr)
961 961
962 if(scsicmd->use_sg) 962 if(scsicmd->use_sg)
963 pci_unmap_sg(dev->pdev, 963 pci_unmap_sg(dev->pdev,
964 (struct scatterlist *)scsicmd->buffer, 964 (struct scatterlist *)scsicmd->request_buffer,
965 scsicmd->use_sg, 965 scsicmd->use_sg,
966 scsicmd->sc_data_direction); 966 scsicmd->sc_data_direction);
967 else if(scsicmd->request_bufflen) 967 else if(scsicmd->request_bufflen)
@@ -1919,7 +1919,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
1919 1919
1920 if(scsicmd->use_sg) 1920 if(scsicmd->use_sg)
1921 pci_unmap_sg(dev->pdev, 1921 pci_unmap_sg(dev->pdev,
1922 (struct scatterlist *)scsicmd->buffer, 1922 (struct scatterlist *)scsicmd->request_buffer,
1923 scsicmd->use_sg, 1923 scsicmd->use_sg,
1924 scsicmd->sc_data_direction); 1924 scsicmd->sc_data_direction);
1925 else if(scsicmd->request_bufflen) 1925 else if(scsicmd->request_bufflen)
diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
index 58d7e34807aa..3ee4d4d3f445 100644
--- a/drivers/scsi/atp870u.c
+++ b/drivers/scsi/atp870u.c
@@ -473,7 +473,7 @@ go_42:
473 */ 473 */
474 if (workreq->use_sg) { 474 if (workreq->use_sg) {
475 pci_unmap_sg(dev->pdev, 475 pci_unmap_sg(dev->pdev,
476 (struct scatterlist *)workreq->buffer, 476 (struct scatterlist *)workreq->request_buffer,
477 workreq->use_sg, 477 workreq->use_sg,
478 workreq->sc_data_direction); 478 workreq->sc_data_direction);
479 } else if (workreq->request_bufflen && 479 } else if (workreq->request_bufflen &&
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index d5740bbdef3e..9b918fd43bf5 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -2542,7 +2542,7 @@ static void gdth_copy_internal_data(int hanum,Scsi_Cmnd *scp,
2542 gdth_ha_str *ha; 2542 gdth_ha_str *ha;
2543 char *address; 2543 char *address;
2544 2544
2545 cpcount = count<=(ushort)scp->bufflen ? count:(ushort)scp->bufflen; 2545 cpcount = count<=(ushort)scp->request_bufflen ? count:(ushort)scp->request_bufflen;
2546 ha = HADATA(gdth_ctr_tab[hanum]); 2546 ha = HADATA(gdth_ctr_tab[hanum]);
2547 2547
2548 if (scp->use_sg) { 2548 if (scp->use_sg) {
diff --git a/drivers/scsi/in2000.c b/drivers/scsi/in2000.c
index 9c519876f8a0..89a57a62e8ca 100644
--- a/drivers/scsi/in2000.c
+++ b/drivers/scsi/in2000.c
@@ -370,7 +370,7 @@ static int in2000_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
370 */ 370 */
371 371
372 if (cmd->use_sg) { 372 if (cmd->use_sg) {
373 cmd->SCp.buffer = (struct scatterlist *) cmd->buffer; 373 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer;
374 cmd->SCp.buffers_residual = cmd->use_sg - 1; 374 cmd->SCp.buffers_residual = cmd->use_sg - 1;
375 cmd->SCp.ptr = (char *) page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset; 375 cmd->SCp.ptr = (char *) page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset;
376 cmd->SCp.this_residual = cmd->SCp.buffer->length; 376 cmd->SCp.this_residual = cmd->SCp.buffer->length;
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index a4c0b04cfdbd..350c08c60887 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -4364,7 +4364,7 @@ ips_rdcap(ips_ha_t * ha, ips_scb_t * scb)
4364 4364
4365 METHOD_TRACE("ips_rdcap", 1); 4365 METHOD_TRACE("ips_rdcap", 1);
4366 4366
4367 if (scb->scsi_cmd->bufflen < 8) 4367 if (scb->scsi_cmd->request_bufflen < 8)
4368 return (0); 4368 return (0);
4369 4369
4370 cap.lba = 4370 cap.lba =
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index a0289ec3e283..994015726ec8 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -2310,7 +2310,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
2310#endif 2310#endif
2311 } 2311 }
2312 2312
2313 qc->nbytes = cmd->bufflen; 2313 qc->nbytes = cmd->request_bufflen;
2314 2314
2315 return 0; 2315 return 0;
2316} 2316}
@@ -2500,7 +2500,7 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
2500 * TODO: find out if we need to do more here to 2500 * TODO: find out if we need to do more here to
2501 * cover scatter/gather case. 2501 * cover scatter/gather case.
2502 */ 2502 */
2503 qc->nsect = cmd->bufflen / ATA_SECT_SIZE; 2503 qc->nsect = cmd->request_bufflen / ATA_SECT_SIZE;
2504 2504
2505 return 0; 2505 return 0;
2506 2506
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 80b68a2481b3..d245717fee65 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -524,7 +524,7 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy)
524 * filter the internal and ioctl commands 524 * filter the internal and ioctl commands
525 */ 525 */
526 if((cmd->cmnd[0] == MEGA_INTERNAL_CMD)) { 526 if((cmd->cmnd[0] == MEGA_INTERNAL_CMD)) {
527 return cmd->buffer; 527 return cmd->request_buffer;
528 } 528 }
529 529
530 530
@@ -4493,7 +4493,7 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
4493 scmd->device = sdev; 4493 scmd->device = sdev;
4494 4494
4495 scmd->device->host = adapter->host; 4495 scmd->device->host = adapter->host;
4496 scmd->buffer = (void *)scb; 4496 scmd->request_buffer = (void *)scb;
4497 scmd->cmnd[0] = MEGA_INTERNAL_CMD; 4497 scmd->cmnd[0] = MEGA_INTERNAL_CMD;
4498 4498
4499 scb->state |= SCB_ACTIVE; 4499 scb->state |= SCB_ACTIVE;
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index 22f913127f08..6ab035590ee6 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -529,7 +529,7 @@ static void __unmap_scsi_data(struct device *dev, struct scsi_cmnd *cmd)
529{ 529{
530 switch(cmd->__data_mapped) { 530 switch(cmd->__data_mapped) {
531 case 2: 531 case 2:
532 dma_unmap_sg(dev, cmd->buffer, cmd->use_sg, 532 dma_unmap_sg(dev, cmd->request_buffer, cmd->use_sg,
533 cmd->sc_data_direction); 533 cmd->sc_data_direction);
534 break; 534 break;
535 case 1: 535 case 1:
@@ -564,7 +564,7 @@ static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd)
564 if (cmd->use_sg == 0) 564 if (cmd->use_sg == 0)
565 return 0; 565 return 0;
566 566
567 use_sg = dma_map_sg(dev, cmd->buffer, cmd->use_sg, 567 use_sg = dma_map_sg(dev, cmd->request_buffer, cmd->use_sg,
568 cmd->sc_data_direction); 568 cmd->sc_data_direction);
569 cmd->__data_mapped = 2; 569 cmd->__data_mapped = 2;
570 cmd->__data_mapping = use_sg; 570 cmd->__data_mapping = use_sg;
@@ -7697,7 +7697,7 @@ static int ncr_scatter(struct ncb *np, struct ccb *cp, struct scsi_cmnd *cmd)
7697 if (!use_sg) 7697 if (!use_sg)
7698 segment = ncr_scatter_no_sglist(np, cp, cmd); 7698 segment = ncr_scatter_no_sglist(np, cp, cmd);
7699 else if ((use_sg = map_scsi_sg_data(np, cmd)) > 0) { 7699 else if ((use_sg = map_scsi_sg_data(np, cmd)) > 0) {
7700 struct scatterlist *scatter = (struct scatterlist *)cmd->buffer; 7700 struct scatterlist *scatter = (struct scatterlist *)cmd->request_buffer;
7701 struct scr_tblmove *data; 7701 struct scr_tblmove *data;
7702 7702
7703 if (use_sg > MAX_SCATTER) { 7703 if (use_sg > MAX_SCATTER) {
diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
index 30ee0ef4b459..5c55e152e718 100644
--- a/drivers/scsi/nsp32.c
+++ b/drivers/scsi/nsp32.c
@@ -1636,7 +1636,7 @@ static void nsp32_scsi_done(struct scsi_cmnd *SCpnt)
1636 1636
1637 if (SCpnt->use_sg) { 1637 if (SCpnt->use_sg) {
1638 pci_unmap_sg(data->Pci, 1638 pci_unmap_sg(data->Pci,
1639 (struct scatterlist *)SCpnt->buffer, 1639 (struct scatterlist *)SCpnt->request_buffer,
1640 SCpnt->use_sg, SCpnt->sc_data_direction); 1640 SCpnt->use_sg, SCpnt->sc_data_direction);
1641 } else { 1641 } else {
1642 pci_unmap_single(data->Pci, 1642 pci_unmap_single(data->Pci,
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index c647d85d97d1..a112e49e946f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -891,7 +891,7 @@ static struct block_device_operations sd_fops = {
891static void sd_rw_intr(struct scsi_cmnd * SCpnt) 891static void sd_rw_intr(struct scsi_cmnd * SCpnt)
892{ 892{
893 int result = SCpnt->result; 893 int result = SCpnt->result;
894 int this_count = SCpnt->bufflen; 894 int this_count = SCpnt->request_bufflen;
895 int good_bytes = (result == 0 ? this_count : 0); 895 int good_bytes = (result == 0 ? this_count : 0);
896 sector_t block_sectors = 1; 896 sector_t block_sectors = 1;
897 u64 first_err_block; 897 u64 first_err_block;
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 7c80711e18ed..ebf6579ed698 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -217,7 +217,7 @@ int sr_media_change(struct cdrom_device_info *cdi, int slot)
217static void rw_intr(struct scsi_cmnd * SCpnt) 217static void rw_intr(struct scsi_cmnd * SCpnt)
218{ 218{
219 int result = SCpnt->result; 219 int result = SCpnt->result;
220 int this_count = SCpnt->bufflen; 220 int this_count = SCpnt->request_bufflen;
221 int good_bytes = (result == 0 ? this_count : 0); 221 int good_bytes = (result == 0 ? this_count : 0);
222 int block_sectors = 0; 222 int block_sectors = 0;
223 long error_sector; 223 long error_sector;
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 9c83b4d39a26..ee081320e1f1 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -156,7 +156,7 @@ static void __unmap_scsi_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
156 156
157 switch(SYM_UCMD_PTR(cmd)->data_mapped) { 157 switch(SYM_UCMD_PTR(cmd)->data_mapped) {
158 case 2: 158 case 2:
159 pci_unmap_sg(pdev, cmd->buffer, cmd->use_sg, dma_dir); 159 pci_unmap_sg(pdev, cmd->request_buffer, cmd->use_sg, dma_dir);
160 break; 160 break;
161 case 1: 161 case 1:
162 pci_unmap_single(pdev, SYM_UCMD_PTR(cmd)->data_mapping, 162 pci_unmap_single(pdev, SYM_UCMD_PTR(cmd)->data_mapping,
@@ -186,7 +186,7 @@ static int __map_scsi_sg_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
186 int use_sg; 186 int use_sg;
187 int dma_dir = cmd->sc_data_direction; 187 int dma_dir = cmd->sc_data_direction;
188 188
189 use_sg = pci_map_sg(pdev, cmd->buffer, cmd->use_sg, dma_dir); 189 use_sg = pci_map_sg(pdev, cmd->request_buffer, cmd->use_sg, dma_dir);
190 if (use_sg > 0) { 190 if (use_sg > 0) {
191 SYM_UCMD_PTR(cmd)->data_mapped = 2; 191 SYM_UCMD_PTR(cmd)->data_mapped = 2;
192 SYM_UCMD_PTR(cmd)->data_mapping = use_sg; 192 SYM_UCMD_PTR(cmd)->data_mapping = use_sg;
@@ -376,7 +376,7 @@ static int sym_scatter(struct sym_hcb *np, struct sym_ccb *cp, struct scsi_cmnd
376 if (!use_sg) 376 if (!use_sg)
377 segment = sym_scatter_no_sglist(np, cp, cmd); 377 segment = sym_scatter_no_sglist(np, cp, cmd);
378 else if ((use_sg = map_scsi_sg_data(np, cmd)) > 0) { 378 else if ((use_sg = map_scsi_sg_data(np, cmd)) > 0) {
379 struct scatterlist *scatter = (struct scatterlist *)cmd->buffer; 379 struct scatterlist *scatter = (struct scatterlist *)cmd->request_buffer;
380 struct sym_tcb *tp = &np->target[cp->target]; 380 struct sym_tcb *tp = &np->target[cp->target];
381 struct sym_tblmove *data; 381 struct sym_tblmove *data;
382 382