scsi: core: Micro-optimize the hot path

Every code path that inserts scmd->eh_entry into a list uses
list_add_tail() (see also scsi_abort_command() and scsi_eh_scmd_add()).
list_add_tail() overwrites the next and prev pointers. Hence, the only code
that depends on the initialization of scmd->eh_entry is the
BUG_ON(!list_empty(&scmd->eh_entry)) statement in scsi_abort_command().

Remove this statement because scsi_timeout() already prevents
scsi_abort_command() from being called twice for the same command by
setting SCMD_STATE_COMPLETE. Remove the scmd->eh_entry initialization
because the only statement that relied on this initialization has been
removed.

Cc: John Garry <john.garry@linux.dev>
Cc: Hannes Reinecke <hare@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: John Garry <john.garry@linux.dev>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Link: https://patch.msgid.link/1ac0d4d0c06e55943e188d0dee9b6f2475715f21.1790359761.git.bvanassche@acm.org
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
This commit is contained in:
Bart Van Assche 2026-09-25 11:09:45 -07:00 committed by Martin K. Petersen (Oracle)
parent 931a0649b9
commit d2398f2e2e
2 changed files with 0 additions and 4 deletions

View File

@ -270,7 +270,6 @@ scsi_abort_command(struct scsi_cmnd *scmd)
spin_lock_irqsave(&shost->host_lock, flags);
if (shost->eh_deadline != -1 && !shost->last_reset)
shost->last_reset = jiffies;
BUG_ON(!list_empty(&scmd->eh_entry));
list_add_tail(&scmd->eh_entry, &shost->eh_abort_list);
spin_unlock_irqrestore(&shost->host_lock, flags);

View File

@ -1322,7 +1322,6 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd)
}
cmd->device = dev;
INIT_LIST_HEAD(&cmd->eh_entry);
INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler);
}
@ -1590,8 +1589,6 @@ static void scsi_complete(struct request *rq)
return;
}
INIT_LIST_HEAD(&cmd->eh_entry);
atomic_inc(&cmd->device->iodone_cnt);
if (cmd->result)
atomic_inc(&cmd->device->ioerr_cnt);