[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aperi-dev] IDVT: getHBAPortWWN() doesn't work on 2.6 kernel withrecent Qlogic driver
|
>>> On Sun, Dec 2, 2007 at 4:46 PM, in message
<OFA187D150.579B4ABD-ONC22573A5.00823367-C22573A5.0082B65A@xxxxxxxxxx>, Simona
Constantin <simona_constantin@xxxxxxxxxx> wrote:
> Hello Robert,
Hi Simona,
> On Red Hat Enterprise Linux AS release 4 (2.6.9- 55.ELsmp), QLogic still
> creates the entries in /proc/scsi/qla2xxx/# . So there should be a check
> and if the getHBAPortWWNFromSys could not retrieve the ctlr.ctlrHBAPortWWN
> then the getHBAPortWWNFromProc should be invoked.
Qlogic says their driver is moving to /sys on 2.6 kernels and they no
longer create file entries in /proc. The code is the same as before for 2.4
kernels, based on discovery in /proc/scsi. For 2.6 we have the FromSys
versus FromProc switch. For drivers on 2.6 that are still using a combination
of /sys and /proc, I've added what you suggested, fallback to FromProc
approach to get the ctlrHBAPortWWN. Patch below:
> I don't know to answer your questions:
> 1. what is missing from the model and why the computers and switches are
> not linked in topology viewer ?
> 2. from what file ( node_name or port_name ) should the WWN be read ?
Not sure about this but I guess at least the port number is set properly
in all cases.
Hth,
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 4 Dec 2007 16:06:05 -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,14 @@
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);
+ ctlr.ctlrHBAPortWWN = 0;
+ // This is how it's supposed to work for 2.6 kernels
+ getHBAPortWWNFromSys(dir1entries[i], ctlr);
+ if (ctlr.ctlrHBAPortWWN == 0) {
+ // Fallback to FromProc approach for older drivers
+ // even if running on 2.6 kernel
+ getHBAPortWWNFromProc(new StringBuffer(dir1entries[i]), ctlr);
+ }
}catch (IOException e) {
if (TraceLogger.enableTrace)
@@ -428,7 +428,7 @@
ctlr.ctlrInstance = (short) x;
//Go Get HBA WWN
- getHBAPortWWN(buf, ctlr);
+ getHBAPortWWNFromProc(buf, ctlr);
}
buf.setLength(11);
@@ -561,7 +561,64 @@
throw new GeneralException();
}
- private void getHBAPortWWN(StringBuffer buf, Controller ctlr)
+ private void getHBAPortWWNFromSys(String host, Controller ctlr)
+ {
+ /*
+ * Open up fc_host port_name file and parse Port Number.
+ */
+ String myFile = "/sys/class/fc_host/" + host + "/port_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.