if (sreq->sr_magic == SCSI_REQ_MAGIC) {
cmd = scsi_get_command(sreq->sr_device, GFP_ATOMIC);
if (unlikely(!cmd))
- return BLKPREP_DEFER;
+ goto defer;
scsi_init_cmd_from_req(cmd, sreq);
} else
cmd = req->special;
if (!req->special) {
cmd = scsi_get_command(sdev, GFP_ATOMIC);
if (unlikely(!cmd))
- return BLKPREP_DEFER;
+ goto defer;
} else
cmd = req->special;
*/
req->flags |= REQ_DONTPREP;
return BLKPREP_OK;
+
+ defer:
+ /* If we defer, the elv_next_request() returns NULL, but the
+ * queue must be restarted, so we plug here if no returning
+ * command will automatically do that. */
+ if (sdev->device_busy == 0)
+ blk_plug_device(q);
+ return BLKPREP_DEFER;
}
/*
*/
req = elv_next_request(q);
- if (!req) {
- /*
- * If the device is busy, a returning I/O will
- * restart the queue. Otherwise, we have to plug
- * the queue
- */
- if (sdev->device_busy == 0)
- blk_plug_device(q);
+ if (!req)
goto completed;
- }
if (!scsi_dev_queue_ready(q, sdev))
goto completed;