diff options
Diffstat (limited to 'drivers/s390/scsi/zfcp_sysfs.c')
-rw-r--r-- | drivers/s390/scsi/zfcp_sysfs.c | 221 |
1 files changed, 111 insertions, 110 deletions
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c index b4561c86e230..2f2c54f4718f 100644 --- a/drivers/s390/scsi/zfcp_sysfs.c +++ b/drivers/s390/scsi/zfcp_sysfs.c | |||
@@ -68,63 +68,96 @@ ZFCP_DEFINE_ATTR(zfcp_port, port, access_denied, "%d\n", | |||
68 | ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0); | 68 | ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0); |
69 | 69 | ||
70 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, status, "0x%08x\n", | 70 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, status, "0x%08x\n", |
71 | atomic_read(&unit->status)); | 71 | zfcp_unit_sdev_status(unit)); |
72 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, in_recovery, "%d\n", | 72 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, in_recovery, "%d\n", |
73 | (atomic_read(&unit->status) & | 73 | (zfcp_unit_sdev_status(unit) & |
74 | ZFCP_STATUS_COMMON_ERP_INUSE) != 0); | 74 | ZFCP_STATUS_COMMON_ERP_INUSE) != 0); |
75 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_denied, "%d\n", | 75 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_denied, "%d\n", |
76 | (atomic_read(&unit->status) & | 76 | (zfcp_unit_sdev_status(unit) & |
77 | ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0); | 77 | ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0); |
78 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_shared, "%d\n", | 78 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_shared, "%d\n", |
79 | (atomic_read(&unit->status) & | 79 | (zfcp_unit_sdev_status(unit) & |
80 | ZFCP_STATUS_UNIT_SHARED) != 0); | 80 | ZFCP_STATUS_LUN_SHARED) != 0); |
81 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_readonly, "%d\n", | 81 | ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_readonly, "%d\n", |
82 | (atomic_read(&unit->status) & | 82 | (zfcp_unit_sdev_status(unit) & |
83 | ZFCP_STATUS_UNIT_READONLY) != 0); | 83 | ZFCP_STATUS_LUN_READONLY) != 0); |
84 | 84 | ||
85 | #define ZFCP_SYSFS_FAILED(_feat_def, _feat, _adapter, _mod_id, _reopen_id) \ | 85 | static ssize_t zfcp_sysfs_port_failed_show(struct device *dev, |
86 | static ssize_t zfcp_sysfs_##_feat##_failed_show(struct device *dev, \ | 86 | struct device_attribute *attr, |
87 | struct device_attribute *attr, \ | 87 | char *buf) |
88 | char *buf) \ | 88 | { |
89 | { \ | 89 | struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); |
90 | struct _feat_def *_feat = container_of(dev, struct _feat_def, dev); \ | 90 | |
91 | \ | 91 | if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_FAILED) |
92 | if (atomic_read(&_feat->status) & ZFCP_STATUS_COMMON_ERP_FAILED) \ | 92 | return sprintf(buf, "1\n"); |
93 | return sprintf(buf, "1\n"); \ | 93 | |
94 | else \ | 94 | return sprintf(buf, "0\n"); |
95 | return sprintf(buf, "0\n"); \ | 95 | } |
96 | } \ | 96 | |
97 | static ssize_t zfcp_sysfs_##_feat##_failed_store(struct device *dev, \ | 97 | static ssize_t zfcp_sysfs_port_failed_store(struct device *dev, |
98 | struct device_attribute *attr,\ | 98 | struct device_attribute *attr, |
99 | const char *buf, size_t count)\ | 99 | const char *buf, size_t count) |
100 | { \ | 100 | { |
101 | struct _feat_def *_feat = container_of(dev, struct _feat_def, dev); \ | 101 | struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); |
102 | unsigned long val; \ | 102 | unsigned long val; |
103 | int retval = 0; \ | 103 | |
104 | \ | 104 | if (strict_strtoul(buf, 0, &val) || val != 0) |
105 | if (!(_feat && get_device(&_feat->dev))) \ | 105 | return -EINVAL; |
106 | return -EBUSY; \ | 106 | |
107 | \ | 107 | zfcp_erp_set_port_status(port, ZFCP_STATUS_COMMON_RUNNING); |
108 | if (strict_strtoul(buf, 0, &val) || val != 0) { \ | 108 | zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, "sypfai2", |
109 | retval = -EINVAL; \ | 109 | NULL); |
110 | goto out; \ | 110 | zfcp_erp_wait(port->adapter); |
111 | } \ | ||
112 | \ | ||
113 | zfcp_erp_modify_##_feat##_status(_feat, _mod_id, NULL, \ | ||
114 | ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET);\ | ||
115 | zfcp_erp_##_feat##_reopen(_feat, ZFCP_STATUS_COMMON_ERP_FAILED, \ | ||
116 | _reopen_id, NULL); \ | ||
117 | zfcp_erp_wait(_adapter); \ | ||
118 | out: \ | ||
119 | put_device(&_feat->dev); \ | ||
120 | return retval ? retval : (ssize_t) count; \ | ||
121 | } \ | ||
122 | static ZFCP_DEV_ATTR(_feat, failed, S_IWUSR | S_IRUGO, \ | ||
123 | zfcp_sysfs_##_feat##_failed_show, \ | ||
124 | zfcp_sysfs_##_feat##_failed_store); | ||
125 | 111 | ||
126 | ZFCP_SYSFS_FAILED(zfcp_port, port, port->adapter, "sypfai1", "sypfai2"); | 112 | return count; |
127 | ZFCP_SYSFS_FAILED(zfcp_unit, unit, unit->port->adapter, "syufai1", "syufai2"); | 113 | } |
114 | static ZFCP_DEV_ATTR(port, failed, S_IWUSR | S_IRUGO, | ||
115 | zfcp_sysfs_port_failed_show, | ||
116 | zfcp_sysfs_port_failed_store); | ||
117 | |||
118 | static ssize_t zfcp_sysfs_unit_failed_show(struct device *dev, | ||
119 | struct device_attribute *attr, | ||
120 | char *buf) | ||
121 | { | ||
122 | struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev); | ||
123 | struct scsi_device *sdev; | ||
124 | unsigned int status, failed = 1; | ||
125 | |||
126 | sdev = zfcp_unit_sdev(unit); | ||
127 | if (sdev) { | ||
128 | status = atomic_read(&sdev_to_zfcp(sdev)->status); | ||
129 | failed = status & ZFCP_STATUS_COMMON_ERP_FAILED ? 1 : 0; | ||
130 | scsi_device_put(sdev); | ||
131 | } | ||
132 | |||
133 | return sprintf(buf, "%d\n", failed); | ||
134 | } | ||
135 | |||
136 | static ssize_t zfcp_sysfs_unit_failed_store(struct device *dev, | ||
137 | struct device_attribute *attr, | ||
138 | const char *buf, size_t count) | ||
139 | { | ||
140 | struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev); | ||
141 | unsigned long val; | ||
142 | struct scsi_device *sdev; | ||
143 | |||
144 | if (strict_strtoul(buf, 0, &val) || val != 0) | ||
145 | return -EINVAL; | ||
146 | |||
147 | sdev = zfcp_unit_sdev(unit); | ||
148 | if (sdev) { | ||
149 | zfcp_erp_set_lun_status(sdev, ZFCP_STATUS_COMMON_RUNNING); | ||
150 | zfcp_erp_lun_reopen(sdev, ZFCP_STATUS_COMMON_ERP_FAILED, | ||
151 | "syufai2", NULL); | ||
152 | zfcp_erp_wait(unit->port->adapter); | ||
153 | } else | ||
154 | zfcp_unit_scsi_scan(unit); | ||
155 | |||
156 | return count; | ||
157 | } | ||
158 | static ZFCP_DEV_ATTR(unit, failed, S_IWUSR | S_IRUGO, | ||
159 | zfcp_sysfs_unit_failed_show, | ||
160 | zfcp_sysfs_unit_failed_store); | ||
128 | 161 | ||
129 | static ssize_t zfcp_sysfs_adapter_failed_show(struct device *dev, | 162 | static ssize_t zfcp_sysfs_adapter_failed_show(struct device *dev, |
130 | struct device_attribute *attr, | 163 | struct device_attribute *attr, |
@@ -163,8 +196,7 @@ static ssize_t zfcp_sysfs_adapter_failed_store(struct device *dev, | |||
163 | goto out; | 196 | goto out; |
164 | } | 197 | } |
165 | 198 | ||
166 | zfcp_erp_modify_adapter_status(adapter, "syafai1", NULL, | 199 | zfcp_erp_set_adapter_status(adapter, ZFCP_STATUS_COMMON_RUNNING); |
167 | ZFCP_STATUS_COMMON_RUNNING, ZFCP_SET); | ||
168 | zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, | 200 | zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, |
169 | "syafai2", NULL); | 201 | "syafai2", NULL); |
170 | zfcp_erp_wait(adapter); | 202 | zfcp_erp_wait(adapter); |
@@ -257,28 +289,15 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev, | |||
257 | const char *buf, size_t count) | 289 | const char *buf, size_t count) |
258 | { | 290 | { |
259 | struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); | 291 | struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); |
260 | struct zfcp_unit *unit; | ||
261 | u64 fcp_lun; | 292 | u64 fcp_lun; |
262 | int retval = -EINVAL; | ||
263 | |||
264 | if (!(port && get_device(&port->dev))) | ||
265 | return -EBUSY; | ||
266 | 293 | ||
267 | if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) | 294 | if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) |
268 | goto out; | 295 | return -EINVAL; |
269 | 296 | ||
270 | unit = zfcp_unit_enqueue(port, fcp_lun); | 297 | if (zfcp_unit_add(port, fcp_lun)) |
271 | if (IS_ERR(unit)) | 298 | return -EINVAL; |
272 | goto out; | ||
273 | else | ||
274 | retval = 0; | ||
275 | 299 | ||
276 | zfcp_erp_unit_reopen(unit, 0, "syuas_1", NULL); | 300 | return count; |
277 | zfcp_erp_wait(unit->port->adapter); | ||
278 | zfcp_scsi_scan(unit); | ||
279 | out: | ||
280 | put_device(&port->dev); | ||
281 | return retval ? retval : (ssize_t) count; | ||
282 | } | 301 | } |
283 | static DEVICE_ATTR(unit_add, S_IWUSR, NULL, zfcp_sysfs_unit_add_store); | 302 | static DEVICE_ATTR(unit_add, S_IWUSR, NULL, zfcp_sysfs_unit_add_store); |
284 | 303 | ||
@@ -287,42 +306,15 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev, | |||
287 | const char *buf, size_t count) | 306 | const char *buf, size_t count) |
288 | { | 307 | { |
289 | struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); | 308 | struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); |
290 | struct zfcp_unit *unit; | ||
291 | u64 fcp_lun; | 309 | u64 fcp_lun; |
292 | int retval = -EINVAL; | ||
293 | struct scsi_device *sdev; | ||
294 | |||
295 | if (!(port && get_device(&port->dev))) | ||
296 | return -EBUSY; | ||
297 | 310 | ||
298 | if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) | 311 | if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) |
299 | goto out; | 312 | return -EINVAL; |
300 | 313 | ||
301 | unit = zfcp_get_unit_by_lun(port, fcp_lun); | 314 | if (zfcp_unit_remove(port, fcp_lun)) |
302 | if (!unit) | 315 | return -EINVAL; |
303 | goto out; | ||
304 | else | ||
305 | retval = 0; | ||
306 | |||
307 | sdev = scsi_device_lookup(port->adapter->scsi_host, 0, | ||
308 | port->starget_id, | ||
309 | scsilun_to_int((struct scsi_lun *)&fcp_lun)); | ||
310 | if (sdev) { | ||
311 | scsi_remove_device(sdev); | ||
312 | scsi_device_put(sdev); | ||
313 | } | ||
314 | |||
315 | write_lock_irq(&port->unit_list_lock); | ||
316 | list_del(&unit->list); | ||
317 | write_unlock_irq(&port->unit_list_lock); | ||
318 | |||
319 | put_device(&unit->dev); | ||
320 | 316 | ||
321 | zfcp_erp_unit_shutdown(unit, 0, "syurs_1", NULL); | 317 | return count; |
322 | zfcp_device_unregister(&unit->dev, &zfcp_sysfs_unit_attrs); | ||
323 | out: | ||
324 | put_device(&port->dev); | ||
325 | return retval ? retval : (ssize_t) count; | ||
326 | } | 318 | } |
327 | static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store); | 319 | static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store); |
328 | 320 | ||
@@ -363,9 +355,9 @@ zfcp_sysfs_unit_##_name##_latency_show(struct device *dev, \ | |||
363 | struct device_attribute *attr, \ | 355 | struct device_attribute *attr, \ |
364 | char *buf) { \ | 356 | char *buf) { \ |
365 | struct scsi_device *sdev = to_scsi_device(dev); \ | 357 | struct scsi_device *sdev = to_scsi_device(dev); \ |
366 | struct zfcp_unit *unit = sdev->hostdata; \ | 358 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \ |
367 | struct zfcp_latencies *lat = &unit->latencies; \ | 359 | struct zfcp_latencies *lat = &zfcp_sdev->latencies; \ |
368 | struct zfcp_adapter *adapter = unit->port->adapter; \ | 360 | struct zfcp_adapter *adapter = zfcp_sdev->port->adapter; \ |
369 | unsigned long long fsum, fmin, fmax, csum, cmin, cmax, cc; \ | 361 | unsigned long long fsum, fmin, fmax, csum, cmin, cmax, cc; \ |
370 | \ | 362 | \ |
371 | spin_lock_bh(&lat->lock); \ | 363 | spin_lock_bh(&lat->lock); \ |
@@ -394,8 +386,8 @@ zfcp_sysfs_unit_##_name##_latency_store(struct device *dev, \ | |||
394 | const char *buf, size_t count) \ | 386 | const char *buf, size_t count) \ |
395 | { \ | 387 | { \ |
396 | struct scsi_device *sdev = to_scsi_device(dev); \ | 388 | struct scsi_device *sdev = to_scsi_device(dev); \ |
397 | struct zfcp_unit *unit = sdev->hostdata; \ | 389 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \ |
398 | struct zfcp_latencies *lat = &unit->latencies; \ | 390 | struct zfcp_latencies *lat = &zfcp_sdev->latencies; \ |
399 | unsigned long flags; \ | 391 | unsigned long flags; \ |
400 | \ | 392 | \ |
401 | spin_lock_irqsave(&lat->lock, flags); \ | 393 | spin_lock_irqsave(&lat->lock, flags); \ |
@@ -423,19 +415,28 @@ static ssize_t zfcp_sysfs_scsi_##_name##_show(struct device *dev, \ | |||
423 | struct device_attribute *attr,\ | 415 | struct device_attribute *attr,\ |
424 | char *buf) \ | 416 | char *buf) \ |
425 | { \ | 417 | { \ |
426 | struct scsi_device *sdev = to_scsi_device(dev); \ | 418 | struct scsi_device *sdev = to_scsi_device(dev); \ |
427 | struct zfcp_unit *unit = sdev->hostdata; \ | 419 | struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \ |
420 | struct zfcp_port *port = zfcp_sdev->port; \ | ||
428 | \ | 421 | \ |
429 | return sprintf(buf, _format, _value); \ | 422 | return sprintf(buf, _format, _value); \ |
430 | } \ | 423 | } \ |
431 | static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_scsi_##_name##_show, NULL); | 424 | static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_scsi_##_name##_show, NULL); |
432 | 425 | ||
433 | ZFCP_DEFINE_SCSI_ATTR(hba_id, "%s\n", | 426 | ZFCP_DEFINE_SCSI_ATTR(hba_id, "%s\n", |
434 | dev_name(&unit->port->adapter->ccw_device->dev)); | 427 | dev_name(&port->adapter->ccw_device->dev)); |
435 | ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n", | 428 | ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n", |
436 | (unsigned long long) unit->port->wwpn); | 429 | (unsigned long long) port->wwpn); |
437 | ZFCP_DEFINE_SCSI_ATTR(fcp_lun, "0x%016llx\n", | 430 | |
438 | (unsigned long long) unit->fcp_lun); | 431 | static ssize_t zfcp_sysfs_scsi_fcp_lun_show(struct device *dev, |
432 | struct device_attribute *attr, | ||
433 | char *buf) | ||
434 | { | ||
435 | struct scsi_device *sdev = to_scsi_device(dev); | ||
436 | |||
437 | return sprintf(buf, "0x%016llx\n", zfcp_scsi_dev_lun(sdev)); | ||
438 | } | ||
439 | static DEVICE_ATTR(fcp_lun, S_IRUGO, zfcp_sysfs_scsi_fcp_lun_show, NULL); | ||
439 | 440 | ||
440 | struct device_attribute *zfcp_sysfs_sdev_attrs[] = { | 441 | struct device_attribute *zfcp_sysfs_sdev_attrs[] = { |
441 | &dev_attr_fcp_lun, | 442 | &dev_attr_fcp_lun, |