diff options
author | Christoph Hellwig <hch@lst.de> | 2014-06-25 16:45:56 -0600 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-04-02 12:12:25 -0600 |
commit | eca7d8545507e54bd3266f86421c34fa0e544cc0 (patch) | |
tree | 6d76d9c206bec3fe3391d604763e995c600762b1 | |
parent | 464745769496b0514e3f4a767744a9b2f639e492 (diff) |
avoid useless free_list lock roundtrips
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>
-rw-r--r-- | drivers/scsi/scsi.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index eaa808e6ba91..20feb8291b6c 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -324,13 +324,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); |