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

Re: ofpath vs ofpathname vs grub-ofpathname



On 4/17/20 9:05 AM, Romain Dolbeau wrote:
> Le jeu. 16 avr. 2020 à 21:31, John Paul Adrian Glaubitz
> <glaubitz@physik.fu-berlin.de> a écrit :
>>> And if my reading of OF 'dev / ls' is correct, the disks should be:
>>> /ht@0,f2000000/pci@9/k2-sata-root@c/k2-sata@0/disk@0
>>> /ht@0,f2000000/pci@9/k2-sata-root@c/k2-sata@1/disk@0
>> What does ofpath say?
> 
> Still says:
> 
> dolbeau@powermacg5:~$ sudo /usr/sbin/ofpath /dev/sda
> /ht@0,f2000000/pci@9/k2-sata-root@c/@0/@0
> dolbeau@powermacg5:~$ sudo /usr/sbin/ofpath /dev/sdb
> /ht@0,f2000000/pci@9/k2-sata-root@c/@1/@0

Ok, thank you. So ofpath is able to tell those two disks apart while
ofpathname isn't. This is important to know and I need to dig into
the script source later today why that's the case.

ofpath calls that component of the path plug ID and it's determined
as follows:

    PLUG_ID=$(ls -dv $SYS_PATH/*/host* 2>/dev/null | grep -n "/host$HOST_ID$")
    [ -z "$PLUG_ID" ] && {
      PLUG_ID=$(ls -dv $SYS_PATH/host* 2>/dev/null | grep -n "/host$HOST_ID$")
    }
    PLUG_ID=$((${PLUG_ID%%:*}-1))

ofpathname calls this component "BUS" and it's determined in get_hbtl():

#                                                                                                                                                                 
# get_hbtl                                                                                                                                                        
# Given a path that ends in an HBTL (Host:Bus:Target ID:LUN), break it apart                                                                                      
# into its constituent parts in the global vars HOST, BUS, TARGET and LUN                                                                                         
#                                                                                                                                                                 
# #1 path ending in HBTL                                                                                                                                          
#                                                                                                                                                                 
get_hbtl()
{
    local hbtl

    HBTL=${1##*/}
    hbtl=$HBTL

    HOST=${hbtl%%:*}
    hbtl=${hbtl#*:}
    BUS=${hbtl%%:*}
    BUS=`echo "ibase=10;obase=16; $BUS" | bc | tr "[:upper:]" "[:lower:]"`
    hbtl=${hbtl#*:}
    ID=${hbtl%%:*}
    ID=`echo "ibase=10;obase=16; $ID" | bc | tr "[:upper:]" "[:lower:]"`
    LUN=${hbtl#*:}
    LUN=`echo "ibase=10;obase=16; $LUN" | bc | tr "[:upper:]" "[:lower:]"`
}

So, I need to dig around in /sys a bit to find out how to properly determine
the plug ID we need. Maybe it's the target ID what we need to use for SATA
on the Mac instead of the bus ID.

>> As far as I know, Apple's OF implementation expects "@0" instead of
>> "disk@0". And I have no idea where the "k2-sata@N" component comes
>> from.
> 
> This is just the values from the OF console itself ('dev / ls'), not
> necessarily what is needed as a booting path.
> The same path is in /sys:
> 
> dolbeau@powermacg5:~$ ls -l
> /sys/firmware/devicetree/base/ht@0\,f2000000/pci@9/k2-sata-root@c/k2-sata@*/*|grep
> disk
> /sys/firmware/devicetree/base/ht@0,f2000000/pci@9/k2-sata-root@c/k2-sata@0/disk@0:
> /sys/firmware/devicetree/base/ht@0,f2000000/pci@9/k2-sata-root@c/k2-sata@1/disk@0:
> 
> Apparently on this machine, the 'scsi' bit (that appears in Michael's
> G5 output) has been replaced by a 'k2-sata' bit.
> It seems to be misunderstood by the script, as it's where the
> difference between sda and sdb should appear...

The number N in "k2-sata@N" the plug ID while the N in "scsi@N" is the bus ID.

I need to find out what the plug ID is in the normal SCSI terminology, but
I assume that's just the target ID.

It would be handy to have access to a G5 running Linux now. It seems that
get_hbtl() needs to be extended to include the target ID in its output.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


Reply to: