diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-01-02 11:25:34 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-01-02 16:11:06 -0500 |
commit | ac40532ef0b8649e6f7f83859ea0de1c4ed08a19 (patch) | |
tree | ca86d577fe7fe68ae28b7f7d020f86bc9fff5535 /drivers/scsi | |
parent | 158a962422e4a54dc256b6a9b9562f3d30d34d9c (diff) |
scsi: revert "[SCSI] Get rid of scsi_cmnd->done"
This reverts commit 6f5391c283d7fdcf24bf40786ea79061919d1e1d ("[SCSI]
Get rid of scsi_cmnd->done") that was supposed to be a cleanup commit,
but apparently it causes regressions:
Bug 9370 - v2.6.24-rc2-409-g9418d5d: attempt to access beyond end of device
http://bugzilla.kernel.org/show_bug.cgi?id=9370
this patch should be reintroduced in a more split-up form to make
testing of it easier.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Acked-by: Matthew Wilcox <matthew@wil.cx>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/scsi.c | 20 | ||||
-rw-r--r-- | drivers/scsi/scsi_error.c | 1 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 14 | ||||
-rw-r--r-- | drivers/scsi/scsi_priv.h | 1 | ||||
-rw-r--r-- | drivers/scsi/sd.c | 28 | ||||
-rw-r--r-- | drivers/scsi/sr.c | 21 |
6 files changed, 43 insertions, 42 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 0fb1709ce5e3..7ceb8209e5df 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -59,7 +59,6 @@ | |||
59 | #include <scsi/scsi_cmnd.h> | 59 | #include <scsi/scsi_cmnd.h> |
60 | #include <scsi/scsi_dbg.h> | 60 | #include <scsi/scsi_dbg.h> |
61 | #include <scsi/scsi_device.h> | 61 | #include <scsi/scsi_device.h> |
62 | #include <scsi/scsi_driver.h> | ||
63 | #include <scsi/scsi_eh.h> | 62 | #include <scsi/scsi_eh.h> |
64 | #include <scsi/scsi_host.h> | 63 | #include <scsi/scsi_host.h> |
65 | #include <scsi/scsi_tcq.h> | 64 | #include <scsi/scsi_tcq.h> |
@@ -368,8 +367,9 @@ void scsi_log_send(struct scsi_cmnd *cmd) | |||
368 | scsi_print_command(cmd); | 367 | scsi_print_command(cmd); |
369 | if (level > 3) { | 368 | if (level > 3) { |
370 | printk(KERN_INFO "buffer = 0x%p, bufflen = %d," | 369 | printk(KERN_INFO "buffer = 0x%p, bufflen = %d," |
371 | " queuecommand 0x%p\n", | 370 | " done = 0x%p, queuecommand 0x%p\n", |
372 | scsi_sglist(cmd), scsi_bufflen(cmd), | 371 | scsi_sglist(cmd), scsi_bufflen(cmd), |
372 | cmd->done, | ||
373 | cmd->device->host->hostt->queuecommand); | 373 | cmd->device->host->hostt->queuecommand); |
374 | 374 | ||
375 | } | 375 | } |
@@ -654,12 +654,6 @@ void __scsi_done(struct scsi_cmnd *cmd) | |||
654 | blk_complete_request(rq); | 654 | blk_complete_request(rq); |
655 | } | 655 | } |
656 | 656 | ||
657 | /* Move this to a header if it becomes more generally useful */ | ||
658 | static struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd) | ||
659 | { | ||
660 | return *(struct scsi_driver **)cmd->request->rq_disk->private_data; | ||
661 | } | ||
662 | |||
663 | /* | 657 | /* |
664 | * Function: scsi_finish_command | 658 | * Function: scsi_finish_command |
665 | * | 659 | * |
@@ -671,8 +665,6 @@ void scsi_finish_command(struct scsi_cmnd *cmd) | |||
671 | { | 665 | { |
672 | struct scsi_device *sdev = cmd->device; | 666 | struct scsi_device *sdev = cmd->device; |
673 | struct Scsi_Host *shost = sdev->host; | 667 | struct Scsi_Host *shost = sdev->host; |
674 | struct scsi_driver *drv; | ||
675 | unsigned int good_bytes; | ||
676 | 668 | ||
677 | scsi_device_unbusy(sdev); | 669 | scsi_device_unbusy(sdev); |
678 | 670 | ||
@@ -698,13 +690,7 @@ void scsi_finish_command(struct scsi_cmnd *cmd) | |||
698 | "Notifying upper driver of completion " | 690 | "Notifying upper driver of completion " |
699 | "(result %x)\n", cmd->result)); | 691 | "(result %x)\n", cmd->result)); |
700 | 692 | ||
701 | good_bytes = cmd->request_bufflen; | 693 | cmd->done(cmd); |
702 | if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) { | ||
703 | drv = scsi_cmd_to_driver(cmd); | ||
704 | if (drv->done) | ||
705 | good_bytes = drv->done(cmd); | ||
706 | } | ||
707 | scsi_io_completion(cmd, good_bytes); | ||
708 | } | 694 | } |
709 | EXPORT_SYMBOL(scsi_finish_command); | 695 | EXPORT_SYMBOL(scsi_finish_command); |
710 | 696 | ||
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index ebaca4ca4a13..70700b97c915 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c | |||
@@ -1699,6 +1699,7 @@ scsi_reset_provider(struct scsi_device *dev, int flag) | |||
1699 | memset(&scmd->cmnd, '\0', sizeof(scmd->cmnd)); | 1699 | memset(&scmd->cmnd, '\0', sizeof(scmd->cmnd)); |
1700 | 1700 | ||
1701 | scmd->scsi_done = scsi_reset_provider_done_command; | 1701 | scmd->scsi_done = scsi_reset_provider_done_command; |
1702 | scmd->done = NULL; | ||
1702 | scmd->request_buffer = NULL; | 1703 | scmd->request_buffer = NULL; |
1703 | scmd->request_bufflen = 0; | 1704 | scmd->request_bufflen = 0; |
1704 | 1705 | ||
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 0e81e4cf8876..8df8267ce316 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -1092,6 +1092,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
1092 | } | 1092 | } |
1093 | scsi_end_request(cmd, 0, this_count, !result); | 1093 | scsi_end_request(cmd, 0, this_count, !result); |
1094 | } | 1094 | } |
1095 | EXPORT_SYMBOL(scsi_io_completion); | ||
1095 | 1096 | ||
1096 | /* | 1097 | /* |
1097 | * Function: scsi_init_io() | 1098 | * Function: scsi_init_io() |
@@ -1170,6 +1171,18 @@ static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev, | |||
1170 | return cmd; | 1171 | return cmd; |
1171 | } | 1172 | } |
1172 | 1173 | ||
1174 | static void scsi_blk_pc_done(struct scsi_cmnd *cmd) | ||
1175 | { | ||
1176 | BUG_ON(!blk_pc_request(cmd->request)); | ||
1177 | /* | ||
1178 | * This will complete the whole command with uptodate=1 so | ||
1179 | * as far as the block layer is concerned the command completed | ||
1180 | * successfully. Since this is a REQ_BLOCK_PC command the | ||
1181 | * caller should check the request's errors value | ||
1182 | */ | ||
1183 | scsi_io_completion(cmd, cmd->request_bufflen); | ||
1184 | } | ||
1185 | |||
1173 | int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req) | 1186 | int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req) |
1174 | { | 1187 | { |
1175 | struct scsi_cmnd *cmd; | 1188 | struct scsi_cmnd *cmd; |
@@ -1219,6 +1232,7 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req) | |||
1219 | cmd->transfersize = req->data_len; | 1232 | cmd->transfersize = req->data_len; |
1220 | cmd->allowed = req->retries; | 1233 | cmd->allowed = req->retries; |
1221 | cmd->timeout_per_command = req->timeout; | 1234 | cmd->timeout_per_command = req->timeout; |
1235 | cmd->done = scsi_blk_pc_done; | ||
1222 | return BLKPREP_OK; | 1236 | return BLKPREP_OK; |
1223 | } | 1237 | } |
1224 | EXPORT_SYMBOL(scsi_setup_blk_pc_cmnd); | 1238 | EXPORT_SYMBOL(scsi_setup_blk_pc_cmnd); |
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h index eff005951895..ee8efe849bf4 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h | |||
@@ -68,7 +68,6 @@ extern int scsi_maybe_unblock_host(struct scsi_device *sdev); | |||
68 | extern void scsi_device_unbusy(struct scsi_device *sdev); | 68 | extern void scsi_device_unbusy(struct scsi_device *sdev); |
69 | extern int scsi_queue_insert(struct scsi_cmnd *cmd, int reason); | 69 | extern int scsi_queue_insert(struct scsi_cmnd *cmd, int reason); |
70 | extern void scsi_next_command(struct scsi_cmnd *cmd); | 70 | extern void scsi_next_command(struct scsi_cmnd *cmd); |
71 | extern void scsi_io_completion(struct scsi_cmnd *, unsigned int); | ||
72 | extern void scsi_run_host_queues(struct Scsi_Host *shost); | 71 | extern void scsi_run_host_queues(struct Scsi_Host *shost); |
73 | extern struct request_queue *scsi_alloc_queue(struct scsi_device *sdev); | 72 | extern struct request_queue *scsi_alloc_queue(struct scsi_device *sdev); |
74 | extern void scsi_free_queue(struct request_queue *q); | 73 | extern void scsi_free_queue(struct request_queue *q); |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index a69b155f39a2..cb85296d5384 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -86,19 +86,6 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_DISK); | |||
86 | MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD); | 86 | MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD); |
87 | MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC); | 87 | MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC); |
88 | 88 | ||
89 | static int sd_revalidate_disk(struct gendisk *); | ||
90 | static int sd_probe(struct device *); | ||
91 | static int sd_remove(struct device *); | ||
92 | static void sd_shutdown(struct device *); | ||
93 | static int sd_suspend(struct device *, pm_message_t state); | ||
94 | static int sd_resume(struct device *); | ||
95 | static void sd_rescan(struct device *); | ||
96 | static int sd_done(struct scsi_cmnd *); | ||
97 | static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer); | ||
98 | static void scsi_disk_release(struct class_device *cdev); | ||
99 | static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); | ||
100 | static void sd_print_result(struct scsi_disk *, int); | ||
101 | |||
102 | static DEFINE_IDR(sd_index_idr); | 89 | static DEFINE_IDR(sd_index_idr); |
103 | static DEFINE_SPINLOCK(sd_index_lock); | 90 | static DEFINE_SPINLOCK(sd_index_lock); |
104 | 91 | ||
@@ -253,7 +240,6 @@ static struct scsi_driver sd_template = { | |||
253 | .shutdown = sd_shutdown, | 240 | .shutdown = sd_shutdown, |
254 | }, | 241 | }, |
255 | .rescan = sd_rescan, | 242 | .rescan = sd_rescan, |
256 | .done = sd_done, | ||
257 | }; | 243 | }; |
258 | 244 | ||
259 | /* | 245 | /* |
@@ -523,6 +509,12 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) | |||
523 | SCpnt->timeout_per_command = timeout; | 509 | SCpnt->timeout_per_command = timeout; |
524 | 510 | ||
525 | /* | 511 | /* |
512 | * This is the completion routine we use. This is matched in terms | ||
513 | * of capability to this function. | ||
514 | */ | ||
515 | SCpnt->done = sd_rw_intr; | ||
516 | |||
517 | /* | ||
526 | * This indicates that the command is ready from our end to be | 518 | * This indicates that the command is ready from our end to be |
527 | * queued. | 519 | * queued. |
528 | */ | 520 | */ |
@@ -895,13 +887,13 @@ static struct block_device_operations sd_fops = { | |||
895 | }; | 887 | }; |
896 | 888 | ||
897 | /** | 889 | /** |
898 | * sd_done - bottom half handler: called when the lower level | 890 | * sd_rw_intr - bottom half handler: called when the lower level |
899 | * driver has completed (successfully or otherwise) a scsi command. | 891 | * driver has completed (successfully or otherwise) a scsi command. |
900 | * @SCpnt: mid-level's per command structure. | 892 | * @SCpnt: mid-level's per command structure. |
901 | * | 893 | * |
902 | * Note: potentially run from within an ISR. Must not block. | 894 | * Note: potentially run from within an ISR. Must not block. |
903 | **/ | 895 | **/ |
904 | static int sd_done(struct scsi_cmnd *SCpnt) | 896 | static void sd_rw_intr(struct scsi_cmnd * SCpnt) |
905 | { | 897 | { |
906 | int result = SCpnt->result; | 898 | int result = SCpnt->result; |
907 | unsigned int xfer_size = SCpnt->request_bufflen; | 899 | unsigned int xfer_size = SCpnt->request_bufflen; |
@@ -922,7 +914,7 @@ static int sd_done(struct scsi_cmnd *SCpnt) | |||
922 | SCSI_LOG_HLCOMPLETE(1, scsi_print_result(SCpnt)); | 914 | SCSI_LOG_HLCOMPLETE(1, scsi_print_result(SCpnt)); |
923 | if (sense_valid) { | 915 | if (sense_valid) { |
924 | SCSI_LOG_HLCOMPLETE(1, scmd_printk(KERN_INFO, SCpnt, | 916 | SCSI_LOG_HLCOMPLETE(1, scmd_printk(KERN_INFO, SCpnt, |
925 | "sd_done: sb[respc,sk,asc," | 917 | "sd_rw_intr: sb[respc,sk,asc," |
926 | "ascq]=%x,%x,%x,%x\n", | 918 | "ascq]=%x,%x,%x,%x\n", |
927 | sshdr.response_code, | 919 | sshdr.response_code, |
928 | sshdr.sense_key, sshdr.asc, | 920 | sshdr.sense_key, sshdr.asc, |
@@ -994,7 +986,7 @@ static int sd_done(struct scsi_cmnd *SCpnt) | |||
994 | break; | 986 | break; |
995 | } | 987 | } |
996 | out: | 988 | out: |
997 | return good_bytes; | 989 | scsi_io_completion(SCpnt, good_bytes); |
998 | } | 990 | } |
999 | 991 | ||
1000 | static int media_not_present(struct scsi_disk *sdkp, | 992 | static int media_not_present(struct scsi_disk *sdkp, |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index c61999031141..a0c4e13d4dab 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -78,7 +78,6 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_WORM); | |||
78 | 78 | ||
79 | static int sr_probe(struct device *); | 79 | static int sr_probe(struct device *); |
80 | static int sr_remove(struct device *); | 80 | static int sr_remove(struct device *); |
81 | static int sr_done(struct scsi_cmnd *); | ||
82 | 81 | ||
83 | static struct scsi_driver sr_template = { | 82 | static struct scsi_driver sr_template = { |
84 | .owner = THIS_MODULE, | 83 | .owner = THIS_MODULE, |
@@ -87,7 +86,6 @@ static struct scsi_driver sr_template = { | |||
87 | .probe = sr_probe, | 86 | .probe = sr_probe, |
88 | .remove = sr_remove, | 87 | .remove = sr_remove, |
89 | }, | 88 | }, |
90 | .done = sr_done, | ||
91 | }; | 89 | }; |
92 | 90 | ||
93 | static unsigned long sr_index_bits[SR_DISKS / BITS_PER_LONG]; | 91 | static unsigned long sr_index_bits[SR_DISKS / BITS_PER_LONG]; |
@@ -210,12 +208,12 @@ static int sr_media_change(struct cdrom_device_info *cdi, int slot) | |||
210 | } | 208 | } |
211 | 209 | ||
212 | /* | 210 | /* |
213 | * sr_done is the interrupt routine for the device driver. | 211 | * rw_intr is the interrupt routine for the device driver. |
214 | * | 212 | * |
215 | * It will be notified on the end of a SCSI read / write, and will take one | 213 | * It will be notified on the end of a SCSI read / write, and will take on |
216 | * of several actions based on success or failure. | 214 | * of several actions based on success or failure. |
217 | */ | 215 | */ |
218 | static int sr_done(struct scsi_cmnd *SCpnt) | 216 | static void rw_intr(struct scsi_cmnd * SCpnt) |
219 | { | 217 | { |
220 | int result = SCpnt->result; | 218 | int result = SCpnt->result; |
221 | int this_count = SCpnt->request_bufflen; | 219 | int this_count = SCpnt->request_bufflen; |
@@ -288,7 +286,12 @@ static int sr_done(struct scsi_cmnd *SCpnt) | |||
288 | } | 286 | } |
289 | } | 287 | } |
290 | 288 | ||
291 | return good_bytes; | 289 | /* |
290 | * This calls the generic completion function, now that we know | ||
291 | * how many actual sectors finished, and how many sectors we need | ||
292 | * to say have failed. | ||
293 | */ | ||
294 | scsi_io_completion(SCpnt, good_bytes); | ||
292 | } | 295 | } |
293 | 296 | ||
294 | static int sr_prep_fn(struct request_queue *q, struct request *rq) | 297 | static int sr_prep_fn(struct request_queue *q, struct request *rq) |
@@ -425,6 +428,12 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq) | |||
425 | SCpnt->timeout_per_command = timeout; | 428 | SCpnt->timeout_per_command = timeout; |
426 | 429 | ||
427 | /* | 430 | /* |
431 | * This is the completion routine we use. This is matched in terms | ||
432 | * of capability to this function. | ||
433 | */ | ||
434 | SCpnt->done = rw_intr; | ||
435 | |||
436 | /* | ||
428 | * This indicates that the command is ready from our end to be | 437 | * This indicates that the command is ready from our end to be |
429 | * queued. | 438 | * queued. |
430 | */ | 439 | */ |