Skip to content

Commit d772a65

Browse files
Ming Leimartinkpetersen
authored andcommitted
Revert "scsi: core: avoid host-wide host_busy counter for scsi_mq"
This reverts commit 3287286. There is fundamental issue in commit 3287286 (scsi: core: avoid host-wide host_busy counter for scsi_mq) because SCSI's host busy counter may not be same with counter of blk-mq's inflight tags, especially in case of none io scheduler. We may switch to other approach for addressing this scsi_mq's performance issue, such as percpu counter or kind of ways, so revert this commit first for fixing this kind of issue in EH path, as reported by Jens. Cc: Omar Sandoval <[email protected]>, Cc: "Martin K. Petersen" <[email protected]>, Cc: James Bottomley <[email protected]>, Cc: Christoph Hellwig <[email protected]>, Cc: Don Brace <[email protected]> Cc: Kashyap Desai <[email protected]> Cc: Mike Snitzer <[email protected]> Cc: Hannes Reinecke <[email protected]> Cc: Laurence Oberman <[email protected]> Cc: Bart Van Assche <[email protected]> Cc: Jens Axboe <[email protected]> Reported-by: Jens Axboe <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 23aa8e6 commit d772a65

File tree

2 files changed

+7
-40
lines changed

2 files changed

+7
-40
lines changed

drivers/scsi/hosts.c

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -563,35 +563,13 @@ struct Scsi_Host *scsi_host_get(struct Scsi_Host *shost)
563563
}
564564
EXPORT_SYMBOL(scsi_host_get);
565565

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-
579566
/**
580567
* scsi_host_busy - Return the host busy counter
581568
* @shost: Pointer to Scsi_Host to inc.
582569
**/
583570
int scsi_host_busy(struct Scsi_Host *shost)
584571
{
585-
struct scsi_host_mq_in_flight in_flight = {
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;
572+
return atomic_read(&shost->host_busy);
595573
}
596574
EXPORT_SYMBOL(scsi_host_busy);
597575

drivers/scsi/scsi_lib.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,7 @@ static void scsi_dec_host_busy(struct Scsi_Host *shost)
345345
unsigned long flags;
346346

347347
rcu_read_lock();
348-
if (!shost->use_blk_mq)
349-
atomic_dec(&shost->host_busy);
348+
atomic_dec(&shost->host_busy);
350349
if (unlikely(scsi_host_in_recovery(shost))) {
351350
spin_lock_irqsave(shost->host_lock, flags);
352351
if (shost->host_failed || shost->host_eh_scheduled)
@@ -445,12 +444,7 @@ static inline bool scsi_target_is_busy(struct scsi_target *starget)
445444

446445
static inline bool scsi_host_is_busy(struct Scsi_Host *shost)
447446
{
448-
/*
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 &&
447+
if (shost->can_queue > 0 &&
454448
atomic_read(&shost->host_busy) >= shost->can_queue)
455449
return true;
456450
if (atomic_read(&shost->host_blocked) > 0)
@@ -1606,12 +1600,9 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
16061600
if (scsi_host_in_recovery(shost))
16071601
return 0;
16081602

1609-
if (!shost->use_blk_mq)
1610-
busy = atomic_inc_return(&shost->host_busy) - 1;
1611-
else
1612-
busy = 0;
1603+
busy = atomic_inc_return(&shost->host_busy) - 1;
16131604
if (atomic_read(&shost->host_blocked) > 0) {
1614-
if (busy || scsi_host_busy(shost))
1605+
if (busy)
16151606
goto starved;
16161607

16171608
/*
@@ -1625,7 +1616,7 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
16251616
"unblocking host at zero depth\n"));
16261617
}
16271618

1628-
if (!shost->use_blk_mq && shost->can_queue > 0 && busy >= shost->can_queue)
1619+
if (shost->can_queue > 0 && busy >= shost->can_queue)
16291620
goto starved;
16301621
if (shost->host_self_blocked)
16311622
goto starved;
@@ -1711,9 +1702,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
17111702
* with the locks as normal issue path does.
17121703
*/
17131704
atomic_inc(&sdev->device_busy);
1714-
1715-
if (!shost->use_blk_mq)
1716-
atomic_inc(&shost->host_busy);
1705+
atomic_inc(&shost->host_busy);
17171706
if (starget->can_queue > 0)
17181707
atomic_inc(&starget->target_busy);
17191708

0 commit comments

Comments
 (0)