aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r--drivers/scsi/sd.c48
1 files changed, 16 insertions, 32 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index efcbcd182863..321faf603035 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -109,6 +109,8 @@ static int sd_suspend_system(struct device *);
109static int sd_suspend_runtime(struct device *); 109static int sd_suspend_runtime(struct device *);
110static int sd_resume(struct device *); 110static int sd_resume(struct device *);
111static void sd_rescan(struct device *); 111static void sd_rescan(struct device *);
112static int sd_init_command(struct scsi_cmnd *SCpnt);
113static void sd_uninit_command(struct scsi_cmnd *SCpnt);
112static int sd_done(struct scsi_cmnd *); 114static int sd_done(struct scsi_cmnd *);
113static int sd_eh_action(struct scsi_cmnd *, int); 115static int sd_eh_action(struct scsi_cmnd *, int);
114static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer); 116static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
@@ -503,6 +505,8 @@ static struct scsi_driver sd_template = {
503 .pm = &sd_pm_ops, 505 .pm = &sd_pm_ops,
504 }, 506 },
505 .rescan = sd_rescan, 507 .rescan = sd_rescan,
508 .init_command = sd_init_command,
509 .uninit_command = sd_uninit_command,
506 .done = sd_done, 510 .done = sd_done,
507 .eh_action = sd_eh_action, 511 .eh_action = sd_eh_action,
508}; 512};
@@ -838,9 +842,9 @@ static int scsi_setup_flush_cmnd(struct scsi_device *sdp, struct request *rq)
838 return scsi_setup_blk_pc_cmnd(sdp, rq); 842 return scsi_setup_blk_pc_cmnd(sdp, rq);
839} 843}
840 844
841static void sd_unprep_fn(struct request_queue *q, struct request *rq) 845static void sd_uninit_command(struct scsi_cmnd *SCpnt)
842{ 846{
843 struct scsi_cmnd *SCpnt = rq->special; 847 struct request *rq = SCpnt->request;
844 848
845 if (rq->cmd_flags & REQ_DISCARD) { 849 if (rq->cmd_flags & REQ_DISCARD) {
846 free_page((unsigned long)rq->buffer); 850 free_page((unsigned long)rq->buffer);
@@ -853,18 +857,10 @@ static void sd_unprep_fn(struct request_queue *q, struct request *rq)
853 } 857 }
854} 858}
855 859
856/** 860static int sd_init_command(struct scsi_cmnd *SCpnt)
857 * sd_prep_fn - build a scsi (read or write) command from
858 * information in the request structure.
859 * @SCpnt: pointer to mid-level's per scsi command structure that
860 * contains request and into which the scsi command is written
861 *
862 * Returns 1 if successful and 0 if error (or cannot be done now).
863 **/
864static int sd_prep_fn(struct request_queue *q, struct request *rq)
865{ 861{
866 struct scsi_cmnd *SCpnt; 862 struct request *rq = SCpnt->request;
867 struct scsi_device *sdp = q->queuedata; 863 struct scsi_device *sdp = SCpnt->device;
868 struct gendisk *disk = rq->rq_disk; 864 struct gendisk *disk = rq->rq_disk;
869 struct scsi_disk *sdkp; 865 struct scsi_disk *sdkp;
870 sector_t block = blk_rq_pos(rq); 866 sector_t block = blk_rq_pos(rq);
@@ -886,12 +882,6 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
886 } else if (rq->cmd_flags & REQ_FLUSH) { 882 } else if (rq->cmd_flags & REQ_FLUSH) {
887 ret = scsi_setup_flush_cmnd(sdp, rq); 883 ret = scsi_setup_flush_cmnd(sdp, rq);
888 goto out; 884 goto out;
889 } else if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
890 ret = scsi_setup_blk_pc_cmnd(sdp, rq);
891 goto out;
892 } else if (rq->cmd_type != REQ_TYPE_FS) {
893 ret = BLKPREP_KILL;
894 goto out;
895 } 885 }
896 ret = scsi_setup_fs_cmnd(sdp, rq); 886 ret = scsi_setup_fs_cmnd(sdp, rq);
897 if (ret != BLKPREP_OK) 887 if (ret != BLKPREP_OK)
@@ -903,11 +893,10 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
903 * is used for a killable error condition */ 893 * is used for a killable error condition */
904 ret = BLKPREP_KILL; 894 ret = BLKPREP_KILL;
905 895
906 SCSI_LOG_HLQUEUE(1, scmd_printk(KERN_INFO, SCpnt, 896 SCSI_LOG_HLQUEUE(1,
907 "sd_prep_fn: block=%llu, " 897 scmd_printk(KERN_INFO, SCpnt,
908 "count=%d\n", 898 "%s: block=%llu, count=%d\n",
909 (unsigned long long)block, 899 __func__, (unsigned long long)block, this_count));
910 this_count));
911 900
912 if (!sdp || !scsi_device_online(sdp) || 901 if (!sdp || !scsi_device_online(sdp) ||
913 block + blk_rq_sectors(rq) > get_capacity(disk)) { 902 block + blk_rq_sectors(rq) > get_capacity(disk)) {
@@ -1127,7 +1116,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
1127 */ 1116 */
1128 ret = BLKPREP_OK; 1117 ret = BLKPREP_OK;
1129 out: 1118 out:
1130 return scsi_prep_return(q, rq, ret); 1119 return ret;
1131} 1120}
1132 1121
1133/** 1122/**
@@ -1689,12 +1678,12 @@ static int sd_done(struct scsi_cmnd *SCpnt)
1689 sshdr.ascq)); 1678 sshdr.ascq));
1690 } 1679 }
1691#endif 1680#endif
1681 sdkp->medium_access_timed_out = 0;
1682
1692 if (driver_byte(result) != DRIVER_SENSE && 1683 if (driver_byte(result) != DRIVER_SENSE &&
1693 (!sense_valid || sense_deferred)) 1684 (!sense_valid || sense_deferred))
1694 goto out; 1685 goto out;
1695 1686
1696 sdkp->medium_access_timed_out = 0;
1697
1698 switch (sshdr.sense_key) { 1687 switch (sshdr.sense_key) {
1699 case HARDWARE_ERROR: 1688 case HARDWARE_ERROR:
1700 case MEDIUM_ERROR: 1689 case MEDIUM_ERROR:
@@ -2878,9 +2867,6 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
2878 2867
2879 sd_revalidate_disk(gd); 2868 sd_revalidate_disk(gd);
2880 2869
2881 blk_queue_prep_rq(sdp->request_queue, sd_prep_fn);
2882 blk_queue_unprep_rq(sdp->request_queue, sd_unprep_fn);
2883
2884 gd->driverfs_dev = &sdp->sdev_gendev; 2870 gd->driverfs_dev = &sdp->sdev_gendev;
2885 gd->flags = GENHD_FL_EXT_DEVT; 2871 gd->flags = GENHD_FL_EXT_DEVT;
2886 if (sdp->removable) { 2872 if (sdp->removable) {
@@ -3028,8 +3014,6 @@ static int sd_remove(struct device *dev)
3028 3014
3029 async_synchronize_full_domain(&scsi_sd_pm_domain); 3015 async_synchronize_full_domain(&scsi_sd_pm_domain);
3030 async_synchronize_full_domain(&scsi_sd_probe_domain); 3016 async_synchronize_full_domain(&scsi_sd_probe_domain);
3031 blk_queue_prep_rq(sdkp->device->request_queue, scsi_prep_fn);
3032 blk_queue_unprep_rq(sdkp->device->request_queue, NULL);
3033 device_del(&sdkp->dev); 3017 device_del(&sdkp->dev);
3034 del_gendisk(sdkp->disk); 3018 del_gendisk(sdkp->disk);
3035 sd_shutdown(dev); 3019 sd_shutdown(dev);