[SCSI] zfcp: Issue FCP command without holding SCSI host_lock
[linux-2.6.git] / drivers / s390 / scsi / zfcp_sysfs.c
index 3e51e64..2f2c54f 100644 (file)
@@ -3,12 +3,13 @@
  *
  * sysfs attributes.
  *
- * Copyright IBM Corporation 2008
+ * Copyright IBM Corporation 2008, 2010
  */
 
 #define KMSG_COMPONENT "zfcp"
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
+#include <linux/slab.h>
 #include "zfcp_ext.h"
 
 #define ZFCP_DEV_ATTR(_feat, _name, _mode, _show, _store) \
@@ -19,30 +20,43 @@ static ssize_t zfcp_sysfs_##_feat##_##_name##_show(struct device *dev,             \
                                                   struct device_attribute *at,\
                                                   char *buf)                  \
 {                                                                             \
-       struct _feat_def *_feat = dev_get_drvdata(dev);                        \
+       struct _feat_def *_feat = container_of(dev, struct _feat_def, dev);    \
                                                                               \
        return sprintf(buf, _format, _value);                                  \
 }                                                                             \
 static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO,                                   \
                     zfcp_sysfs_##_feat##_##_name##_show, NULL);
 
-ZFCP_DEFINE_ATTR(zfcp_adapter, adapter, status, "0x%08x\n",
-                atomic_read(&adapter->status));
-ZFCP_DEFINE_ATTR(zfcp_adapter, adapter, peer_wwnn, "0x%016llx\n",
-                (unsigned long long) adapter->peer_wwnn);
-ZFCP_DEFINE_ATTR(zfcp_adapter, adapter, peer_wwpn, "0x%016llx\n",
-                (unsigned long long) adapter->peer_wwpn);
-ZFCP_DEFINE_ATTR(zfcp_adapter, adapter, peer_d_id, "0x%06x\n",
-                adapter->peer_d_id);
-ZFCP_DEFINE_ATTR(zfcp_adapter, adapter, card_version, "0x%04x\n",
-                adapter->hydra_version);
-ZFCP_DEFINE_ATTR(zfcp_adapter, adapter, lic_version, "0x%08x\n",
-                adapter->fsf_lic_version);
-ZFCP_DEFINE_ATTR(zfcp_adapter, adapter, hardware_version, "0x%08x\n",
-                adapter->hardware_version);
-ZFCP_DEFINE_ATTR(zfcp_adapter, adapter, in_recovery, "%d\n",
-                (atomic_read(&adapter->status) &
-                 ZFCP_STATUS_COMMON_ERP_INUSE) != 0);
+#define ZFCP_DEFINE_A_ATTR(_name, _format, _value)                          \
+static ssize_t zfcp_sysfs_adapter_##_name##_show(struct device *dev,        \
+                                                struct device_attribute *at,\
+                                                char *buf)                  \
+{                                                                           \
+       struct ccw_device *cdev = to_ccwdev(dev);                            \
+       struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);       \
+       int i;                                                               \
+                                                                            \
+       if (!adapter)                                                        \
+               return -ENODEV;                                              \
+                                                                            \
+       i = sprintf(buf, _format, _value);                                   \
+       zfcp_ccw_adapter_put(adapter);                                       \
+       return i;                                                            \
+}                                                                           \
+static ZFCP_DEV_ATTR(adapter, _name, S_IRUGO,                               \
+                    zfcp_sysfs_adapter_##_name##_show, NULL);
+
+ZFCP_DEFINE_A_ATTR(status, "0x%08x\n", atomic_read(&adapter->status));
+ZFCP_DEFINE_A_ATTR(peer_wwnn, "0x%016llx\n",
+                  (unsigned long long) adapter->peer_wwnn);
+ZFCP_DEFINE_A_ATTR(peer_wwpn, "0x%016llx\n",
+                  (unsigned long long) adapter->peer_wwpn);
+ZFCP_DEFINE_A_ATTR(peer_d_id, "0x%06x\n", adapter->peer_d_id);
+ZFCP_DEFINE_A_ATTR(card_version, "0x%04x\n", adapter->hydra_version);
+ZFCP_DEFINE_A_ATTR(lic_version, "0x%08x\n", adapter->fsf_lic_version);
+ZFCP_DEFINE_A_ATTR(hardware_version, "0x%08x\n", adapter->hardware_version);
+ZFCP_DEFINE_A_ATTR(in_recovery, "%d\n", (atomic_read(&adapter->status) &
+                                        ZFCP_STATUS_COMMON_ERP_INUSE) != 0);
 
 ZFCP_DEFINE_ATTR(zfcp_port, port, status, "0x%08x\n",
                 atomic_read(&port->status));
@@ -54,80 +68,162 @@ ZFCP_DEFINE_ATTR(zfcp_port, port, access_denied, "%d\n",
                  ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0);
 
 ZFCP_DEFINE_ATTR(zfcp_unit, unit, status, "0x%08x\n",
-                atomic_read(&unit->status));
+                zfcp_unit_sdev_status(unit));
 ZFCP_DEFINE_ATTR(zfcp_unit, unit, in_recovery, "%d\n",
-                (atomic_read(&unit->status) &
+                (zfcp_unit_sdev_status(unit) &
                  ZFCP_STATUS_COMMON_ERP_INUSE) != 0);
 ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_denied, "%d\n",
-                (atomic_read(&unit->status) &
+                (zfcp_unit_sdev_status(unit) &
                  ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0);
 ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_shared, "%d\n",
-                (atomic_read(&unit->status) &
-                 ZFCP_STATUS_UNIT_SHARED) != 0);
+                (zfcp_unit_sdev_status(unit) &
+                 ZFCP_STATUS_LUN_SHARED) != 0);
 ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_readonly, "%d\n",
-                (atomic_read(&unit->status) &
-                 ZFCP_STATUS_UNIT_READONLY) != 0);
+                (zfcp_unit_sdev_status(unit) &
+                 ZFCP_STATUS_LUN_READONLY) != 0);
 
-#define ZFCP_SYSFS_FAILED(_feat_def, _feat, _adapter, _mod_id, _reopen_id)     \
-static ssize_t zfcp_sysfs_##_feat##_failed_show(struct device *dev,           \
-                                               struct device_attribute *attr, \
-                                               char *buf)                     \
-{                                                                             \
-       struct _feat_def *_feat = dev_get_drvdata(dev);                        \
-                                                                              \
-       if (atomic_read(&_feat->status) & ZFCP_STATUS_COMMON_ERP_FAILED)       \
-               return sprintf(buf, "1\n");                                    \
-       else                                                                   \
-               return sprintf(buf, "0\n");                                    \
-}                                                                             \
-static ssize_t zfcp_sysfs_##_feat##_failed_store(struct device *dev,          \
-                                                struct device_attribute *attr,\
-                                                const char *buf, size_t count)\
-{                                                                             \
-       struct _feat_def *_feat = dev_get_drvdata(dev);                        \
-       unsigned long val;                                                     \
-       int retval = 0;                                                        \
-                                                                              \
-       down(&zfcp_data.config_sema);                                          \
-       if (atomic_read(&_feat->status) & ZFCP_STATUS_COMMON_REMOVE) {         \
-               retval = -EBUSY;                                               \
-               goto out;                                                      \
-       }                                                                      \
-                                                                              \
-       if (strict_strtoul(buf, 0, &val) || val != 0) {                        \
-               retval = -EINVAL;                                              \
-               goto out;                                                      \
-       }                                                                      \
-                                                                              \
-       zfcp_erp_modify_##_feat##_status(_feat, _mod_id, NULL,                 \
-                                        ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET);\
-       zfcp_erp_##_feat##_reopen(_feat, ZFCP_STATUS_COMMON_ERP_FAILED,        \
-                                 _reopen_id, NULL);                           \
-       zfcp_erp_wait(_adapter);                                               \
-out:                                                                          \
-       up(&zfcp_data.config_sema);                                            \
-       return retval ? retval : (ssize_t) count;                              \
-}                                                                             \
-static ZFCP_DEV_ATTR(_feat, failed, S_IWUSR | S_IRUGO,                        \
-                    zfcp_sysfs_##_feat##_failed_show,                         \
-                    zfcp_sysfs_##_feat##_failed_store);
+static ssize_t zfcp_sysfs_port_failed_show(struct device *dev,
+                                          struct device_attribute *attr,
+                                          char *buf)
+{
+       struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
+
+       if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
+               return sprintf(buf, "1\n");
+
+       return sprintf(buf, "0\n");
+}
+
+static ssize_t zfcp_sysfs_port_failed_store(struct device *dev,
+                                           struct device_attribute *attr,
+                                           const char *buf, size_t count)
+{
+       struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
+       unsigned long val;
+
+       if (strict_strtoul(buf, 0, &val) || val != 0)
+               return -EINVAL;
+
+       zfcp_erp_set_port_status(port, ZFCP_STATUS_COMMON_RUNNING);
+       zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, "sypfai2",
+                            NULL);
+       zfcp_erp_wait(port->adapter);
+
+       return count;
+}
+static ZFCP_DEV_ATTR(port, failed, S_IWUSR | S_IRUGO,
+                    zfcp_sysfs_port_failed_show,
+                    zfcp_sysfs_port_failed_store);
+
+static ssize_t zfcp_sysfs_unit_failed_show(struct device *dev,
+                                          struct device_attribute *attr,
+                                          char *buf)
+{
+       struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev);
+       struct scsi_device *sdev;
+       unsigned int status, failed = 1;
+
+       sdev = zfcp_unit_sdev(unit);
+       if (sdev) {
+               status = atomic_read(&sdev_to_zfcp(sdev)->status);
+               failed = status & ZFCP_STATUS_COMMON_ERP_FAILED ? 1 : 0;
+               scsi_device_put(sdev);
+       }
+
+       return sprintf(buf, "%d\n", failed);
+}
+
+static ssize_t zfcp_sysfs_unit_failed_store(struct device *dev,
+                                           struct device_attribute *attr,
+                                           const char *buf, size_t count)
+{
+       struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev);
+       unsigned long val;
+       struct scsi_device *sdev;
+
+       if (strict_strtoul(buf, 0, &val) || val != 0)
+               return -EINVAL;
+
+       sdev = zfcp_unit_sdev(unit);
+       if (sdev) {
+               zfcp_erp_set_lun_status(sdev, ZFCP_STATUS_COMMON_RUNNING);
+               zfcp_erp_lun_reopen(sdev, ZFCP_STATUS_COMMON_ERP_FAILED,
+                                   "syufai2", NULL);
+               zfcp_erp_wait(unit->port->adapter);
+       } else
+               zfcp_unit_scsi_scan(unit);
+
+       return count;
+}
+static ZFCP_DEV_ATTR(unit, failed, S_IWUSR | S_IRUGO,
+                    zfcp_sysfs_unit_failed_show,
+                    zfcp_sysfs_unit_failed_store);
+
+static ssize_t zfcp_sysfs_adapter_failed_show(struct device *dev,
+                                             struct device_attribute *attr,
+                                             char *buf)
+{
+       struct ccw_device *cdev = to_ccwdev(dev);
+       struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
+       int i;
+
+       if (!adapter)
+               return -ENODEV;
+
+       if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_ERP_FAILED)
+               i = sprintf(buf, "1\n");
+       else
+               i = sprintf(buf, "0\n");
+
+       zfcp_ccw_adapter_put(adapter);
+       return i;
+}
+
+static ssize_t zfcp_sysfs_adapter_failed_store(struct device *dev,
+                                              struct device_attribute *attr,
+                                              const char *buf, size_t count)
+{
+       struct ccw_device *cdev = to_ccwdev(dev);
+       struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
+       unsigned long val;
+       int retval = 0;
+
+       if (!adapter)
+               return -ENODEV;
+
+       if (strict_strtoul(buf, 0, &val) || val != 0) {
+               retval = -EINVAL;
+               goto out;
+       }
 
-ZFCP_SYSFS_FAILED(zfcp_adapter, adapter, adapter, "syafai1", "syafai2");
-ZFCP_SYSFS_FAILED(zfcp_port, port, port->adapter, "sypfai1", "sypfai2");
-ZFCP_SYSFS_FAILED(zfcp_unit, unit, unit->port->adapter, "syufai1", "syufai2");
+       zfcp_erp_set_adapter_status(adapter, ZFCP_STATUS_COMMON_RUNNING);
+       zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED,
+                               "syafai2", NULL);
+       zfcp_erp_wait(adapter);
+out:
+       zfcp_ccw_adapter_put(adapter);
+       return retval ? retval : (ssize_t) count;
+}
+static ZFCP_DEV_ATTR(adapter, failed, S_IWUSR | S_IRUGO,
+                    zfcp_sysfs_adapter_failed_show,
+                    zfcp_sysfs_adapter_failed_store);
 
 static ssize_t zfcp_sysfs_port_rescan_store(struct device *dev,
                                            struct device_attribute *attr,
                                            const char *buf, size_t count)
 {
-       struct zfcp_adapter *adapter = dev_get_drvdata(dev);
-       int ret;
+       struct ccw_device *cdev = to_ccwdev(dev);
+       struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
+
+       if (!adapter)
+               return -ENODEV;
 
-       if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_REMOVE)
-               return -EBUSY;
+       /* sync the user-space- with the kernel-invocation of scan_work */
+       queue_work(adapter->work_queue, &adapter->scan_work);
+       flush_work(&adapter->scan_work);
+       zfcp_ccw_adapter_put(adapter);
 
-       ret = zfcp_scan_ports(adapter);
-       return ret ? ret : (ssize_t) count;
+       return (ssize_t) count;
 }
 static ZFCP_DEV_ATTR(adapter, port_rescan, S_IWUSR, NULL,
                     zfcp_sysfs_port_rescan_store);
@@ -136,44 +232,34 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
                                            struct device_attribute *attr,
                                            const char *buf, size_t count)
 {
-       struct zfcp_adapter *adapter = dev_get_drvdata(dev);
+       struct ccw_device *cdev = to_ccwdev(dev);
+       struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
        struct zfcp_port *port;
        u64 wwpn;
-       int retval = 0;
-       LIST_HEAD(port_remove_lh);
+       int retval = -EINVAL;
 
-       down(&zfcp_data.config_sema);
-       if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_REMOVE) {
-               retval = -EBUSY;
-               goto out;
-       }
+       if (!adapter)
+               return -ENODEV;
 
-       if (strict_strtoull(buf, 0, (unsigned long long *) &wwpn)) {
-               retval = -EINVAL;
+       if (strict_strtoull(buf, 0, (unsigned long long *) &wwpn))
                goto out;
-       }
 
-       write_lock_irq(&zfcp_data.config_lock);
        port = zfcp_get_port_by_wwpn(adapter, wwpn);
-       if (port && (atomic_read(&port->refcount) == 0)) {
-               zfcp_port_get(port);
-               atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
-               list_move(&port->list, &port_remove_lh);
-       } else
-               port = NULL;
-       write_unlock_irq(&zfcp_data.config_lock);
-
-       if (!port) {
-               retval = -ENXIO;
+       if (!port)
                goto out;
-       }
+       else
+               retval = 0;
+
+       write_lock_irq(&adapter->port_list_lock);
+       list_del(&port->list);
+       write_unlock_irq(&adapter->port_list_lock);
+
+       put_device(&port->dev);
 
        zfcp_erp_port_shutdown(port, 0, "syprs_1", NULL);
-       zfcp_erp_wait(adapter);
-       zfcp_port_put(port);
-       zfcp_port_dequeue(port);
+       zfcp_device_unregister(&port->dev, &zfcp_sysfs_port_attrs);
  out:
-       up(&zfcp_data.config_sema);
+       zfcp_ccw_adapter_put(adapter);
        return retval ? retval : (ssize_t) count;
 }
 static ZFCP_DEV_ATTR(adapter, port_remove, S_IWUSR, NULL,
@@ -202,32 +288,16 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev,
                                         struct device_attribute *attr,
                                         const char *buf, size_t count)
 {
-       struct zfcp_port *port = dev_get_drvdata(dev);
-       struct zfcp_unit *unit;
+       struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
        u64 fcp_lun;
-       int retval = -EINVAL;
-
-       down(&zfcp_data.config_sema);
-       if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_REMOVE) {
-               retval = -EBUSY;
-               goto out;
-       }
 
        if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun))
-               goto out;
-
-       unit = zfcp_unit_enqueue(port, fcp_lun);
-       if (IS_ERR(unit))
-               goto out;
+               return -EINVAL;
 
-       retval = 0;
+       if (zfcp_unit_add(port, fcp_lun))
+               return -EINVAL;
 
-       zfcp_erp_unit_reopen(unit, 0, "syuas_1", NULL);
-       zfcp_erp_wait(unit->port->adapter);
-       zfcp_unit_put(unit);
-out:
-       up(&zfcp_data.config_sema);
-       return retval ? retval : (ssize_t) count;
+       return count;
 }
 static DEVICE_ATTR(unit_add, S_IWUSR, NULL, zfcp_sysfs_unit_add_store);
 
@@ -235,55 +305,16 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
                                            struct device_attribute *attr,
                                            const char *buf, size_t count)
 {
-       struct zfcp_port *port = dev_get_drvdata(dev);
-       struct zfcp_unit *unit;
+       struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
        u64 fcp_lun;
-       int retval = 0;
-       LIST_HEAD(unit_remove_lh);
-
-       down(&zfcp_data.config_sema);
-       if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_REMOVE) {
-               retval = -EBUSY;
-               goto out;
-       }
-
-       if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) {
-               retval = -EINVAL;
-               goto out;
-       }
-
-       write_lock_irq(&zfcp_data.config_lock);
-       unit = zfcp_get_unit_by_lun(port, fcp_lun);
-       if (unit) {
-               write_unlock_irq(&zfcp_data.config_lock);
-               /* wait for possible timeout during SCSI probe */
-               flush_work(&unit->scsi_work);
-               write_lock_irq(&zfcp_data.config_lock);
-
-               if (atomic_read(&unit->refcount) == 0) {
-                       zfcp_unit_get(unit);
-                       atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE,
-                                       &unit->status);
-                       list_move(&unit->list, &unit_remove_lh);
-               } else {
-                       unit = NULL;
-               }
-       }
 
-       write_unlock_irq(&zfcp_data.config_lock);
+       if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun))
+               return -EINVAL;
 
-       if (!unit) {
-               retval = -ENXIO;
-               goto out;
-       }
+       if (zfcp_unit_remove(port, fcp_lun))
+               return -EINVAL;
 
-       zfcp_erp_unit_shutdown(unit, 0, "syurs_1", NULL);
-       zfcp_erp_wait(unit->port->adapter);
-       zfcp_unit_put(unit);
-       zfcp_unit_dequeue(unit);
-out:
-       up(&zfcp_data.config_sema);
-       return retval ? retval : (ssize_t) count;
+       return count;
 }
 static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store);
 
@@ -324,9 +355,9 @@ zfcp_sysfs_unit_##_name##_latency_show(struct device *dev,          \
                                       struct device_attribute *attr,   \
                                       char *buf) {                     \
        struct scsi_device *sdev = to_scsi_device(dev);                 \
-       struct zfcp_unit *unit = sdev->hostdata;                        \
-       struct zfcp_latencies *lat = &unit->latencies;                  \
-       struct zfcp_adapter *adapter = unit->port->adapter;             \
+       struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);           \
+       struct zfcp_latencies *lat = &zfcp_sdev->latencies;             \
+       struct zfcp_adapter *adapter = zfcp_sdev->port->adapter;        \
        unsigned long long fsum, fmin, fmax, csum, cmin, cmax, cc;      \
                                                                        \
        spin_lock_bh(&lat->lock);                                       \
@@ -355,8 +386,8 @@ zfcp_sysfs_unit_##_name##_latency_store(struct device *dev,         \
                                        const char *buf, size_t count)  \
 {                                                                      \
        struct scsi_device *sdev = to_scsi_device(dev);                 \
-       struct zfcp_unit *unit = sdev->hostdata;                        \
-       struct zfcp_latencies *lat = &unit->latencies;                  \
+       struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);           \
+       struct zfcp_latencies *lat = &zfcp_sdev->latencies;             \
        unsigned long flags;                                            \
                                                                        \
        spin_lock_irqsave(&lat->lock, flags);                           \
@@ -384,19 +415,28 @@ static ssize_t zfcp_sysfs_scsi_##_name##_show(struct device *dev, \
                                              struct device_attribute *attr,\
                                              char *buf)                 \
 {                                                                        \
-       struct scsi_device *sdev  = to_scsi_device(dev);                 \
-       struct zfcp_unit *unit = sdev->hostdata;                         \
+       struct scsi_device *sdev = to_scsi_device(dev);                  \
+       struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);            \
+       struct zfcp_port *port = zfcp_sdev->port;                        \
                                                                         \
        return sprintf(buf, _format, _value);                            \
 }                                                                        \
 static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_scsi_##_name##_show, NULL);
 
 ZFCP_DEFINE_SCSI_ATTR(hba_id, "%s\n",
-                     dev_name(&unit->port->adapter->ccw_device->dev));
+                     dev_name(&port->adapter->ccw_device->dev));
 ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n",
-                     (unsigned long long) unit->port->wwpn);
-ZFCP_DEFINE_SCSI_ATTR(fcp_lun, "0x%016llx\n",
-                     (unsigned long long) unit->fcp_lun);
+                     (unsigned long long) port->wwpn);
+
+static ssize_t zfcp_sysfs_scsi_fcp_lun_show(struct device *dev,
+                                           struct device_attribute *attr,
+                                           char *buf)
+{
+       struct scsi_device *sdev = to_scsi_device(dev);
+
+       return sprintf(buf, "0x%016llx\n", zfcp_scsi_dev_lun(sdev));
+}
+static DEVICE_ATTR(fcp_lun, S_IRUGO, zfcp_sysfs_scsi_fcp_lun_show, NULL);
 
 struct device_attribute *zfcp_sysfs_sdev_attrs[] = {
        &dev_attr_fcp_lun,
@@ -425,7 +465,7 @@ static ssize_t zfcp_sysfs_adapter_util_show(struct device *dev,
        if (!qtcb_port)
                return -ENOMEM;
 
-       retval = zfcp_fsf_exchange_port_data_sync(adapter, qtcb_port);
+       retval = zfcp_fsf_exchange_port_data_sync(adapter->qdio, qtcb_port);
        if (!retval)
                retval = sprintf(buf, "%u %u %u\n", qtcb_port->cp_util,
                                 qtcb_port->cb_util, qtcb_port->a_util);
@@ -451,7 +491,7 @@ static int zfcp_sysfs_adapter_ex_config(struct device *dev,
        if (!qtcb_config)
                return -ENOMEM;
 
-       retval = zfcp_fsf_exchange_config_data_sync(adapter, qtcb_config);
+       retval = zfcp_fsf_exchange_config_data_sync(adapter->qdio, qtcb_config);
        if (!retval)
                *stat_inf = qtcb_config->stat_info;
 
@@ -492,11 +532,16 @@ static ssize_t zfcp_sysfs_adapter_q_full_show(struct device *dev,
                                              char *buf)
 {
        struct Scsi_Host *scsi_host = class_to_shost(dev);
-       struct zfcp_adapter *adapter =
-               (struct zfcp_adapter *) scsi_host->hostdata[0];
+       struct zfcp_qdio *qdio =
+               ((struct zfcp_adapter *) scsi_host->hostdata[0])->qdio;
+       u64 util;
+
+       spin_lock_bh(&qdio->stat_lock);
+       util = qdio->req_q_util;
+       spin_unlock_bh(&qdio->stat_lock);
 
-       return sprintf(buf, "%d %llu\n", atomic_read(&adapter->qdio_outb_full),
-                      (unsigned long long)adapter->req_q_util);
+       return sprintf(buf, "%d %llu\n", atomic_read(&qdio->req_q_full),
+                      (unsigned long long)util);
 }
 static DEVICE_ATTR(queue_full, S_IRUGO, zfcp_sysfs_adapter_q_full_show, NULL);