Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Checkin ProbeLinux.java 1.9 (Re: Retry (Re: [aperi-dev] IDVT: getHBAPortWWN() doesn't work ...

>>> On Tue, Dec 4, 2007 at  4:36 PM, in message
<OF6A3F7279.44BF5091-ONC22573A7.0075D1EF-002573A7.0081AB25@xxxxxxxxxx>, Simona
Constantin <simona_constantin@xxxxxxxxxx> wrote: 
> Hello Robert,
> 
> I think your patch is correct.

Thanks Simona, the code reads out of /sys/class/fc_host/#/port_name
and I verified it works with SLES10 sp1 and a Qlogic driver that uses sysfs
exclusively (no more files in /proc). 

Checked in version 1.9 of ProbeLinux.java and closed bug #211375

Thanks,
Robert

P.S. It seems you been checked in a few related files on December 3rd?
can you share details of those fixes and whether they'll be included in 0.4?

> ---
> Simona Constantin
>                                                                            
>              "Robert Wipfel"                                               
>              <rawipfel@novell.                                             
>              com>                                                       To 
>              Sent by:                  "Aperi Development"                 
>              aperi- dev- bounces         <aperi- dev@xxxxxxxxxxx>             
>              @eclipse.org                                               cc 
>                                                                            
>                                                                    Subject 
>              04/12/2007 05:58          Retry (Re: [aperi- dev] IDVT:        
>              PM                        getHBAPortWWN() doesn't work on     
>                                        2.6      kernel withrecent Qlogic   
>                                        driver)                             
>              Please respond to                                             
>              Aperi Development                                             
>              <aperi- dev@eclips                                             
>                   e.org>                                                   
>                                                                            
>                                                                            
> 
> 
> 
> 
> Retry:
> 
> Code is identical to Simona's last version, with the addition of checking
> for 2.6 kernels, if the port number can't be obtained from /sys, then
> fallback
> to /proc using the same (Simona's) code as for 2.4 kernel.
> 
> 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/e
> clipse/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
> 17:41:27 - 0000
> @@ - 326,12 +326,19 @@
>                 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) {
> +                   // 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);
> +
> +                   getHBAPortWWNFromProc(procBuffer, ctlr);
> +               }
> 
>             }catch (IOException e) {
>                 if (TraceLogger.enableTrace)
> @@ - 428,7 +435,7 @@
>              ctlr.ctlrInstance = (short) x;
> 
>              //Go Get HBA WWN
> -             getHBAPortWWN(buf, ctlr);
> +            getHBAPortWWNFromProc(buf, ctlr);
>           }
> 
>           buf.setLength(11);
> @@ - 561,7 +568,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.
> 
> 
>>>> On Tue, Dec 4, 2007 at  9:08 AM, in message
> <4755197A.C5C7.00CF.0@xxxxxxxxxx>,
> "Robert Wipfel" <rawipfel@xxxxxxxxxx> wrote:
>>>>> 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





Back to the top