Wednesday, July 06, 2005

Getting LUNs for MPxIO devices

I wrote simple C program which displays basic info about FC HBAs in a system and lets you see available targets on each HBA with information like LUN number, target ID, WWPN, etc.
Why did I write it? Well, when you have a lot of devices under MPxIO and you often add new LUNs, then there's no simple (I mean quick) way to figure out which MPxIO devices are which. Then if there're several arrays attached it's getting even worse. Normally you can use luxadm but with a lot of LUNs it actually takes some time to find given LUN.
Program compiles and works on Solaris 10, makes use of libHBAAPI so not all HBAs will work (depends on driver). Qlogic HBAs with standard Solaris drivers works. I don't know about the others. Although this program works (for me at least) - I must admit that it's not a clean code and I'm not a programmer, some things are done ugly (static arrays, missing safe checks, etc.) - I have no time to correct this ('coz it works).

btw: looks like there's a tool named fcinfo in SX which can give the same (and more) info (but there's none in S10).

Ok, some example output.


bash-3.00# ./hba_inq
Number of HBAs: 2


HBA(0) name: QLogic Corp.-2200-0
Manufacturer : QLogic Corp.
SerialNumber :
Model : 2200
Description : 2200
SymbolicName :
HardwareVersion :
DriverVersion : 20050104-1.58
OptionROMVersion : 1
FirmwareVersion : 2.1.142
DriverName : SunFC Qlogic FCA v20050104-1.58
NumberOfPorts : 1
NodeWWN : 20:00:00:e0:8b:05:3e:7c


HBA(1) name: QLogic Corp.-2200-1
Manufacturer : QLogic Corp.
SerialNumber :
Model : 2200
Description : 2200
SymbolicName :
HardwareVersion :
DriverVersion : 20050104-1.58
OptionROMVersion : 1
FirmwareVersion : 2.1.142
DriverName : SunFC Qlogic FCA v20050104-1.58
NumberOfPorts : 1
NodeWWN : 20:00:00:e0:8b:01:94:01
bash-3.00#

// another server with less LUNs

bash-3.00# ./hba_inq -l
Number of HBAs: 2


HBA(0) name: QLogic Corp.-2200-0
Manufacturer : QLogic Corp.
SerialNumber :
Model : 2200
Description : 2200
SymbolicName :
HardwareVersion :
DriverVersion : 20050104-1.58
OptionROMVersion : 1
FirmwareVersion : 2.1.142
DriverName : SunFC Qlogic FCA v20050104-1.58
NumberOfPorts : 1
NodeWWN : 20:00:00:e0:8b:01:95:01
NumberOfLUNs : 6
bus 5 target 71424 lun 56 "/dev/rdsk/c4t600A0B80001652440000003C428E0AEBd0s2"
bus 5 target 71424 lun 55 "/dev/rdsk/c4t600A0B80001652440000003B428E0ACBd0s2"
bus 5 target 71424 lun 54 "/dev/rdsk/c4t600A0B80001652440000003A428E0AA7d0s2"
bus 5 target 71424 lun 53 "/dev/rdsk/c4t600A0B800016524400000039428E0A79d0s2"
bus 5 target 71424 lun 52 "/dev/rdsk/c4t600A0B800016524400000037428E0A49d0s2"
bus 5 target 71424 lun 31 "/dev/rdsk/c5t200400A0B8169D18d31s2"


HBA(1) name: QLogic Corp.-2200-1
Manufacturer : QLogic Corp.
SerialNumber :
Model : 2200
Description : 2200
SymbolicName :
HardwareVersion :
DriverVersion : 20050104-1.58
OptionROMVersion : 1
FirmwareVersion : 2.1.142
DriverName : SunFC Qlogic FCA v20050104-1.58
NumberOfPorts : 1
NodeWWN : 20:00:00:e0:8b:05:34:7c
NumberOfLUNs : 6
bus 1 target 135168 lun 56 "/dev/rdsk/c4t600A0B80001652440000003C428E0AEBd0s2"
bus 1 target 135168 lun 55 "/dev/rdsk/c4t600A0B80001652440000003B428E0ACBd0s2"
bus 1 target 135168 lun 54 "/dev/rdsk/c4t600A0B80001652440000003A428E0AA7d0s2"
bus 1 target 135168 lun 53 "/dev/rdsk/c4t600A0B800016524400000039428E0A79d0s2"
bus 1 target 135168 lun 52 "/dev/rdsk/c4t600A0B800016524400000037428E0A49d0s2"
bus 1 target 135168 lun 31 "/dev/rdsk/c1t200500A0B8169D18d31s2"
bash-3.00#

// now another server with a lot of luns
// it's easy to filter by given WWPN
// first see what we have

bash-3.00# cfgadm -al
Ap_Id Type Receptacle Occupant Condition
c0 scsi-bus connected configured unknown
c0::dsk/c0t0d0 disk connected configured unknown
c0::dsk/c0t1d0 disk connected configured unknown
c0::dsk/c0t6d0 CD-ROM connected configured unknown
c1 fc-fabric connected configured unknown
c1::200500a0b8169d18 disk connected configured unknown
c1::5006016008065109 disk connected configured unknown
c2 fc-fabric connected configured unknown
c2::200400a0b8169d18 disk connected configured unknown
c2::5006016108065109 disk connected unconfigured unknown
c2::5006016908065109 disk connected configured unknown
c2::500604843d489c84 disk connected configured unknown
c3 scsi-bus connected configured unknown
c3::dsk/c3t8d0 disk connected configured unknown
c3::dsk/c3t9d0 disk connected configured unknown
c3::dsk/c3t10d0 disk connected configured unknown
c3::dsk/c3t11d0 disk connected configured unknown
c3::dsk/c3t12d0 disk connected configured unknown
c3::dsk/c3t13d0 disk connected configured unknown
c3::dsk/c3t14d0 disk connected configured unknown
bash-3.00#

// lets see which devices are seen on c2::200400a0b8169d18
// only some last entries

bash-3.00# ./hba_inq -lw | grep "200400a0b8169d18" | tail
NodeWWN 200400a0b8169d17 PortWWN 200400a0b8169d18 bus 2 target 71424 lun 10 "/dev/rdsk/c4t600A0B8000169D170000001541C9C2A6d0s2"
NodeWWN 200400a0b8169d17 PortWWN 200400a0b8169d18 bus 2 target 71424 lun 9 "/dev/rdsk/c4t600A0B8000169D170000001441C9C27Ed0s2"
NodeWWN 200400a0b8169d17 PortWWN 200400a0b8169d18 bus 2 target 71424 lun 8 "/dev/rdsk/c4t600A0B8000169D170000001341C9C256d0s2"
NodeWWN 200400a0b8169d17 PortWWN 200400a0b8169d18 bus 2 target 71424 lun 7 "/dev/rdsk/c4t600A0B8000169D170000001241C9C230d0s2"
NodeWWN 200400a0b8169d17 PortWWN 200400a0b8169d18 bus 2 target 71424 lun 6 "/dev/rdsk/c4t600A0B8000169D170000000A41C9C0B8d0s2"
NodeWWN 200400a0b8169d17 PortWWN 200400a0b8169d18 bus 2 target 71424 lun 5 "/dev/rdsk/c4t600A0B8000169D170000001141C9C1FEd0s2"
NodeWWN 200400a0b8169d17 PortWWN 200400a0b8169d18 bus 2 target 71424 lun 4 "/dev/rdsk/c4t600A0B8000169D170000001041C9C1D8d0s2"
NodeWWN 200400a0b8169d17 PortWWN 200400a0b8169d18 bus 2 target 71424 lun 3 "/dev/rdsk/c4t600A0B8000169D170000000F41C9C1A2d0s2"
NodeWWN 200400a0b8169d17 PortWWN 200400a0b8169d18 bus 2 target 71424 lun 2 "/dev/rdsk/c4t600A0B8000169D170000000E41C9C17Cd0s2"
NodeWWN 200400a0b8169d17 PortWWN 200400a0b8169d18 bus 2 target 71424 lun 1 "/dev/rdsk/c4t600A0B8000169D170000000C41C9C148d0s2"
bash-3.00#


// so lets assume we are looking for LUN 55 which was just presented to the
// server and we don't know what MPxIO device it's

bash-3.00# ./hba_inq -lw|grep "200400a0b8169d18"|grep "lun 55"
NodeWWN 200400a0b8169d17 PortWWN 200400a0b8169d18 bus 2 target 71424 lun 55 "/dev/rdsk/c4t600A0B80001652440000003B428E0ACBd0s2"
bash-3.00#



hba_inq is covered by CDDL.

7 comments:

Lasse Østerild said...

Fantastic tool, this makes my life so much easier, THANKS!

Anonymous said...

Thanks.. very useful!

Anonymous said...

hba_inq is exactly what I needed, excellent little utility!

victorhalla said...

I tested with Emulex-LPe11002-S-1 and works fine. thanks !!!

Anonymous said...

Thank you so much !!!

Abhi said...

Wonderful tool.
Just confused about compilation part.
How did you find out that we should link it to HBAAPI library while compiling ?
eg: gcc -lHBAAPI ..

milek said...

Abhi - I believe I found it from reading man pages for the API used in the program. I'm glad you like it.