Skip to content

Commit 12f3eef

Browse files
johnpgarrymartinkpetersen
authored andcommitted
scsi: scsi_debug: Use scsi_host_busy() in delay_store() and ndelay_store()
The functions to update ndelay and delay value first check whether we have any in-flight IO for any host. It does this by checking if any tag is used in the global submit queues. We can achieve the same by setting the host as blocked and then ensuring that we have no in-flight commands with scsi_host_busy(). Note that scsi_host_busy() checks SCMD_STATE_INFLIGHT flag, which is only set per command after we ensure that the host is not blocked, i.e. we see more commands active after the check for scsi_host_busy() returns 0. Signed-off-by: John Garry <john.g.garry@oracle.com> Link: https://lore.kernel.org/r/20230327074310.1862889-10-john.g.garry@oracle.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 9c559c9 commit 12f3eef

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

drivers/scsi/scsi_debug.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6062,16 +6062,15 @@ static ssize_t delay_store(struct device_driver *ddp, const char *buf,
60626062
if (count > 0 && sscanf(buf, "%d", &jdelay) == 1) {
60636063
res = count;
60646064
if (sdebug_jdelay != jdelay) {
6065-
int j, k;
6066-
struct sdebug_queue *sqp;
6065+
struct sdebug_host_info *sdhp;
60676066

60686067
mutex_lock(&sdebug_host_list_mutex);
60696068
block_unblock_all_queues(true);
6070-
for (j = 0, sqp = sdebug_q_arr; j < submit_queues;
6071-
++j, ++sqp) {
6072-
k = find_first_bit(sqp->in_use_bm,
6073-
sdebug_max_queue);
6074-
if (k != sdebug_max_queue) {
6069+
6070+
list_for_each_entry(sdhp, &sdebug_host_list, host_list) {
6071+
struct Scsi_Host *shost = sdhp->shost;
6072+
6073+
if (scsi_host_busy(shost)) {
60756074
res = -EBUSY; /* queued commands */
60766075
break;
60776076
}
@@ -6104,20 +6103,20 @@ static ssize_t ndelay_store(struct device_driver *ddp, const char *buf,
61046103
(ndelay >= 0) && (ndelay < (1000 * 1000 * 1000))) {
61056104
res = count;
61066105
if (sdebug_ndelay != ndelay) {
6107-
int j, k;
6108-
struct sdebug_queue *sqp;
6106+
struct sdebug_host_info *sdhp;
61096107

61106108
mutex_lock(&sdebug_host_list_mutex);
61116109
block_unblock_all_queues(true);
6112-
for (j = 0, sqp = sdebug_q_arr; j < submit_queues;
6113-
++j, ++sqp) {
6114-
k = find_first_bit(sqp->in_use_bm,
6115-
sdebug_max_queue);
6116-
if (k != sdebug_max_queue) {
6110+
6111+
list_for_each_entry(sdhp, &sdebug_host_list, host_list) {
6112+
struct Scsi_Host *shost = sdhp->shost;
6113+
6114+
if (scsi_host_busy(shost)) {
61176115
res = -EBUSY; /* queued commands */
61186116
break;
61196117
}
61206118
}
6119+
61216120
if (res > 0) {
61226121
sdebug_ndelay = ndelay;
61236122
sdebug_jdelay = ndelay ? JDELAY_OVERRIDDEN

0 commit comments

Comments
 (0)