On 6.3.2017 22:24, Don Brace wrote:
> avoid rescan storms. No need to queue another
> if one is pending.
>
> Reviewed-by: Scott Benesh <[email protected]>
> Reviewed-by: Scott Teel <[email protected]>
> Signed-off-by: Don Brace <[email protected]>
> ---
> drivers/scsi/hpsa.c | 16 +++++++++++++++-
> drivers/scsi/hpsa.h | 1 +
> 2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 1adc4ec..a36d3a6 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -5558,7 +5558,7 @@ static void hpsa_scan_complete(struct ctlr_info *h)
>
> spin_lock_irqsave(&h->scan_lock, flags);
> h->scan_finished = 1;
> - wake_up_all(&h->scan_wait_queue);
> + wake_up(&h->scan_wait_queue);
> spin_unlock_irqrestore(&h->scan_lock, flags);
> }
>
> @@ -5576,11 +5576,23 @@ static void hpsa_scan_start(struct Scsi_Host *sh)
> if (unlikely(lockup_detected(h)))
> return hpsa_scan_complete(h);
>
> + /*
> + * If a scan is alreay waiting to run, no need to add another
> + */
> + spin_lock_irqsave(&h->scan_lock, flags);
> + if (h->scan_waiting) {
> + spin_unlock_irqrestore(&h->scan_lock, flags);
> + return;
> + }
> +
> + spin_unlock_irqrestore(&h->scan_lock, flags);
> +
> /* wait until any scan already in progress is finished. */
> while (1) {
> spin_lock_irqsave(&h->scan_lock, flags);
Placing the test to this place would save few lines
+ if (h->scan_waiting) {
+ spin_unlock_irqrestore(&h->scan_lock, flags);
+ return
but I agree with your version too.
Reviewed-by: Tomas Henzl <[email protected]>
tomash