Skip to content

Commit

Permalink
[SCSI] avoid useless free_list lock roundtrips
Browse files Browse the repository at this point in the history
Avoid hitting the host-wide free_list lock unless we need to put a command
back onto the freelist.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
  • Loading branch information
Christoph Hellwig authored and James Bottomley committed Mar 15, 2014
1 parent df03c3f commit 44b93b5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/scsi/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,14 @@ void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd,
{
unsigned long flags;

/* changing locks here, don't need to restore the irq state */
spin_lock_irqsave(&shost->free_list_lock, flags);
if (unlikely(list_empty(&shost->free_list))) {
list_add(&cmd->list, &shost->free_list);
cmd = NULL;
spin_lock_irqsave(&shost->free_list_lock, flags);
if (list_empty(&shost->free_list)) {
list_add(&cmd->list, &shost->free_list);
cmd = NULL;
}
spin_unlock_irqrestore(&shost->free_list_lock, flags);
}
spin_unlock_irqrestore(&shost->free_list_lock, flags);

if (likely(cmd != NULL))
scsi_pool_free_command(shost->cmd_pool, cmd);
Expand Down

0 comments on commit 44b93b5

Please sign in to comment.