scsi: convert target_busy to an atomic_t

Avoid taking the host-wide host_lock to check the per-target queue limit.
Instead we do an atomic_inc_return early on to grab our slot in the queue,
and if necessary decrement it after finishing all checks.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Martin K. Petersen <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Reviewed-by: Webb Scales <[email protected]>
Acked-by: Jens Axboe <[email protected]>
Tested-by: Bart Van Assche <[email protected]>
Tested-by: Robert Elliott <[email protected]>
This commit is contained in:
Christoph Hellwig 2014-01-22 14:49:41 +01:00
commit 7ae65c0f96
2 changed files with 34 additions and 23 deletions

View file

@ -291,8 +291,8 @@ struct scsi_target {
unsigned int expecting_lun_change:1; /* A device has reported
* a 3F/0E UA, other devices on
* the same target will also. */
/* commands actually active on LLD. protected by host lock. */
unsigned int target_busy;
/* commands actually active on LLD. */
atomic_t target_busy;
/*
* LLDs should set this in the slave_alloc host template callout.
* If set to zero then there is not limit.