]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/scsi/scsi_transport_srp.c
Merge uncontroversial parts of branch 'readlink' of git://git.kernel.org/pub/scm...
[mirror_ubuntu-artful-kernel.git] / drivers / scsi / scsi_transport_srp.c
index e3cd3ece44121c7d8ee3806a40a42acf069f6958..b87a78673f6501be8e14f0dc28c97e244fa372ef 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/string.h>
-#include <linux/delay.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
@@ -115,21 +114,12 @@ static DECLARE_TRANSPORT_CLASS(srp_host_class, "srp_host", srp_host_setup,
 static DECLARE_TRANSPORT_CLASS(srp_rport_class, "srp_remote_ports",
                               NULL, NULL, NULL);
 
-#define SRP_PID(p) \
-       (p)->port_id[0], (p)->port_id[1], (p)->port_id[2], (p)->port_id[3], \
-       (p)->port_id[4], (p)->port_id[5], (p)->port_id[6], (p)->port_id[7], \
-       (p)->port_id[8], (p)->port_id[9], (p)->port_id[10], (p)->port_id[11], \
-       (p)->port_id[12], (p)->port_id[13], (p)->port_id[14], (p)->port_id[15]
-
-#define SRP_PID_FMT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:" \
-       "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x"
-
 static ssize_t
 show_srp_rport_id(struct device *dev, struct device_attribute *attr,
                  char *buf)
 {
        struct srp_rport *rport = transport_class_to_srp_rport(dev);
-       return sprintf(buf, SRP_PID_FMT "\n", SRP_PID(rport));
+       return sprintf(buf, "%16phC\n", rport->port_id);
 }
 
 static DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL);
@@ -402,36 +392,6 @@ static void srp_reconnect_work(struct work_struct *work)
        }
 }
 
-/**
- * scsi_request_fn_active() - number of kernel threads inside scsi_request_fn()
- * @shost: SCSI host for which to count the number of scsi_request_fn() callers.
- *
- * To do: add support for scsi-mq in this function.
- */
-static int scsi_request_fn_active(struct Scsi_Host *shost)
-{
-       struct scsi_device *sdev;
-       struct request_queue *q;
-       int request_fn_active = 0;
-
-       shost_for_each_device(sdev, shost) {
-               q = sdev->request_queue;
-
-               spin_lock_irq(q->queue_lock);
-               request_fn_active += q->request_fn_active;
-               spin_unlock_irq(q->queue_lock);
-       }
-
-       return request_fn_active;
-}
-
-/* Wait until ongoing shost->hostt->queuecommand() calls have finished. */
-static void srp_wait_for_queuecommand(struct Scsi_Host *shost)
-{
-       while (scsi_request_fn_active(shost))
-               msleep(20);
-}
-
 static void __rport_fail_io_fast(struct srp_rport *rport)
 {
        struct Scsi_Host *shost = rport_to_shost(rport);
@@ -441,14 +401,17 @@ static void __rport_fail_io_fast(struct srp_rport *rport)
 
        if (srp_rport_set_state(rport, SRP_RPORT_FAIL_FAST))
                return;
+       /*
+        * Call scsi_target_block() to wait for ongoing shost->queuecommand()
+        * calls before invoking i->f->terminate_rport_io().
+        */
+       scsi_target_block(rport->dev.parent);
        scsi_target_unblock(rport->dev.parent, SDEV_TRANSPORT_OFFLINE);
 
        /* Involve the LLD if possible to terminate all I/O on the rport. */
        i = to_srp_internal(shost->transportt);
-       if (i->f->terminate_rport_io) {
-               srp_wait_for_queuecommand(shost);
+       if (i->f->terminate_rport_io)
                i->f->terminate_rport_io(rport);
-       }
 }
 
 /**
@@ -576,7 +539,6 @@ int srp_reconnect_rport(struct srp_rport *rport)
        if (res)
                goto out;
        scsi_target_block(&shost->shost_gendev);
-       srp_wait_for_queuecommand(shost);
        res = rport->state != SRP_RPORT_LOST ? i->f->reconnect(rport) : -ENODEV;
        pr_debug("%s (state %d): transport.reconnect() returned %d\n",
                 dev_name(&shost->shost_gendev), rport->state, res);