Commit c8bba1443573055f4836c9f3ab5638d25b8d8d5c

Authored by Steffen Maier
Committed by Christoph Hellwig
1 parent 9f30b67475

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>

Showing 1 changed file with 49 additions and 3 deletions Side-by-side Diff

drivers/s390/scsi/zfcp_sysfs.c
... ... @@ -437,16 +437,15 @@
437 437 { \
438 438 struct scsi_device *sdev = to_scsi_device(dev); \
439 439 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev); \
440   - struct zfcp_port *port = zfcp_sdev->port; \
441 440 \
442 441 return sprintf(buf, _format, _value); \
443 442 } \
444 443 static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_scsi_##_name##_show, NULL);
445 444  
446 445 ZFCP_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));
448 447 ZFCP_DEFINE_SCSI_ATTR(wwpn, "0x%016llx\n",
449   - (unsigned long long) port->wwpn);
  448 + (unsigned long long) zfcp_sdev->port->wwpn);
450 449  
451 450 static ssize_t zfcp_sysfs_scsi_fcp_lun_show(struct device *dev,
452 451 struct device_attribute *attr,
... ... @@ -458,6 +457,49 @@
458 457 }
459 458 static DEVICE_ATTR(fcp_lun, S_IRUGO, zfcp_sysfs_scsi_fcp_lun_show, NULL);
460 459  
  460 +ZFCP_DEFINE_SCSI_ATTR(zfcp_access_denied, "%d\n",
  461 + (atomic_read(&zfcp_sdev->status) &
  462 + ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0);
  463 +
  464 +static 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 +
  475 +static 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 +}
  492 +static DEVICE_ATTR(zfcp_failed, S_IWUSR | S_IRUGO,
  493 + zfcp_sysfs_scsi_zfcp_failed_show,
  494 + zfcp_sysfs_scsi_zfcp_failed_store);
  495 +
  496 +ZFCP_DEFINE_SCSI_ATTR(zfcp_in_recovery, "%d\n",
  497 + (atomic_read(&zfcp_sdev->status) &
  498 + ZFCP_STATUS_COMMON_ERP_INUSE) != 0);
  499 +
  500 +ZFCP_DEFINE_SCSI_ATTR(zfcp_status, "0x%08x\n",
  501 + atomic_read(&zfcp_sdev->status));
  502 +
461 503 struct device_attribute *zfcp_sysfs_sdev_attrs[] = {
462 504 &dev_attr_fcp_lun,
463 505 &dev_attr_wwpn,
... ... @@ -465,6 +507,10 @@
465 507 &dev_attr_read_latency,
466 508 &dev_attr_write_latency,
467 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 514 NULL
469 515 };
470 516