[PATCH rhel7-alpha2-branch 15/16] Handle offload qla4xxx iscsi devices properly (#823810)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



These kind of devices, when qla4xxx.ql4xdisablesysfsboot=1,
is discovered by anaconda/udev as iscsi device yet it can not
be handled by iscsiadm so we need to treat it specially.

Resolves: rhbz#823810
---
 pyanaconda/storage/devices.py    |   33 +++++++++++++++++++++++++--------
 pyanaconda/storage/devicetree.py |   30 ++++++++++++++++++++----------
 pyanaconda/storage/udev.py       |   28 +++++++++++++++++++++++++---
 3 files changed, 70 insertions(+), 21 deletions(-)

diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index 4c63bb5..237230b 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -3643,19 +3643,36 @@ class iScsiDiskDevice(DiskDevice, NetworkStorageDevice):
         self.ibft = kwargs.pop("ibft")
         self.nic = kwargs.pop("nic")
         self.initiator = kwargs.pop("initiator")
-        DiskDevice.__init__(self, device, **kwargs)
-        NetworkStorageDevice.__init__(self, host_address=self.node.address,
-                                      nic=self.nic)
-        log.debug("created new iscsi disk %s %s:%d via %s:%s" % (self.node.name,
-                                                              self.node.address,
-                                                              self.node.port,
-                                                              self.node.iface,
-                                                              self.nic))
+
+        if self.node is None:
+            # qla4xxx partial offload
+            name = kwargs.pop("fw_name")
+            address = kwargs.pop("fw_address")
+            port = kwargs.pop("fw_port")
+            DiskDevice.__init__(self, device, **kwargs)
+            NetworkStorageDevice.__init__(self,
+                                          host_address=address,
+                                          nic=self.nic)
+            log.debug("created new iscsi disk %s %s:%s using fw initiator %s"
+                      % (name, address, port, self.initiator))
+        else:
+            DiskDevice.__init__(self, device, **kwargs)
+            NetworkStorageDevice.__init__(self, host_address=self.node.address,
+                                          nic=self.nic)
+            log.debug("created new iscsi disk %s %s:%d via %s:%s" % (self.node.name,
+                                                                  self.node.address,
+                                                                  self.node.port,
+                                                                  self.node.iface,
+                                                                  self.nic))
 
     def dracutSetupArgs(self):
         if self.ibft:
             return set(["iscsi_firmware"])
 
+        # qla4xxx partial offload
+        if self.node is None:
+            return set()
+
         address = self.node.address
         # surround ipv6 addresses with []
         if ":" in address:
diff --git a/pyanaconda/storage/devicetree.py b/pyanaconda/storage/devicetree.py
index 561ac5f..5e2b126 100644
--- a/pyanaconda/storage/devicetree.py
+++ b/pyanaconda/storage/devicetree.py
@@ -842,16 +842,26 @@ class DeviceTree(object):
         kwargs = { "serial": serial, "vendor": vendor, "bus": bus }
         if udev_device_is_iscsi(info):
             diskType = iScsiDiskDevice
-            node = self.iscsi.getNode(
-                                   udev_device_get_iscsi_name(info),
-                                   udev_device_get_iscsi_address(info),
-                                   udev_device_get_iscsi_port(info),
-                                   udev_device_get_iscsi_nic(info))
-            kwargs["node"] = node
-            kwargs["nic"] = self.iscsi.ifaces.get(node.iface, node.iface)
-            kwargs["ibft"] = node in self.iscsi.ibftNodes
-            kwargs["initiator"] = self.iscsi.initiator
-            log.info("%s is an iscsi disk" % name)
+            initiator = udev_device_get_iscsi_initiator(info)
+            target = udev_device_get_iscsi_name(info)
+            address = udev_device_get_iscsi_address(info)
+            port = udev_device_get_iscsi_port(info)
+            nic = udev_device_get_iscsi_nic(info)
+            kwargs["initiator"] = initiator
+            if initiator == self.iscsi.initiator:
+                node = self.iscsi.getNode(target, address, port, nic)
+                kwargs["node"] = node
+                kwargs["ibft"] = node in self.iscsi.ibftNodes
+                kwargs["nic"] = self.iscsi.ifaces.get(node.iface, node.iface)
+                log.info("%s is an iscsi disk" % name)
+            else:
+                # qla4xxx partial offload
+                kwargs["node"] = None
+                kwargs["ibft"] = False
+                kwargs["nic"] = "offload:not_accessible_via_iscsiadm"
+                kwargs["fw_address"] = address
+                kwargs["fw_port"] = port
+                kwargs["fw_name"] = name
         elif udev_device_is_fcoe(info):
             diskType = FcoeDiskDevice
             kwargs["nic"]        = udev_device_get_fcoe_nic(info)
diff --git a/pyanaconda/storage/udev.py b/pyanaconda/storage/udev.py
index 09e9c25..d5a08af 100644
--- a/pyanaconda/storage/udev.py
+++ b/pyanaconda/storage/udev.py
@@ -556,19 +556,41 @@ def udev_device_get_iscsi_port(info):
     # IPV6 contains : within the address, the part after the last : is the port
     return path_components[address_field].split(":")[-1]
 
-def udev_device_get_iscsi_nic(info):
+def udev_device_get_iscsi_session(info):
     # '/devices/pci0000:00/0000:00:02.0/0000:09:00.0/0000:0a:01.0/0000:0e:00.2/host3/session1/target3:0:0/3:0:0:0/block/sda'
     # The position of sessionX part depends on device
     # (e.g. offload vs. sw; also varies for different offload devs)
+    session = None
     match = re.match('/.*/(session\d+)', info["sysfs_path"])
     if match:
         session = match.groups()[0]
+    else:
+        log.error("udev_device_get_iscsi_session: session not found in %s" % info)
+    return session
+
+
+def udev_device_get_iscsi_nic(info):
+    iface = None
+    session = udev_device_get_iscsi_session(info)
+    if session:
         iface = open("/sys/class/iscsi_session/%s/ifacename" %
                      session).read().strip()
-    else:
-        iface = None
     return iface
 
+def udev_device_get_iscsi_initiator(info):
+    initiator = None
+    if udev_device_is_partoff_iscsi(info):
+        host = re.match('.*/(host\d+)', info["sysfs_path"]).groups()[0]
+        initiator = open("/sys/class/iscsi_host/%s/initiatorname" %
+                         host).read().strip()
+    else:
+        session = udev_device_get_iscsi_session(info)
+        if session:
+            initiator = open("/sys/class/iscsi_session/%s/initiatorname" %
+                             session).read().strip()
+    return initiator
+
+
 # fcoe disks have ID_PATH in the form of:
 # For FCoE directly over the NIC (so no VLAN and thus no DCB):
 # pci-eth#-fc-${id}
-- 
1.7.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux