scsi: scsi-mq: Always unprepare before requeuing a request

One of the two scsi-mq functions that requeue a request unprepares a
request before requeueing (scsi_io_completion()) but the other function
not (__scsi_queue_insert()). Make sure that a request is unprepared
before requeuing it.

Fixes: commit d285203cf647 ("scsi: add support for a blk-mq based I/O path.")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
a45a1f36 cad8cf20

+8 -2
+8 -2
drivers/scsi/scsi_lib.c
··· 44 44 static struct kmem_cache *scsi_sense_isadma_cache; 45 45 static DEFINE_MUTEX(scsi_sense_cache_mutex); 46 46 47 + static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd); 48 + 47 49 static inline struct kmem_cache * 48 50 scsi_select_sense_cache(bool unchecked_isa_dma) 49 51 { ··· 142 140 { 143 141 struct scsi_device *sdev = cmd->device; 144 142 143 + if (cmd->request->rq_flags & RQF_DONTPREP) { 144 + cmd->request->rq_flags &= ~RQF_DONTPREP; 145 + scsi_mq_uninit_cmd(cmd); 146 + } else { 147 + WARN_ON_ONCE(true); 148 + } 145 149 blk_mq_requeue_request(cmd->request, true); 146 150 put_device(&sdev->sdev_gendev); 147 151 } ··· 990 982 * A new command will be prepared and issued. 991 983 */ 992 984 if (q->mq_ops) { 993 - cmd->request->rq_flags &= ~RQF_DONTPREP; 994 - scsi_mq_uninit_cmd(cmd); 995 985 scsi_mq_requeue_cmd(cmd); 996 986 } else { 997 987 scsi_release_buffers(cmd);