Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aperi-dev] IDVT: getHBAPortWWN() doesn't work on 2.6 kernel with recent Qlogic driver

Hi,

https://bugs.eclipse.org/bugs/show_bug.cgi?id=211375

getHBAPortWWN() doesn't work on 2.6 Linux kernels with recent Qlogic driver
that no longer creates file entries under /proc/scsi/ The patch below adds more
code to Simona's fixes for SCSI discovery on 2.6 kernels. There are now two
versions of getHBAPortWWN - one for 2.4 /proc/scsi and another for 2.6 based
/sys/class/fc_host/host#/node_name based discovery

A patch is below. Simona, I'd appreciate your code review if you have time ;-)

Should this fix be checked in for the 0.4 release?

Thanks,
Robert


### Eclipse Workspace Patch 1.0
#P org.eclipse.aperi.agent.data
Index: src/org/eclipse/aperi/agent/probe/ProbeLinux.java
===================================================================
RCS file:
/cvsroot/technology/org.eclipse.aperi/org.eclipse.aperi.agent.data/src/org/eclipse/aperi/agent/probe/ProbeLinux.java,v
retrieving revision 1.8
diff -u -r1.8 ProbeLinux.java
--- src/org/eclipse/aperi/agent/probe/ProbeLinux.java   18 Nov 2007 19:24:28
-0000      1.8
+++ src/org/eclipse/aperi/agent/probe/ProbeLinux.java   29 Nov 2007 06:00:26
-0000
@@ -266,7 +266,6 @@
        final String sysClassScsiHost = new StringBuffer(SYS)
                        .append(CLASS_SCSI_HOST).toString();

-       StringBuffer procBuffer = new StringBuffer(PROC_SCSI);
        Reader fileReader=null;

        File scsiHostDir = new File(sysClassScsiHost);       
@@ -325,13 +324,7 @@
                ctlr.ctlrType = Controller.SCSI;
                ctlr.ctlrInstance = (short) instanceNumber;

-               // Go Get HBA WWN
-               // it seems the port information can not be obtained from sysfs
(yet)
-               // try to get it from /proc/scsi/<driver>/<instance>
-               procBuffer.setLength(PROC_SCSI.length());
-               procBuffer.append("/").append(controllerName);
-               
-               getHBAPortWWN(procBuffer, ctlr); 
+               getHBAPortWWNFromSys(dir1entries[i], ctlr); 

            }catch (IOException e) {
                if (TraceLogger.enableTrace)
@@ -428,7 +421,7 @@
             ctlr.ctlrInstance = (short) x;

             //Go Get HBA WWN
-            getHBAPortWWN(buf, ctlr);
+            getHBAPortWWNFromProc(buf, ctlr);
          }

          buf.setLength(11);
@@ -561,7 +554,64 @@
          throw new GeneralException();
    }

-   private void getHBAPortWWN(StringBuffer buf,  Controller ctlr)
+   private void getHBAPortWWNFromSys(String host, Controller ctlr)
+   {
+   /*
+    * Open up fc_host node_name file and parse Port Number.
+    */
+      String myFile = "/sys/class/fc_host/" + host + "/node_name";
+
+      if (!(new File(myFile)).isFile())
+         return;
+
+      Reader raw;
+      try
+      {
+         raw = new FileReader(myFile);
+      }
+      catch(IOException e)
+      {
+         MessageLog.logException("STA0800W", e, myFile);
+         rc = 4;
+         return;
+      }
+      BufferedReader cooked = new BufferedReader(raw);
+      try
+      {
+         String line;
+         while((line = cooked.readLine()) != null)
+         {
+                if (line.startsWith("0x"))
+                {
+                        try
+                        {
+                                long wwn = Long.valueOf(line.substring(2),
16).longValue();
+                                ctlr.ctlrHBAPortWWN = wwn;
+                                ctlr.ctlrType = Controller.FCAL;
+                        }
+                        catch (StringIndexOutOfBoundsException e)
+                        {
+                                System.out.println("Port Line = " + line);
+                        }
+                        break;
+                }
+         }
+      }
+      catch(IOException e)
+      {
+         MessageLog.logException("STA0800E", e, myFile);
+         rc = 4;
+      }
+      try
+      {
+         cooked.close();
+      }
+      catch(IOException e)
+      {
+      }
+   }
+   
+   private void getHBAPortWWNFromProc(StringBuffer buf,  Controller ctlr)
    {
    /*
     * Open up instance number file and parse looking for Port Number.



Back to the top