Commit cd464d838041b3a69464c0dd3938c1f912487bd3

Authored by Bart Van Assche
Committed by Martin K. Petersen
1 parent cf64e5a5f6

scsi: core: Remove an atomic instruction from the hot path

From scsi_init_command(), a function called by scsi_mq_prep_fn():

	/* zero out the cmd, except for the embedded scsi_request */
	memset((char *)cmd + sizeof(cmd->req), 0,
		sizeof(*cmd) - sizeof(cmd->req) + dev->host->hostt->cmd_size);

In other words, scsi_mq_prep_fn() clears scsi_cmnd.flags. Hence move the
clear_bit() call into the else branch, the only branch in which this code
is necessary.

See also commit f1342709d18a ("scsi: Do not rely on blk-mq for double
completions").

Cc: Keith Busch <keith.busch@intel.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

drivers/scsi/scsi_lib.c
... ... @@ -1712,13 +1712,13 @@
1712 1712 if (!scsi_host_queue_ready(q, shost, sdev))
1713 1713 goto out_dec_target_busy;
1714 1714  
1715   - clear_bit(SCMD_STATE_COMPLETE, &cmd->state);
1716 1715 if (!(req->rq_flags & RQF_DONTPREP)) {
1717 1716 ret = scsi_mq_prep_fn(req);
1718 1717 if (ret != BLK_STS_OK)
1719 1718 goto out_dec_host_busy;
1720 1719 req->rq_flags |= RQF_DONTPREP;
1721 1720 } else {
  1721 + clear_bit(SCMD_STATE_COMPLETE, &cmd->state);
1722 1722 blk_mq_start_request(req);
1723 1723 }
1724 1724