aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/scsi_lib.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 4bfe0df35823..6085377643ae 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1112,9 +1112,13 @@ err_exit:
1112EXPORT_SYMBOL(scsi_init_io); 1112EXPORT_SYMBOL(scsi_init_io);
1113 1113
1114/** 1114/**
1115 * scsi_initialize_rq - initialize struct scsi_cmnd.req 1115 * scsi_initialize_rq - initialize struct scsi_cmnd partially
1116 * @rq: Request associated with the SCSI command to be initialized. 1116 * @rq: Request associated with the SCSI command to be initialized.
1117 * 1117 *
1118 * This function initializes the members of struct scsi_cmnd that must be
1119 * initialized before request processing starts and that won't be
1120 * reinitialized if a SCSI command is requeued.
1121 *
1118 * Called from inside blk_get_request() for pass-through requests and from 1122 * Called from inside blk_get_request() for pass-through requests and from
1119 * inside scsi_init_command() for filesystem requests. 1123 * inside scsi_init_command() for filesystem requests.
1120 */ 1124 */
@@ -1123,6 +1127,8 @@ void scsi_initialize_rq(struct request *rq)
1123 struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); 1127 struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq);
1124 1128
1125 scsi_req_init(&cmd->req); 1129 scsi_req_init(&cmd->req);
1130 cmd->jiffies_at_alloc = jiffies;
1131 cmd->retries = 0;
1126} 1132}
1127EXPORT_SYMBOL(scsi_initialize_rq); 1133EXPORT_SYMBOL(scsi_initialize_rq);
1128 1134
@@ -1162,12 +1168,16 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd)
1162 void *prot = cmd->prot_sdb; 1168 void *prot = cmd->prot_sdb;
1163 struct request *rq = blk_mq_rq_from_pdu(cmd); 1169 struct request *rq = blk_mq_rq_from_pdu(cmd);
1164 unsigned int flags = cmd->flags & SCMD_PRESERVED_FLAGS; 1170 unsigned int flags = cmd->flags & SCMD_PRESERVED_FLAGS;
1171 unsigned long jiffies_at_alloc;
1172 int retries;
1165 1173
1166 if (!blk_rq_is_scsi(rq) && !(flags & SCMD_INITIALIZED)) { 1174 if (!blk_rq_is_scsi(rq) && !(flags & SCMD_INITIALIZED)) {
1167 flags |= SCMD_INITIALIZED; 1175 flags |= SCMD_INITIALIZED;
1168 scsi_initialize_rq(rq); 1176 scsi_initialize_rq(rq);
1169 } 1177 }
1170 1178
1179 jiffies_at_alloc = cmd->jiffies_at_alloc;
1180 retries = cmd->retries;
1171 /* zero out the cmd, except for the embedded scsi_request */ 1181 /* zero out the cmd, except for the embedded scsi_request */
1172 memset((char *)cmd + sizeof(cmd->req), 0, 1182 memset((char *)cmd + sizeof(cmd->req), 0,
1173 sizeof(*cmd) - sizeof(cmd->req) + dev->host->hostt->cmd_size); 1183 sizeof(*cmd) - sizeof(cmd->req) + dev->host->hostt->cmd_size);
@@ -1177,7 +1187,8 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd)
1177 cmd->prot_sdb = prot; 1187 cmd->prot_sdb = prot;
1178 cmd->flags = flags; 1188 cmd->flags = flags;
1179 INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler); 1189 INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler);
1180 cmd->jiffies_at_alloc = jiffies; 1190 cmd->jiffies_at_alloc = jiffies_at_alloc;
1191 cmd->retries = retries;
1181 1192
1182 scsi_add_cmd_to_list(cmd); 1193 scsi_add_cmd_to_list(cmd);
1183} 1194}