aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMing Lei <ming.lei@redhat.com>2018-06-24 10:03:26 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2018-06-26 12:53:26 -0400
commitc84b023a4c1461498abf0eda54f60e2fd64a1ca2 (patch)
tree67ebdb69f8d50cd93209e09945474f23e845280f
parent2b33ab371e026cfcea4cbdf233c6b8776dde9ba8 (diff)
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 <osandov@fb.com>, Cc: "Martin K. Petersen" <martin.petersen@oracle.com>, Cc: James Bottomley <james.bottomley@hansenpartnership.com>, Cc: Christoph Hellwig <hch@lst.de>, Cc: Don Brace <don.brace@microsemi.com> Cc: Kashyap Desai <kashyap.desai@broadcom.com> Cc: Mike Snitzer <snitzer@redhat.com> Cc: Hannes Reinecke <hare@suse.de> Cc: Laurence Oberman <loberman@redhat.com> Cc: Bart Van Assche <bart.vanassche@wdc.com> Signed-off-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/advansys.c8
-rw-r--r--drivers/scsi/hosts.c10
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c4
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_base.c2
-rw-r--r--drivers/scsi/mpt3sas/mpt3sas_base.c4
-rw-r--r--drivers/scsi/qlogicpti.c2
-rw-r--r--drivers/scsi/scsi.c2
-rw-r--r--drivers/scsi/scsi_error.c6
-rw-r--r--drivers/scsi/scsi_sysfs.c2
-rw-r--r--include/scsi/scsi_host.h1
10 files changed, 26 insertions, 15 deletions
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index c9a52905070e..713f69033f20 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2416,8 +2416,8 @@ static void asc_prt_scsi_host(struct Scsi_Host *s)
2416 struct asc_board *boardp = shost_priv(s); 2416 struct asc_board *boardp = shost_priv(s);
2417 2417
2418 printk("Scsi_Host at addr 0x%p, device %s\n", s, dev_name(boardp->dev)); 2418 printk("Scsi_Host at addr 0x%p, device %s\n", s, dev_name(boardp->dev));
2419 printk(" host_busy %u, host_no %d,\n", 2419 printk(" host_busy %d, host_no %d,\n",
2420 atomic_read(&s->host_busy), s->host_no); 2420 scsi_host_busy(s), s->host_no);
2421 2421
2422 printk(" base 0x%lx, io_port 0x%lx, irq %d,\n", 2422 printk(" base 0x%lx, io_port 0x%lx, irq %d,\n",
2423 (ulong)s->base, (ulong)s->io_port, boardp->irq); 2423 (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)
3182 shost->host_no); 3182 shost->host_no);
3183 3183
3184 seq_printf(m, 3184 seq_printf(m,
3185 " host_busy %u, max_id %u, max_lun %llu, max_channel %u\n", 3185 " host_busy %d, max_id %u, max_lun %llu, max_channel %u\n",
3186 atomic_read(&shost->host_busy), shost->max_id, 3186 scsi_host_busy(shost), shost->max_id,
3187 shost->max_lun, shost->max_channel); 3187 shost->max_lun, shost->max_channel);
3188 3188
3189 seq_printf(m, 3189 seq_printf(m,
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 3771e59a9fae..ea4b0bb0c1cd 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -564,6 +564,16 @@ struct Scsi_Host *scsi_host_get(struct Scsi_Host *shost)
564EXPORT_SYMBOL(scsi_host_get); 564EXPORT_SYMBOL(scsi_host_get);
565 565
566/** 566/**
567 * scsi_host_busy - Return the host busy counter
568 * @shost: Pointer to Scsi_Host to inc.
569 **/
570int scsi_host_busy(struct Scsi_Host *shost)
571{
572 return atomic_read(&shost->host_busy);
573}
574EXPORT_SYMBOL(scsi_host_busy);
575
576/**
567 * scsi_host_put - dec a Scsi_Host ref count 577 * scsi_host_put - dec a Scsi_Host ref count
568 * @shost: Pointer to Scsi_Host to dec. 578 * @shost: Pointer to Scsi_Host to dec.
569 **/ 579 **/
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index ceab5e5c41c2..33229348dcb6 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -759,7 +759,7 @@ retry:
759 spin_unlock_irq(shost->host_lock); 759 spin_unlock_irq(shost->host_lock);
760 760
761 SAS_DPRINTK("Enter %s busy: %d failed: %d\n", 761 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);
763 /* 763 /*
764 * Deal with commands that still have SAS tasks (i.e. they didn't 764 * Deal with commands that still have SAS tasks (i.e. they didn't
765 * complete via the normal sas_task completion mechanism), 765 * complete via the normal sas_task completion mechanism),
@@ -801,7 +801,7 @@ out:
801 goto retry; 801 goto retry;
802 802
803 SAS_DPRINTK("--- Exit %s: busy: %d failed: %d tries: %d\n", 803 SAS_DPRINTK("--- Exit %s: busy: %d failed: %d tries: %d\n",
804 __func__, atomic_read(&shost->host_busy), 804 __func__, scsi_host_busy(shost),
805 shost->host_failed, tries); 805 shost->host_failed, tries);
806} 806}
807 807
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index e6ba02793610..9aa9590c5373 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -2834,7 +2834,7 @@ static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
2834 "SCSI command pointer: (%p)\t SCSI host state: %d\t" 2834 "SCSI command pointer: (%p)\t SCSI host state: %d\t"
2835 " SCSI host busy: %d\t FW outstanding: %d\n", 2835 " SCSI host busy: %d\t FW outstanding: %d\n",
2836 scmd, scmd->device->host->shost_state, 2836 scmd, scmd->device->host->shost_state,
2837 atomic_read((atomic_t *)&scmd->device->host->host_busy), 2837 scsi_host_busy(scmd->device->host),
2838 atomic_read(&instance->fw_outstanding)); 2838 atomic_read(&instance->fw_outstanding));
2839 2839
2840 /* 2840 /*
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 2053970fc9f8..dc41bd3de08a 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -3250,7 +3250,7 @@ _base_recovery_check(struct MPT3SAS_ADAPTER *ioc)
3250 * See _wait_for_commands_to_complete() call with regards to this code. 3250 * See _wait_for_commands_to_complete() call with regards to this code.
3251 */ 3251 */
3252 if (ioc->shost_recovery && ioc->pending_io_count) { 3252 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);
3254 if (ioc->pending_io_count == 0) 3254 if (ioc->pending_io_count == 0)
3255 wake_up(&ioc->reset_wq); 3255 wake_up(&ioc->reset_wq);
3256 } 3256 }
@@ -6857,7 +6857,7 @@ mpt3sas_wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc)
6857 return; 6857 return;
6858 6858
6859 /* pending command count */ 6859 /* pending command count */
6860 ioc->pending_io_count = atomic_read(&ioc->shost->host_busy); 6860 ioc->pending_io_count = scsi_host_busy(ioc->shost);
6861 6861
6862 if (!ioc->pending_io_count) 6862 if (!ioc->pending_io_count)
6863 return; 6863 return;
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index 8578e566ab41..9d09228eee28 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -959,7 +959,7 @@ static inline void update_can_queue(struct Scsi_Host *host, u_int in_ptr, u_int
959 /* Temporary workaround until bug is found and fixed (one bug has been found 959 /* Temporary workaround until bug is found and fixed (one bug has been found
960 already, but fixing it makes things even worse) -jj */ 960 already, but fixing it makes things even worse) -jj */
961 int num_free = QLOGICPTI_REQ_QUEUE_LEN - REQ_QUEUE_DEPTH(in_ptr, out_ptr) - 64; 961 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;
963 host->sg_tablesize = QLOGICPTI_MAX_SG(num_free); 963 host->sg_tablesize = QLOGICPTI_MAX_SG(num_free);
964} 964}
965 965
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 70ef3c39061d..fc1356d101b0 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -167,7 +167,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
167 if (level > 3) 167 if (level > 3)
168 scmd_printk(KERN_INFO, cmd, 168 scmd_printk(KERN_INFO, cmd,
169 "scsi host busy %d failed %d\n", 169 "scsi host busy %d failed %d\n",
170 atomic_read(&cmd->device->host->host_busy), 170 scsi_host_busy(cmd->device->host),
171 cmd->device->host->host_failed); 171 cmd->device->host->host_failed);
172 } 172 }
173 } 173 }
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 8932ae81a15a..6a014fd15fe9 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -66,7 +66,7 @@ void scsi_eh_wakeup(struct Scsi_Host *shost)
66{ 66{
67 lockdep_assert_held(shost->host_lock); 67 lockdep_assert_held(shost->host_lock);
68 68
69 if (atomic_read(&shost->host_busy) == shost->host_failed) { 69 if (scsi_host_busy(shost) == shost->host_failed) {
70 trace_scsi_eh_wakeup(shost); 70 trace_scsi_eh_wakeup(shost);
71 wake_up_process(shost->ehandler); 71 wake_up_process(shost->ehandler);
72 SCSI_LOG_ERROR_RECOVERY(5, shost_printk(KERN_INFO, shost, 72 SCSI_LOG_ERROR_RECOVERY(5, shost_printk(KERN_INFO, shost,
@@ -2155,7 +2155,7 @@ int scsi_error_handler(void *data)
2155 break; 2155 break;
2156 2156
2157 if ((shost->host_failed == 0 && shost->host_eh_scheduled == 0) || 2157 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)) {
2159 SCSI_LOG_ERROR_RECOVERY(1, 2159 SCSI_LOG_ERROR_RECOVERY(1,
2160 shost_printk(KERN_INFO, shost, 2160 shost_printk(KERN_INFO, shost,
2161 "scsi_eh_%d: sleeping\n", 2161 "scsi_eh_%d: sleeping\n",
@@ -2170,7 +2170,7 @@ int scsi_error_handler(void *data)
2170 "scsi_eh_%d: waking up %d/%d/%d\n", 2170 "scsi_eh_%d: waking up %d/%d/%d\n",
2171 shost->host_no, shost->host_eh_scheduled, 2171 shost->host_no, shost->host_eh_scheduled,
2172 shost->host_failed, 2172 shost->host_failed,
2173 atomic_read(&shost->host_busy))); 2173 scsi_host_busy(shost)));
2174 2174
2175 /* 2175 /*
2176 * We have a host that is failing for some reason. Figure out 2176 * We have a host that is failing for some reason. Figure out
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 7943b762c12d..de122354d09a 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -382,7 +382,7 @@ static ssize_t
382show_host_busy(struct device *dev, struct device_attribute *attr, char *buf) 382show_host_busy(struct device *dev, struct device_attribute *attr, char *buf)
383{ 383{
384 struct Scsi_Host *shost = class_to_shost(dev); 384 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));
386} 386}
387static DEVICE_ATTR(host_busy, S_IRUGO, show_host_busy, NULL); 387static DEVICE_ATTR(host_busy, S_IRUGO, show_host_busy, NULL);
388 388
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 53b485fe9b67..5ea06d310a25 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -758,6 +758,7 @@ extern void scsi_scan_host(struct Scsi_Host *);
758extern void scsi_rescan_device(struct device *); 758extern void scsi_rescan_device(struct device *);
759extern void scsi_remove_host(struct Scsi_Host *); 759extern void scsi_remove_host(struct Scsi_Host *);
760extern struct Scsi_Host *scsi_host_get(struct Scsi_Host *); 760extern struct Scsi_Host *scsi_host_get(struct Scsi_Host *);
761extern int scsi_host_busy(struct Scsi_Host *shost);
761extern void scsi_host_put(struct Scsi_Host *t); 762extern void scsi_host_put(struct Scsi_Host *t);
762extern struct Scsi_Host *scsi_host_lookup(unsigned short); 763extern struct Scsi_Host *scsi_host_lookup(unsigned short);
763extern const char *scsi_host_state_name(enum scsi_host_state); 764extern const char *scsi_host_state_name(enum scsi_host_state);