[SCSI] scsi_transport_fc: Add missing parenthesis to Point-To-Point description
[safe/jmp/linux-2.6] / drivers / scsi / scsi_transport_fc.c
index 5fd64e7..2df7529 100644 (file)
 
 static int fc_queue_work(struct Scsi_Host *, struct work_struct *);
 static void fc_vport_sched_delete(struct work_struct *work);
-
-/*
- * This is a temporary carrier for creating a vport. It will eventually
- * be replaced  by a real message definition for sgio or netlink.
- *
- * fc_vport_identifiers: This set of data contains all elements
- * to uniquely identify and instantiate a FC virtual port.
- *
- * Notes:
- *   symbolic_name: The driver is to append the symbolic_name string data
- *      to the symbolic_node_name data that it generates by default.
- *      the resulting combination should then be registered with the switch.
- *      It is expected that things like Xen may stuff a VM title into
- *      this field.
- */
-struct fc_vport_identifiers {
-       u64 node_name;
-       u64 port_name;
-       u32 roles;
-       bool disable;
-       enum fc_port_type vport_type;   /* only FC_PORTTYPE_NPIV allowed */
-       char symbolic_name[FC_VPORT_SYMBOLIC_NAMELEN];
-};
-
-static int fc_vport_create(struct Scsi_Host *shost, int channel,
+static int fc_vport_setup(struct Scsi_Host *shost, int channel,
        struct device *pdev, struct fc_vport_identifiers  *ids,
        struct fc_vport **vport);
 
@@ -119,7 +95,7 @@ static struct {
        { FC_PORTTYPE_NPORT,    "NPort (fabric via point-to-point)" },
        { FC_PORTTYPE_NLPORT,   "NLPort (fabric via loop)" },
        { FC_PORTTYPE_LPORT,    "LPort (private loop)" },
-       { FC_PORTTYPE_PTP,      "Point-To-Point (direct nport connection" },
+       { FC_PORTTYPE_PTP,      "Point-To-Point (direct nport connection)" },
        { FC_PORTTYPE_NPIV,             "NPIV VPORT" },
 };
 fc_enum_name_search(port_type, fc_port_type, fc_port_type_names)
@@ -417,15 +393,16 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev,
        fc_host->next_vport_number = 0;
        fc_host->npiv_vports_inuse = 0;
 
-       snprintf(fc_host->work_q_name, KOBJ_NAME_LEN, "fc_wq_%d",
-               shost->host_no);
+       snprintf(fc_host->work_q_name, sizeof(fc_host->work_q_name),
+                "fc_wq_%d", shost->host_no);
        fc_host->work_q = create_singlethread_workqueue(
                                        fc_host->work_q_name);
        if (!fc_host->work_q)
                return -ENOMEM;
 
-       snprintf(fc_host->devloss_work_q_name, KOBJ_NAME_LEN, "fc_dl_%d",
-               shost->host_no);
+       snprintf(fc_host->devloss_work_q_name,
+                sizeof(fc_host->devloss_work_q_name),
+                "fc_dl_%d", shost->host_no);
        fc_host->devloss_work_q = create_singlethread_workqueue(
                                        fc_host->devloss_work_q_name);
        if (!fc_host->devloss_work_q) {
@@ -570,7 +547,7 @@ send_fail:
        name = get_fc_host_event_code_name(event_code);
        printk(KERN_WARNING
                "%s: Dropped Event : host %d %s data 0x%08x - err %d\n",
-               __FUNCTION__, shost->host_no,
+               __func__, shost->host_no,
                (name) ? name : "<unknown>", event_data, err);
        return;
 }
@@ -643,7 +620,7 @@ send_vendor_fail_skb:
 send_vendor_fail:
        printk(KERN_WARNING
                "%s: Dropped Event : host %d vendor_unique - err %d\n",
-               __FUNCTION__, shost->host_no, err);
+               __func__, shost->host_no, err);
        return;
 }
 EXPORT_SYMBOL(fc_host_post_vendor_event);
@@ -1759,7 +1736,7 @@ store_fc_host_vport_create(struct device *dev, struct device_attribute *attr,
        vid.disable = false;            /* always enabled */
 
        /* we only allow support on Channel 0 !!! */
-       stat = fc_vport_create(shost, 0, &shost->shost_gendev, &vid, &vport);
+       stat = fc_vport_setup(shost, 0, &shost->shost_gendev, &vid, &vport);
        return stat ? stat : count;
 }
 static FC_DEVICE_ATTR(host, vport_create, S_IWUSR, NULL,
@@ -1949,15 +1926,15 @@ static int fc_vport_match(struct attribute_container *cont,
  * Notes:
  *     This routine assumes no locks are held on entry.
  */
-static enum scsi_eh_timer_return
+static enum blk_eh_timer_return
 fc_timed_out(struct scsi_cmnd *scmd)
 {
        struct fc_rport *rport = starget_to_rport(scsi_target(scmd->device));
 
        if (rport->port_state == FC_PORTSTATE_BLOCKED)
-               return EH_RESET_TIMER;
+               return BLK_EH_RESET_TIMER;
 
-       return EH_NOT_HANDLED;
+       return BLK_EH_NOT_HANDLED;
 }
 
 /*
@@ -2156,8 +2133,7 @@ fc_attach_transport(struct fc_function_template *ft)
        SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(roles);
        SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_state);
        SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(scsi_target_id);
-       if (ft->terminate_rport_io)
-               SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(fast_io_fail_tmo);
+       SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(fast_io_fail_tmo);
 
        BUG_ON(count > FC_RPORT_NUM_ATTRS);
 
@@ -2351,6 +2327,22 @@ fc_remove_host(struct Scsi_Host *shost)
 }
 EXPORT_SYMBOL(fc_remove_host);
 
+static void fc_terminate_rport_io(struct fc_rport *rport)
+{
+       struct Scsi_Host *shost = rport_to_shost(rport);
+       struct fc_internal *i = to_fc_internal(shost->transportt);
+
+       /* Involve the LLDD if possible to terminate all io on the rport. */
+       if (i->f->terminate_rport_io)
+               i->f->terminate_rport_io(rport);
+
+       /*
+        * must unblock to flush queued IO. The caller will have set
+        * the port_state or flags, so that fc_remote_port_chkready will
+        * fail IO.
+        */
+       scsi_target_unblock(&rport->dev);
+}
 
 /**
  * fc_starget_delete - called to delete the scsi decendents of an rport
@@ -2363,13 +2355,8 @@ fc_starget_delete(struct work_struct *work)
 {
        struct fc_rport *rport =
                container_of(work, struct fc_rport, stgt_delete_work);
-       struct Scsi_Host *shost = rport_to_shost(rport);
-       struct fc_internal *i = to_fc_internal(shost->transportt);
-
-       /* Involve the LLDD if possible to terminate all io on the rport. */
-       if (i->f->terminate_rport_io)
-               i->f->terminate_rport_io(rport);
 
+       fc_terminate_rport_io(rport);
        scsi_remove_target(&rport->dev);
 }
 
@@ -2395,10 +2382,7 @@ fc_rport_final_delete(struct work_struct *work)
        if (rport->flags & FC_RPORT_SCAN_PENDING)
                scsi_flush_work(shost);
 
-       /* involve the LLDD to terminate all pending i/o */
-       if (i->f->terminate_rport_io)
-               i->f->terminate_rport_io(rport);
-
+       fc_terminate_rport_io(rport);
        /*
         * Cancel any outstanding timers. These should really exist
         * only when rmmod'ing the LLDD and we're asking for
@@ -2423,8 +2407,12 @@ fc_rport_final_delete(struct work_struct *work)
        /*
         * Notify the driver that the rport is now dead. The LLDD will
         * also guarantee that any communication to the rport is terminated
+        *
+        * Avoid this call if we already called it when we preserved the
+        * rport for the binding.
         */
-       if (i->f->dev_loss_tmo_callbk)
+       if (!(rport->flags & FC_RPORT_DEVLOSS_CALLBK_DONE) &&
+           (i->f->dev_loss_tmo_callbk))
                i->f->dev_loss_tmo_callbk(rport);
 
        transport_remove_device(dev);
@@ -2463,7 +2451,7 @@ fc_rport_create(struct Scsi_Host *shost, int channel,
        size = (sizeof(struct fc_rport) + fci->f->dd_fcrport_size);
        rport = kzalloc(size, GFP_KERNEL);
        if (unlikely(!rport)) {
-               printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__);
+               printk(KERN_ERR "%s: allocation failure\n", __func__);
                return NULL;
        }
 
@@ -2502,8 +2490,8 @@ fc_rport_create(struct Scsi_Host *shost, int channel,
        device_initialize(dev);                 /* takes self reference */
        dev->parent = get_device(&shost->shost_gendev); /* parent reference */
        dev->release = fc_rport_dev_release;
-       sprintf(dev->bus_id, "rport-%d:%d-%d",
-               shost->host_no, channel, rport->number);
+       dev_set_name(dev, "rport-%d:%d-%d",
+                    shost->host_no, channel, rport->number);
        transport_setup_device(dev);
 
        error = device_add(dev);
@@ -2662,7 +2650,9 @@ fc_remote_port_add(struct Scsi_Host *shost, int channel,
 
                                spin_lock_irqsave(shost->host_lock, flags);
 
-                               rport->flags &= ~FC_RPORT_DEVLOSS_PENDING;
+                               rport->flags &= ~(FC_RPORT_FAST_FAIL_TIMEDOUT |
+                                                 FC_RPORT_DEVLOSS_PENDING |
+                                                 FC_RPORT_DEVLOSS_CALLBK_DONE);
 
                                /* if target, initiate a scan */
                                if (rport->scsi_target_id != -1) {
@@ -2725,6 +2715,7 @@ fc_remote_port_add(struct Scsi_Host *shost, int channel,
                        rport->port_id = ids->port_id;
                        rport->roles = ids->roles;
                        rport->port_state = FC_PORTSTATE_ONLINE;
+                       rport->flags &= ~FC_RPORT_FAST_FAIL_TIMEDOUT;
 
                        if (fci->f->dd_fcrport_size)
                                memset(rport->dd_data, 0,
@@ -2807,7 +2798,6 @@ void
 fc_remote_port_delete(struct fc_rport  *rport)
 {
        struct Scsi_Host *shost = rport_to_shost(rport);
-       struct fc_internal *i = to_fc_internal(shost->transportt);
        int timeout = rport->dev_loss_tmo;
        unsigned long flags;
 
@@ -2853,7 +2843,7 @@ fc_remote_port_delete(struct fc_rport  *rport)
 
        /* see if we need to kill io faster than waiting for device loss */
        if ((rport->fast_io_fail_tmo != -1) &&
-           (rport->fast_io_fail_tmo < timeout) && (i->f->terminate_rport_io))
+           (rport->fast_io_fail_tmo < timeout))
                fc_queue_devloss_work(shost, &rport->fail_io_work,
                                        rport->fast_io_fail_tmo * HZ);
 
@@ -2929,7 +2919,8 @@ fc_remote_port_rolechg(struct fc_rport  *rport, u32 roles)
                        fc_flush_devloss(shost);
 
                spin_lock_irqsave(shost->host_lock, flags);
-               rport->flags &= ~FC_RPORT_DEVLOSS_PENDING;
+               rport->flags &= ~(FC_RPORT_FAST_FAIL_TIMEDOUT |
+                                 FC_RPORT_DEVLOSS_PENDING);
                spin_unlock_irqrestore(shost->host_lock, flags);
 
                /* ensure any stgt delete functions are done */
@@ -2958,6 +2949,7 @@ fc_timeout_deleted_rport(struct work_struct *work)
        struct fc_rport *rport =
                container_of(work, struct fc_rport, dev_loss_work.work);
        struct Scsi_Host *shost = rport_to_shost(rport);
+       struct fc_internal *i = to_fc_internal(shost->transportt);
        struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
        unsigned long flags;
 
@@ -3024,6 +3016,18 @@ fc_timeout_deleted_rport(struct work_struct *work)
        rport->supported_classes = FC_COS_UNSPECIFIED;
        rport->roles = FC_PORT_ROLE_UNKNOWN;
        rport->port_state = FC_PORTSTATE_NOTPRESENT;
+       rport->flags &= ~FC_RPORT_FAST_FAIL_TIMEDOUT;
+       rport->flags |= FC_RPORT_DEVLOSS_CALLBK_DONE;
+
+       /*
+        * Pre-emptively kill I/O rather than waiting for the work queue
+        * item to teardown the starget. (FCOE libFC folks prefer this
+        * and to have the rport_port_id still set when it's done).
+        */
+       spin_unlock_irqrestore(shost->host_lock, flags);
+       fc_terminate_rport_io(rport);
+
+       BUG_ON(rport->port_state != FC_PORTSTATE_NOTPRESENT);
 
        /* remove the identifiers that aren't used in the consisting binding */
        switch (fc_host->tgtid_bind_type) {
@@ -3048,12 +3052,19 @@ fc_timeout_deleted_rport(struct work_struct *work)
         * went away and didn't come back - we'll remove
         * all attached scsi devices.
         */
-       spin_unlock_irqrestore(shost->host_lock, flags);
-
-       scsi_target_unblock(&rport->dev);
        fc_queue_work(shost, &rport->stgt_delete_work);
+
+       /*
+        * Notify the driver that the rport is now dead. The LLDD will
+        * also guarantee that any communication to the rport is terminated
+        *
+        * Note: we set the CALLBK_DONE flag above to correspond
+        */
+       if (i->f->dev_loss_tmo_callbk)
+               i->f->dev_loss_tmo_callbk(rport);
 }
 
+
 /**
  * fc_timeout_fail_rport_io - Timeout handler for a fast io failing on a disconnected SCSI target.
  * @work:      rport to terminate io on.
@@ -3066,13 +3077,12 @@ fc_timeout_fail_rport_io(struct work_struct *work)
 {
        struct fc_rport *rport =
                container_of(work, struct fc_rport, fail_io_work.work);
-       struct Scsi_Host *shost = rport_to_shost(rport);
-       struct fc_internal *i = to_fc_internal(shost->transportt);
 
        if (rport->port_state != FC_PORTSTATE_BLOCKED)
                return;
 
-       i->f->terminate_rport_io(rport);
+       rport->flags |= FC_RPORT_FAST_FAIL_TIMEDOUT;
+       fc_terminate_rport_io(rport);
 }
 
 /**
@@ -3102,7 +3112,7 @@ fc_scsi_scan_rport(struct work_struct *work)
 
 
 /**
- * fc_vport_create - allocates and creates a FC virtual port.
+ * fc_vport_setup - allocates and creates a FC virtual port.
  * @shost:     scsi host the virtual port is connected to.
  * @channel:   Channel on shost port connected to.
  * @pdev:      parent device for vport
@@ -3117,7 +3127,7 @@ fc_scsi_scan_rport(struct work_struct *work)
  *     This routine assumes no locks are held on entry.
  */
 static int
-fc_vport_create(struct Scsi_Host *shost, int channel, struct device *pdev,
+fc_vport_setup(struct Scsi_Host *shost, int channel, struct device *pdev,
        struct fc_vport_identifiers  *ids, struct fc_vport **ret_vport)
 {
        struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
@@ -3136,7 +3146,7 @@ fc_vport_create(struct Scsi_Host *shost, int channel, struct device *pdev,
        size = (sizeof(struct fc_vport) + fci->f->dd_fcvport_size);
        vport = kzalloc(size, GFP_KERNEL);
        if (unlikely(!vport)) {
-               printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__);
+               printk(KERN_ERR "%s: allocation failure\n", __func__);
                return -ENOMEM;
        }
 
@@ -3171,8 +3181,8 @@ fc_vport_create(struct Scsi_Host *shost, int channel, struct device *pdev,
        device_initialize(dev);                 /* takes self reference */
        dev->parent = get_device(pdev);         /* takes parent reference */
        dev->release = fc_vport_dev_release;
-       sprintf(dev->bus_id, "vport-%d:%d-%d",
-               shost->host_no, channel, vport->number);
+       dev_set_name(dev, "vport-%d:%d-%d",
+                    shost->host_no, channel, vport->number);
        transport_setup_device(dev);
 
        error = device_add(dev);
@@ -3195,19 +3205,19 @@ fc_vport_create(struct Scsi_Host *shost, int channel, struct device *pdev,
         */
        if (pdev != &shost->shost_gendev) {
                error = sysfs_create_link(&shost->shost_gendev.kobj,
-                                &dev->kobj, dev->bus_id);
+                                &dev->kobj, dev_name(dev));
                if (error)
                        printk(KERN_ERR
                                "%s: Cannot create vport symlinks for "
                                "%s, err=%d\n",
-                               __FUNCTION__, dev->bus_id, error);
+                               __func__, dev_name(dev), error);
        }
        spin_lock_irqsave(shost->host_lock, flags);
        vport->flags &= ~FC_VPORT_CREATING;
        spin_unlock_irqrestore(shost->host_lock, flags);
 
        dev_printk(KERN_NOTICE, pdev,
-                       "%s created via shost%d channel %d\n", dev->bus_id,
+                       "%s created via shost%d channel %d\n", dev_name(dev),
                        shost->host_no, channel);
 
        *ret_vport = vport;
@@ -3230,6 +3240,28 @@ delete_vport:
        return error;
 }
 
+/**
+ * fc_vport_create - Admin App or LLDD requests creation of a vport
+ * @shost:     scsi host the virtual port is connected to.
+ * @channel:   channel on shost port connected to.
+ * @ids:       The world wide names, FC4 port roles, etc for
+ *              the virtual port.
+ *
+ * Notes:
+ *     This routine assumes no locks are held on entry.
+ */
+struct fc_vport *
+fc_vport_create(struct Scsi_Host *shost, int channel,
+       struct fc_vport_identifiers *ids)
+{
+       int stat;
+       struct fc_vport *vport;
+
+       stat = fc_vport_setup(shost, channel, &shost->shost_gendev,
+                ids, &vport);
+       return stat ? NULL : vport;
+}
+EXPORT_SYMBOL(fc_vport_create);
 
 /**
  * fc_vport_terminate - Admin App or LLDD requests termination of a vport
@@ -3282,7 +3314,7 @@ fc_vport_terminate(struct fc_vport *vport)
                return stat;
 
        if (dev->parent != &shost->shost_gendev)
-               sysfs_remove_link(&shost->shost_gendev.kobj, dev->bus_id);
+               sysfs_remove_link(&shost->shost_gendev.kobj, dev_name(dev));
        transport_remove_device(dev);
        device_del(dev);
        transport_destroy_device(dev);
@@ -3313,8 +3345,8 @@ fc_vport_sched_delete(struct work_struct *work)
        if (stat)
                dev_printk(KERN_ERR, vport->dev.parent,
                        "%s: %s could not be deleted created via "
-                       "shost%d channel %d - error %d\n", __FUNCTION__,
-                       vport->dev.bus_id, vport->shost->host_no,
+                       "shost%d channel %d - error %d\n", __func__,
+                       dev_name(&vport->dev), vport->shost->host_no,
                        vport->channel, stat);
 }