aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorSteffen Maier <maier@linux.vnet.ibm.com>2014-11-13 08:59:47 -0500
committerChristoph Hellwig <hch@lst.de>2014-11-20 03:11:29 -0500
commitc8bba1443573055f4836c9f3ab5638d25b8d8d5c (patch)
tree1f041a5ad4b5ee0c026c6e250e23a19ec7c48b91 /drivers/s390
parent9f30b674759b9a2da25aefe25d885161d8a911cb (diff)
zfcp: bring back unit sysfs attributes for automatic LUN scan
Through sysfs attributes, zfcp unit objects provide a trigger for manual LUN recovery and export information for problem determination. With commit f8210e34887e1feb977a9b6b8caa086855af40c9 "[SCSI] zfcp: Allow midlayer to scan for LUNs when running in NPIV mode" and when attaching SCSI devices through this new optional method, no more zfcp unit objects are allocated for such SCSI devices. Hence, the above-mentioned trigger and information were missing. The information and context is located in SCSI transport device data since b62a8d9b45b971a67a0f8413338c230e3117dff5 "[SCSI] zfcp: Use SCSI device data zfcp_scsi_dev instead of zfcp_unit" 57c237731b92fadc7d44824276313ec330b1989b "[SCSI] zfcp: Add zfcp private struct as SCSI device driver data" Hence, introduce the trigger and the information unconditionally for all SCSI devices attached through zfcp. We prefix the attribute names with 'zfcp_' to prevent collisions and to avoid mix-ups such as with the common 'state' attribute. Since some of the new attribute views do not need zfcp_port in the ZFCP_DEFINE_SCSI_ATTR helper macro, remove zfcp_port to avoid compiler warnings on unused variable. It's easy to open code the conversion from zfcp_scsi_dev to zfcp_port for the two already existing attributes hba_id and wwpn. Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com> Reviewed-by: Martin Peschke <mpeschke@linux.vnet.ibm.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/scsi/zfcp_sysfs.c52
1 files changed, 49 insertions, 3 deletions
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index 6b6641298f07..a488c09f6e25 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -437,16 +437,15 @@ static ssize_t zfcp_sysfs_scsi_##_name##_show(struct device *dev, \
437{ \ 437{ \
438 struct scsi_device *sdev = to_scsi_device(dev); \ 438 struct scsi_device *sdev = to_scsi_device(dev); \
439 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \ 439 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \
440 struct zfcp_port *port = zfcp_sdev->port; \
441 \ 440 \
442 return sprintf(buf, _format, _value); \ 441 return sprintf(buf, _format, _value); \
443} \ 442} \
444static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_scsi_##_name##_show, NULL); 443static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_scsi_##_name##_show, NULL);
445 444
446ZFCP_DEFINE_SCSI_ATTR(hba_id, "%s\n", 445ZFCP_DEFINE_SCSI_ATTR(hba_id, "%s\n",
447 dev_name(&port->adapter->ccw_device->dev)); 446 dev_name(&zfcp_sdev->port->adapter->ccw_device->dev));
448ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n", 447ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n",
449 (unsigned long long) port->wwpn); 448 (unsigned long long) zfcp_sdev->port->wwpn);
450 449
451static ssize_t zfcp_sysfs_scsi_fcp_lun_show(struct device *dev, 450static ssize_t zfcp_sysfs_scsi_fcp_lun_show(struct device *dev,
452 struct device_attribute *attr, 451 struct device_attribute *attr,
@@ -458,6 +457,49 @@ static ssize_t zfcp_sysfs_scsi_fcp_lun_show(struct device *dev,
458} 457}
459static DEVICE_ATTR(fcp_lun, S_IRUGO, zfcp_sysfs_scsi_fcp_lun_show, NULL); 458static DEVICE_ATTR(fcp_lun, S_IRUGO, zfcp_sysfs_scsi_fcp_lun_show, NULL);
460 459
460ZFCP_DEFINE_SCSI_ATTR(zfcp_access_denied, "%d\n",
461 (atomic_read(&zfcp_sdev->status) &
462 ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0);
463
464static ssize_t zfcp_sysfs_scsi_zfcp_failed_show(struct device *dev,
465 struct device_attribute *attr,
466 char *buf)
467{
468 struct scsi_device *sdev = to_scsi_device(dev);
469 unsigned int status = atomic_read(&sdev_to_zfcp(sdev)->status);
470 unsigned int failed = status & ZFCP_STATUS_COMMON_ERP_FAILED ? 1 : 0;
471
472 return sprintf(buf, "%d\n", failed);
473}
474
475static ssize_t zfcp_sysfs_scsi_zfcp_failed_store(struct device *dev,
476 struct device_attribute *attr,
477 const char *buf, size_t count)
478{
479 struct scsi_device *sdev = to_scsi_device(dev);
480 unsigned long val;
481
482 if (kstrtoul(buf, 0, &val) || val != 0)
483 return -EINVAL;
484
485 zfcp_erp_set_lun_status(sdev, ZFCP_STATUS_COMMON_RUNNING);
486 zfcp_erp_lun_reopen(sdev, ZFCP_STATUS_COMMON_ERP_FAILED,
487 "syufai3");
488 zfcp_erp_wait(sdev_to_zfcp(sdev)->port->adapter);
489
490 return count;
491}
492static DEVICE_ATTR(zfcp_failed, S_IWUSR | S_IRUGO,
493 zfcp_sysfs_scsi_zfcp_failed_show,
494 zfcp_sysfs_scsi_zfcp_failed_store);
495
496ZFCP_DEFINE_SCSI_ATTR(zfcp_in_recovery, "%d\n",
497 (atomic_read(&zfcp_sdev->status) &
498 ZFCP_STATUS_COMMON_ERP_INUSE) != 0);
499
500ZFCP_DEFINE_SCSI_ATTR(zfcp_status, "0x%08x\n",
501 atomic_read(&zfcp_sdev->status));
502
461struct device_attribute *zfcp_sysfs_sdev_attrs[] = { 503struct device_attribute *zfcp_sysfs_sdev_attrs[] = {
462 &dev_attr_fcp_lun, 504 &dev_attr_fcp_lun,
463 &dev_attr_wwpn, 505 &dev_attr_wwpn,
@@ -465,6 +507,10 @@ struct device_attribute *zfcp_sysfs_sdev_attrs[] = {
465 &dev_attr_read_latency, 507 &dev_attr_read_latency,
466 &dev_attr_write_latency, 508 &dev_attr_write_latency,
467 &dev_attr_cmd_latency, 509 &dev_attr_cmd_latency,
510 &dev_attr_zfcp_access_denied,
511 &dev_attr_zfcp_failed,
512 &dev_attr_zfcp_in_recovery,
513 &dev_attr_zfcp_status,
468 NULL 514 NULL
469}; 515};
470 516