aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_lib.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2014-06-28 05:58:42 -0400
committerChristoph Hellwig <hch@lst.de>2014-07-17 16:11:27 -0400
commit3868cf8ea70a57fc3f927872d8296f287ce4b96a (patch)
treec663a5fa31a457fe4b6597082ae8efbeb381045d /drivers/scsi/scsi_lib.c
parent635d98b1d0cfc2ba3426a701725d31a6102c059a (diff)
scsi: restructure command initialization for TYPE_FS requests
We should call the device handler prep_fn for all TYPE_FS requests, not just simple read/write calls that are handled by the disk driver. Restructure the common I/O code to call the prep_fn handler and zero out the CDB, and just leave the call to scsi_init_io to the ULDs. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de>
Diffstat (limited to 'drivers/scsi/scsi_lib.c')
-rw-r--r--drivers/scsi/scsi_lib.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 150d7bb675a1..2afb96b801cb 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1082,11 +1082,10 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
1082EXPORT_SYMBOL(scsi_setup_blk_pc_cmnd); 1082EXPORT_SYMBOL(scsi_setup_blk_pc_cmnd);
1083 1083
1084/* 1084/*
1085 * Setup a REQ_TYPE_FS command. These are simple read/write request 1085 * Setup a REQ_TYPE_FS command. These are simple request from filesystems
1086 * from filesystems that still need to be translated to SCSI CDBs from 1086 * that still need to be translated to SCSI CDBs from the ULD.
1087 * the ULD.
1088 */ 1087 */
1089int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req) 1088static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
1090{ 1089{
1091 struct scsi_cmnd *cmd = req->special; 1090 struct scsi_cmnd *cmd = req->special;
1092 1091
@@ -1098,9 +1097,8 @@ int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
1098 } 1097 }
1099 1098
1100 memset(cmd->cmnd, 0, BLK_MAX_CDB); 1099 memset(cmd->cmnd, 0, BLK_MAX_CDB);
1101 return scsi_init_io(cmd, GFP_ATOMIC); 1100 return scsi_cmd_to_driver(cmd)->init_command(cmd);
1102} 1101}
1103EXPORT_SYMBOL(scsi_setup_fs_cmnd);
1104 1102
1105static int 1103static int
1106scsi_prep_state_check(struct scsi_device *sdev, struct request *req) 1104scsi_prep_state_check(struct scsi_device *sdev, struct request *req)
@@ -1205,12 +1203,16 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1205 goto out; 1203 goto out;
1206 } 1204 }
1207 1205
1208 if (req->cmd_type == REQ_TYPE_FS) 1206 switch (req->cmd_type) {
1209 ret = scsi_cmd_to_driver(cmd)->init_command(cmd); 1207 case REQ_TYPE_FS:
1210 else if (req->cmd_type == REQ_TYPE_BLOCK_PC) 1208 ret = scsi_setup_fs_cmnd(sdev, req);
1209 break;
1210 case REQ_TYPE_BLOCK_PC:
1211 ret = scsi_setup_blk_pc_cmnd(sdev, req); 1211 ret = scsi_setup_blk_pc_cmnd(sdev, req);
1212 else 1212 break;
1213 default:
1213 ret = BLKPREP_KILL; 1214 ret = BLKPREP_KILL;
1215 }
1214 1216
1215out: 1217out:
1216 return scsi_prep_return(q, req, ret); 1218 return scsi_prep_return(q, req, ret);