Score:0

I want to reset a FC_HOST before the multipath tries to mount paths from it

ht flag

I have an HPE SN1100Q 2port 16G HBA card on my hpe proliant gen10 server which is connected to HPE 3par storage direct attach. And some wierd stuff happening. Im using qla2xxx driver version 10.01.00.19-k which comes built-in in ubuntu 20.04. When my servers restart the connection between my server and 3par become unaccessible. But when i reset my fc_ports with this commands the connection accessible again.

echo 1 > /sys/class/fc_host/host7/issue_lip
echo 1 > /sys/class/fc_host/host9/issue_lip

So i want to reset this ports before the server tries mount the paths. I wrote a systemd service and reset-hba script for this. But multipath trying to access paths before my script reset the ports. How can i fix this problem?

Here is my systemd service:

[Unit]
Description=Reset hba ports on startup
Before=multipathd.service
 
[Service]
Type=oneshot
ExecStartPre=/sbin/modprobe -a qla2xxx
ExecStart=/bin/bash -c "/opt/hpe-hba/reset_hba_ports.sh"

[Install]
WantedBy=sysinit.target

And my reset script:

#/bin/bash

FC_HOST_PATH="/sys/class/fc_host"

modprobe qla2xxx

until [ ! -z "$(ls $FC_HOST_PATH)" ]
do
    sleep 1
    echo "Waiting for FC hosts..."
done

echo "HBA port reset in progess..."
for host in $(ls $FC_HOST_PATH);do
    RPORT=$(ls $FC_HOST_PATH/$host/device/ | grep rport)
    TPORT=$(ls $FC_HOST_PATH/$host/device/$RPORT | grep target)
    if [ -z "${TPORT}" ]
    then
    echo "$host not connected. Resetting FC port"
        echo 1 >  /sys/class/fc_host/$host/issue_lip;
    fi
done

echo "Waiting for the FC communication to be established."
try_count=0
while [ $try_count -le 3 ]
do
    err=0
    for host in $(ls $FC_HOST_PATH)
    do 
        RPORT=$(ls $FC_HOST_PATH/$host/device/ | grep rport)
        TPORT=$(ls $FC_HOST_PATH/$host/device/$RPORT | grep target)
        echo "Target port for $host is $TPORT"
        if [ -z "${TPORT}" ]
        then
            echo "HBA FC port is not ready yet. Target is not available! Waiting for 10 sec..."
            err=1
            sleep 5
        fi
    done
    if [ $err -eq 0 ]
    then
        break
    fi
    ((try_count++))
done

echo "FC port init complated!"

DATE=$(/usr/bin/date)
echo $DATE >> /opt/hpe-hba/last_run.txt
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.