Skip to content

Commit c84b023

Browse files
Ming Leimartinkpetersen
authored andcommitted
scsi: read host_busy via scsi_host_busy()
No functional change. Just introduce scsi_host_busy() and replace the direct read of scsi_host->host_busy with this new API. 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]> Signed-off-by: Ming Lei <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 2b33ab3 commit c84b023

File tree

10 files changed

+26
-15
lines changed

10 files changed

+26
-15
lines changed

drivers/scsi/advansys.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,8 +2416,8 @@ static void asc_prt_scsi_host(struct Scsi_Host *s)
24162416
struct asc_board *boardp = shost_priv(s);
24172417

24182418
printk("Scsi_Host at addr 0x%p, device %s\n", s, dev_name(boardp->dev));
2419-
printk(" host_busy %u, host_no %d,\n",
2420-
atomic_read(&s->host_busy), s->host_no);
2419+
printk(" host_busy %d, host_no %d,\n",
2420+
scsi_host_busy(s), s->host_no);
24212421

24222422
printk(" base 0x%lx, io_port 0x%lx, irq %d,\n",
24232423
(ulong)s->base, (ulong)s->io_port, boardp->irq);
@@ -3182,8 +3182,8 @@ static void asc_prt_driver_conf(struct seq_file *m, struct Scsi_Host *shost)
31823182
shost->host_no);
31833183

31843184
seq_printf(m,
3185-
" host_busy %u, max_id %u, max_lun %llu, max_channel %u\n",
3186-
atomic_read(&shost->host_busy), shost->max_id,
3185+
" host_busy %d, max_id %u, max_lun %llu, max_channel %u\n",
3186+
scsi_host_busy(shost), shost->max_id,
31873187
shost->max_lun, shost->max_channel);
31883188

31893189
seq_printf(m,

drivers/scsi/hosts.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,16 @@ struct Scsi_Host *scsi_host_get(struct Scsi_Host *shost)
563563
}
564564
EXPORT_SYMBOL(scsi_host_get);
565565

566+
/**
567+
* scsi_host_busy - Return the host busy counter
568+
* @shost: Pointer to Scsi_Host to inc.
569+
**/
570+
int scsi_host_busy(struct Scsi_Host *shost)
571+
{
572+
return atomic_read(&shost->host_busy);
573+
}
574+
EXPORT_SYMBOL(scsi_host_busy);
575+
566576
/**
567577
* scsi_host_put - dec a Scsi_Host ref count
568578
* @shost: Pointer to Scsi_Host to dec.

drivers/scsi/libsas/sas_scsi_host.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ void sas_scsi_recover_host(struct Scsi_Host *shost)
759759
spin_unlock_irq(shost->host_lock);
760760

761761
SAS_DPRINTK("Enter %s busy: %d failed: %d\n",
762-
__func__, atomic_read(&shost->host_busy), shost->host_failed);
762+
__func__, scsi_host_busy(shost), shost->host_failed);
763763
/*
764764
* Deal with commands that still have SAS tasks (i.e. they didn't
765765
* complete via the normal sas_task completion mechanism),
@@ -801,7 +801,7 @@ void sas_scsi_recover_host(struct Scsi_Host *shost)
801801
goto retry;
802802

803803
SAS_DPRINTK("--- Exit %s: busy: %d failed: %d tries: %d\n",
804-
__func__, atomic_read(&shost->host_busy),
804+
__func__, scsi_host_busy(shost),
805805
shost->host_failed, tries);
806806
}
807807

drivers/scsi/megaraid/megaraid_sas_base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2834,7 +2834,7 @@ static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
28342834
"SCSI command pointer: (%p)\t SCSI host state: %d\t"
28352835
" SCSI host busy: %d\t FW outstanding: %d\n",
28362836
scmd, scmd->device->host->shost_state,
2837-
atomic_read((atomic_t *)&scmd->device->host->host_busy),
2837+
scsi_host_busy(scmd->device->host),
28382838
atomic_read(&instance->fw_outstanding));
28392839

28402840
/*

drivers/scsi/mpt3sas/mpt3sas_base.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3250,7 +3250,7 @@ _base_recovery_check(struct MPT3SAS_ADAPTER *ioc)
32503250
* See _wait_for_commands_to_complete() call with regards to this code.
32513251
*/
32523252
if (ioc->shost_recovery && ioc->pending_io_count) {
3253-
ioc->pending_io_count = atomic_read(&ioc->shost->host_busy);
3253+
ioc->pending_io_count = scsi_host_busy(ioc->shost);
32543254
if (ioc->pending_io_count == 0)
32553255
wake_up(&ioc->reset_wq);
32563256
}
@@ -6857,7 +6857,7 @@ mpt3sas_wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc)
68576857
return;
68586858

68596859
/* pending command count */
6860-
ioc->pending_io_count = atomic_read(&ioc->shost->host_busy);
6860+
ioc->pending_io_count = scsi_host_busy(ioc->shost);
68616861

68626862
if (!ioc->pending_io_count)
68636863
return;

drivers/scsi/qlogicpti.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ static inline void update_can_queue(struct Scsi_Host *host, u_int in_ptr, u_int
959959
/* Temporary workaround until bug is found and fixed (one bug has been found
960960
already, but fixing it makes things even worse) -jj */
961961
int num_free = QLOGICPTI_REQ_QUEUE_LEN - REQ_QUEUE_DEPTH(in_ptr, out_ptr) - 64;
962-
host->can_queue = atomic_read(&host->host_busy) + num_free;
962+
host->can_queue = scsi_host_busy(host) + num_free;
963963
host->sg_tablesize = QLOGICPTI_MAX_SG(num_free);
964964
}
965965

drivers/scsi/scsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
167167
if (level > 3)
168168
scmd_printk(KERN_INFO, cmd,
169169
"scsi host busy %d failed %d\n",
170-
atomic_read(&cmd->device->host->host_busy),
170+
scsi_host_busy(cmd->device->host),
171171
cmd->device->host->host_failed);
172172
}
173173
}

drivers/scsi/scsi_error.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void scsi_eh_wakeup(struct Scsi_Host *shost)
6666
{
6767
lockdep_assert_held(shost->host_lock);
6868

69-
if (atomic_read(&shost->host_busy) == shost->host_failed) {
69+
if (scsi_host_busy(shost) == shost->host_failed) {
7070
trace_scsi_eh_wakeup(shost);
7171
wake_up_process(shost->ehandler);
7272
SCSI_LOG_ERROR_RECOVERY(5, shost_printk(KERN_INFO, shost,
@@ -2155,7 +2155,7 @@ int scsi_error_handler(void *data)
21552155
break;
21562156

21572157
if ((shost->host_failed == 0 && shost->host_eh_scheduled == 0) ||
2158-
shost->host_failed != atomic_read(&shost->host_busy)) {
2158+
shost->host_failed != scsi_host_busy(shost)) {
21592159
SCSI_LOG_ERROR_RECOVERY(1,
21602160
shost_printk(KERN_INFO, shost,
21612161
"scsi_eh_%d: sleeping\n",
@@ -2170,7 +2170,7 @@ int scsi_error_handler(void *data)
21702170
"scsi_eh_%d: waking up %d/%d/%d\n",
21712171
shost->host_no, shost->host_eh_scheduled,
21722172
shost->host_failed,
2173-
atomic_read(&shost->host_busy)));
2173+
scsi_host_busy(shost)));
21742174

21752175
/*
21762176
* We have a host that is failing for some reason. Figure out

drivers/scsi/scsi_sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ static ssize_t
382382
show_host_busy(struct device *dev, struct device_attribute *attr, char *buf)
383383
{
384384
struct Scsi_Host *shost = class_to_shost(dev);
385-
return snprintf(buf, 20, "%d\n", atomic_read(&shost->host_busy));
385+
return snprintf(buf, 20, "%d\n", scsi_host_busy(shost));
386386
}
387387
static DEVICE_ATTR(host_busy, S_IRUGO, show_host_busy, NULL);
388388

include/scsi/scsi_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ extern void scsi_scan_host(struct Scsi_Host *);
758758
extern void scsi_rescan_device(struct device *);
759759
extern void scsi_remove_host(struct Scsi_Host *);
760760
extern struct Scsi_Host *scsi_host_get(struct Scsi_Host *);
761+
extern int scsi_host_busy(struct Scsi_Host *shost);
761762
extern void scsi_host_put(struct Scsi_Host *t);
762763
extern struct Scsi_Host *scsi_host_lookup(unsigned short);
763764
extern const char *scsi_host_state_name(enum scsi_host_state);

0 commit comments

Comments
 (0)