aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c49
1 files changed, 17 insertions, 32 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 895a9ff17379..bcbf22ee0aa7 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -474,6 +474,21 @@ static void srp_free_req_data(struct srp_target_port *target)
474 } 474 }
475} 475}
476 476
477/**
478 * srp_del_scsi_host_attr() - Remove attributes defined in the host template.
479 * @shost: SCSI host whose attributes to remove from sysfs.
480 *
481 * Note: Any attributes defined in the host template and that did not exist
482 * before invocation of this function will be ignored.
483 */
484static void srp_del_scsi_host_attr(struct Scsi_Host *shost)
485{
486 struct device_attribute **attr;
487
488 for (attr = shost->hostt->shost_attrs; attr && *attr; ++attr)
489 device_remove_file(&shost->shost_dev, *attr);
490}
491
477static void srp_remove_work(struct work_struct *work) 492static void srp_remove_work(struct work_struct *work)
478{ 493{
479 struct srp_target_port *target = 494 struct srp_target_port *target =
@@ -486,6 +501,7 @@ static void srp_remove_work(struct work_struct *work)
486 list_del(&target->list); 501 list_del(&target->list);
487 spin_unlock(&target->srp_host->target_lock); 502 spin_unlock(&target->srp_host->target_lock);
488 503
504 srp_del_scsi_host_attr(target->scsi_host);
489 srp_remove_host(target->scsi_host); 505 srp_remove_host(target->scsi_host);
490 scsi_remove_host(target->scsi_host); 506 scsi_remove_host(target->scsi_host);
491 ib_destroy_cm_id(target->cm_id); 507 ib_destroy_cm_id(target->cm_id);
@@ -1678,10 +1694,6 @@ static ssize_t show_id_ext(struct device *dev, struct device_attribute *attr,
1678{ 1694{
1679 struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1695 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1680 1696
1681 if (target->state == SRP_TARGET_DEAD ||
1682 target->state == SRP_TARGET_REMOVED)
1683 return -ENODEV;
1684
1685 return sprintf(buf, "0x%016llx\n", 1697 return sprintf(buf, "0x%016llx\n",
1686 (unsigned long long) be64_to_cpu(target->id_ext)); 1698 (unsigned long long) be64_to_cpu(target->id_ext));
1687} 1699}
@@ -1691,10 +1703,6 @@ static ssize_t show_ioc_guid(struct device *dev, struct device_attribute *attr,
1691{ 1703{
1692 struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1704 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1693 1705
1694 if (target->state == SRP_TARGET_DEAD ||
1695 target->state == SRP_TARGET_REMOVED)
1696 return -ENODEV;
1697
1698 return sprintf(buf, "0x%016llx\n", 1706 return sprintf(buf, "0x%016llx\n",
1699 (unsigned long long) be64_to_cpu(target->ioc_guid)); 1707 (unsigned long long) be64_to_cpu(target->ioc_guid));
1700} 1708}
@@ -1704,10 +1712,6 @@ static ssize_t show_service_id(struct device *dev,
1704{ 1712{
1705 struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1713 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1706 1714
1707 if (target->state == SRP_TARGET_DEAD ||
1708 target->state == SRP_TARGET_REMOVED)
1709 return -ENODEV;
1710
1711 return sprintf(buf, "0x%016llx\n", 1715 return sprintf(buf, "0x%016llx\n",
1712 (unsigned long long) be64_to_cpu(target->service_id)); 1716 (unsigned long long) be64_to_cpu(target->service_id));
1713} 1717}
@@ -1717,10 +1721,6 @@ static ssize_t show_pkey(struct device *dev, struct device_attribute *attr,
1717{ 1721{
1718 struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1722 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1719 1723
1720 if (target->state == SRP_TARGET_DEAD ||
1721 target->state == SRP_TARGET_REMOVED)
1722 return -ENODEV;
1723
1724 return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey)); 1724 return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey));
1725} 1725}
1726 1726
@@ -1729,10 +1729,6 @@ static ssize_t show_dgid(struct device *dev, struct device_attribute *attr,
1729{ 1729{
1730 struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1730 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1731 1731
1732 if (target->state == SRP_TARGET_DEAD ||
1733 target->state == SRP_TARGET_REMOVED)
1734 return -ENODEV;
1735
1736 return sprintf(buf, "%pI6\n", target->path.dgid.raw); 1732 return sprintf(buf, "%pI6\n", target->path.dgid.raw);
1737} 1733}
1738 1734
@@ -1741,10 +1737,6 @@ static ssize_t show_orig_dgid(struct device *dev,
1741{ 1737{
1742 struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1738 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1743 1739
1744 if (target->state == SRP_TARGET_DEAD ||
1745 target->state == SRP_TARGET_REMOVED)
1746 return -ENODEV;
1747
1748 return sprintf(buf, "%pI6\n", target->orig_dgid); 1740 return sprintf(buf, "%pI6\n", target->orig_dgid);
1749} 1741}
1750 1742
@@ -1753,10 +1745,6 @@ static ssize_t show_req_lim(struct device *dev,
1753{ 1745{
1754 struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1746 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1755 1747
1756 if (target->state == SRP_TARGET_DEAD ||
1757 target->state == SRP_TARGET_REMOVED)
1758 return -ENODEV;
1759
1760 return sprintf(buf, "%d\n", target->req_lim); 1748 return sprintf(buf, "%d\n", target->req_lim);
1761} 1749}
1762 1750
@@ -1765,10 +1753,6 @@ static ssize_t show_zero_req_lim(struct device *dev,
1765{ 1753{
1766 struct srp_target_port *target = host_to_target(class_to_shost(dev)); 1754 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1767 1755
1768 if (target->state == SRP_TARGET_DEAD ||
1769 target->state == SRP_TARGET_REMOVED)
1770 return -ENODEV;
1771
1772 return sprintf(buf, "%d\n", target->zero_req_lim); 1756 return sprintf(buf, "%d\n", target->zero_req_lim);
1773} 1757}
1774 1758
@@ -2432,6 +2416,7 @@ static void srp_remove_one(struct ib_device *device)
2432 2416
2433 list_for_each_entry_safe(target, tmp_target, 2417 list_for_each_entry_safe(target, tmp_target,
2434 &host->target_list, list) { 2418 &host->target_list, list) {
2419 srp_del_scsi_host_attr(target->scsi_host);
2435 srp_remove_host(target->scsi_host); 2420 srp_remove_host(target->scsi_host);
2436 scsi_remove_host(target->scsi_host); 2421 scsi_remove_host(target->scsi_host);
2437 srp_disconnect_target(target); 2422 srp_disconnect_target(target);