diff options
| -rw-r--r-- | drivers/scsi/hosts.c | 24 | ||||
| -rw-r--r-- | drivers/scsi/scsi_lib.c | 23 |
2 files changed, 7 insertions, 40 deletions
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index f02dcc875a09..ea4b0bb0c1cd 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c | |||
| @@ -563,35 +563,13 @@ struct Scsi_Host *scsi_host_get(struct Scsi_Host *shost) | |||
| 563 | } | 563 | } |
| 564 | EXPORT_SYMBOL(scsi_host_get); | 564 | EXPORT_SYMBOL(scsi_host_get); |
| 565 | 565 | ||
| 566 | struct scsi_host_mq_in_flight { | ||
| 567 | int cnt; | ||
| 568 | }; | ||
| 569 | |||
| 570 | static void scsi_host_check_in_flight(struct request *rq, void *data, | ||
| 571 | bool reserved) | ||
| 572 | { | ||
| 573 | struct scsi_host_mq_in_flight *in_flight = data; | ||
| 574 | |||
| 575 | if (blk_mq_request_started(rq)) | ||
| 576 | in_flight->cnt++; | ||
| 577 | } | ||
| 578 | |||
| 579 | /** | 566 | /** |
| 580 | * scsi_host_busy - Return the host busy counter | 567 | * scsi_host_busy - Return the host busy counter |
| 581 | * @shost: Pointer to Scsi_Host to inc. | 568 | * @shost: Pointer to Scsi_Host to inc. |
| 582 | **/ | 569 | **/ |
| 583 | int scsi_host_busy(struct Scsi_Host *shost) | 570 | int scsi_host_busy(struct Scsi_Host *shost) |
| 584 | { | 571 | { |
| 585 | struct scsi_host_mq_in_flight in_flight = { | 572 | return atomic_read(&shost->host_busy); |
| 586 | .cnt = 0, | ||
| 587 | }; | ||
| 588 | |||
| 589 | if (!shost->use_blk_mq) | ||
| 590 | return atomic_read(&shost->host_busy); | ||
| 591 | |||
| 592 | blk_mq_tagset_busy_iter(&shost->tag_set, scsi_host_check_in_flight, | ||
| 593 | &in_flight); | ||
| 594 | return in_flight.cnt; | ||
| 595 | } | 573 | } |
| 596 | EXPORT_SYMBOL(scsi_host_busy); | 574 | EXPORT_SYMBOL(scsi_host_busy); |
| 597 | 575 | ||
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 1046679f5473..eb97d2dd3651 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
| @@ -345,8 +345,7 @@ static void scsi_dec_host_busy(struct Scsi_Host *shost) | |||
| 345 | unsigned long flags; | 345 | unsigned long flags; |
| 346 | 346 | ||
| 347 | rcu_read_lock(); | 347 | rcu_read_lock(); |
| 348 | if (!shost->use_blk_mq) | 348 | atomic_dec(&shost->host_busy); |
| 349 | atomic_dec(&shost->host_busy); | ||
| 350 | if (unlikely(scsi_host_in_recovery(shost))) { | 349 | if (unlikely(scsi_host_in_recovery(shost))) { |
| 351 | spin_lock_irqsave(shost->host_lock, flags); | 350 | spin_lock_irqsave(shost->host_lock, flags); |
| 352 | if (shost->host_failed || shost->host_eh_scheduled) | 351 | if (shost->host_failed || shost->host_eh_scheduled) |
| @@ -445,12 +444,7 @@ static inline bool scsi_target_is_busy(struct scsi_target *starget) | |||
| 445 | 444 | ||
| 446 | static inline bool scsi_host_is_busy(struct Scsi_Host *shost) | 445 | static inline bool scsi_host_is_busy(struct Scsi_Host *shost) |
| 447 | { | 446 | { |
| 448 | /* | 447 | if (shost->can_queue > 0 && |
| 449 | * blk-mq can handle host queue busy efficiently via host-wide driver | ||
| 450 | * tag allocation | ||
| 451 | */ | ||
| 452 | |||
| 453 | if (!shost->use_blk_mq && shost->can_queue > 0 && | ||
| 454 | atomic_read(&shost->host_busy) >= shost->can_queue) | 448 | atomic_read(&shost->host_busy) >= shost->can_queue) |
| 455 | return true; | 449 | return true; |
| 456 | if (atomic_read(&shost->host_blocked) > 0) | 450 | if (atomic_read(&shost->host_blocked) > 0) |
| @@ -1606,12 +1600,9 @@ static inline int scsi_host_queue_ready(struct request_queue *q, | |||
| 1606 | if (scsi_host_in_recovery(shost)) | 1600 | if (scsi_host_in_recovery(shost)) |
| 1607 | return 0; | 1601 | return 0; |
| 1608 | 1602 | ||
| 1609 | if (!shost->use_blk_mq) | 1603 | busy = atomic_inc_return(&shost->host_busy) - 1; |
| 1610 | busy = atomic_inc_return(&shost->host_busy) - 1; | ||
| 1611 | else | ||
| 1612 | busy = 0; | ||
| 1613 | if (atomic_read(&shost->host_blocked) > 0) { | 1604 | if (atomic_read(&shost->host_blocked) > 0) { |
| 1614 | if (busy || scsi_host_busy(shost)) | 1605 | if (busy) |
| 1615 | goto starved; | 1606 | goto starved; |
| 1616 | 1607 | ||
| 1617 | /* | 1608 | /* |
| @@ -1625,7 +1616,7 @@ static inline int scsi_host_queue_ready(struct request_queue *q, | |||
| 1625 | "unblocking host at zero depth\n")); | 1616 | "unblocking host at zero depth\n")); |
| 1626 | } | 1617 | } |
| 1627 | 1618 | ||
| 1628 | if (!shost->use_blk_mq && shost->can_queue > 0 && busy >= shost->can_queue) | 1619 | if (shost->can_queue > 0 && busy >= shost->can_queue) |
| 1629 | goto starved; | 1620 | goto starved; |
| 1630 | if (shost->host_self_blocked) | 1621 | if (shost->host_self_blocked) |
| 1631 | goto starved; | 1622 | goto starved; |
| @@ -1711,9 +1702,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q) | |||
| 1711 | * with the locks as normal issue path does. | 1702 | * with the locks as normal issue path does. |
| 1712 | */ | 1703 | */ |
| 1713 | atomic_inc(&sdev->device_busy); | 1704 | atomic_inc(&sdev->device_busy); |
| 1714 | 1705 | atomic_inc(&shost->host_busy); | |
| 1715 | if (!shost->use_blk_mq) | ||
| 1716 | atomic_inc(&shost->host_busy); | ||
| 1717 | if (starget->can_queue > 0) | 1706 | if (starget->can_queue > 0) |
| 1718 | atomic_inc(&starget->target_busy); | 1707 | atomic_inc(&starget->target_busy); |
| 1719 | 1708 | ||
