Whamcloud - gitweb
LU-17894 lnet: Initialize common lnd params 41/55341/4
authorChris Horn <chris.horn@hpe.com>
Thu, 6 Jun 2024 19:35:29 +0000 (13:35 -0600)
committerOleg Drokin <green@whamcloud.com>
Wed, 19 Jun 2024 01:16:15 +0000 (01:16 +0000)
This ensures the correct default values are used when the user does
not specify a value for them.

Test-Parameters: trivial testlist=sanity-lnet
Fixes: 7e01787863 ("LU-12452 lnet: allow to set IP ToS value per-NI")
Signed-off-by: Chris Horn <chris.horn@hpe.com>
Change-Id: I201e9acbc3be8e27cd8957b722c8cea9a64de6c1
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55341
Reviewed-by: Etienne AUJAMES <eaujames@ddn.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lnet/utils/lnetctl.c
lustre/tests/sanity-lnet.sh

index a27dca3..152a694 100644 (file)
@@ -2539,13 +2539,12 @@ static int jt_add_ni(int argc, char **argv)
                found = true;
        }
 
-       if (pto >= 0 || pc > 0 || pbc > 0 || cre > 0 || cpp > -1) {
-               tunables.lt_cmn.lct_peer_timeout = pto;
-               tunables.lt_cmn.lct_peer_tx_credits = pc;
-               tunables.lt_cmn.lct_peer_rtr_credits = pbc;
-               tunables.lt_cmn.lct_max_tx_credits = cre;
+       tunables.lt_cmn.lct_peer_timeout = pto;
+       tunables.lt_cmn.lct_peer_tx_credits = pc;
+       tunables.lt_cmn.lct_peer_rtr_credits = pbc;
+       tunables.lt_cmn.lct_max_tx_credits = cre;
+       if (pto >= 0 || pc > 0 || pbc > 0 || cre > 0)
                found = true;
-       }
 
        if (found && LNET_NETTYP(nw_descr.nw_id) == O2IBLND)
                tunables.lt_tun.lnd_tun_u.lnd_o2ib.lnd_map_on_demand = UINT_MAX;
index fdb9a45..9d91754 100755 (executable)
@@ -3471,47 +3471,63 @@ test_231() {
        reinit_dlc || return $?
 
        local net=${NETTYPE}231
+       local opts="--net $net --if ${INTERFACES[0]}"
 
-       do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
-               error "Failed to add net"
+       do_lnetctl net add $opts || error "Failed to add net"
+
+       local lnd=$(basename $LNETLND)
+       local param_path="/sys/module/$lnd/parameters"
+
+       [[ -d $param_path ]] ||
+               error "Cannot find kernel params for $lnd at $param_path"
+
+       local lnd_pto=$(cat $param_path/peer_timeout)
+
+       # A value of -1 means we use the default peer timeout
+       #lnet/include/lnet/lib-lnet.h:#define DEFAULT_PEER_TIMEOUT    180
+       ((lnd_pto != -1)) || lnd_pto=180
 
        $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-expected.yaml
-       sed -i 's/peer_timeout: .*$/peer_timeout: 0/' \
-               $TMP/sanity-lnet-$testnum-expected.yaml
 
-       reinit_dlc || return $?
+       local pto=$(awk '/^\s+peer_timeout:/{print $NF}' \
+                   $TMP/sanity-lnet-$testnum-expected.yaml)
 
-       do_lnetctl import $TMP/sanity-lnet-$testnum-expected.yaml ||
-               error "Failed to import configuration"
+       ((pto == lnd_pto)) ||
+               error "Expect peer_timeout $lnd_pto but found $pto"
 
        $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+       compare_yaml_files ||
+               error "Unexpected config after net add without options"
 
-       compare_yaml_files || error "Wrong config after import"
+       for pto in -1 0 60 180; do
+               reinit_dlc || return $?
 
-       do_lnetctl net del --net $net --if ${INTERFACES[0]} ||
-               error "Failed to delete net $net"
+               sed -i 's/peer_timeout: .*/peer_timeout: '$pto'/' \
+                       $TMP/sanity-lnet-$testnum-expected.yaml
 
-       do_lnetctl net add --net $net --if ${INTERFACES[0]} --peer-timeout=0 ||
-               error "Failed to add net with peer-timeout=0"
+               do_lnetctl import $TMP/sanity-lnet-$testnum-expected.yaml ||
+                       error "Failed to import configuration"
 
-       $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+               $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
 
-       compare_yaml_files || error "Wrong config after lnetctl net add"
+               # Swap lnd_to for -1 in the expected output
+               ((pto != -1)) ||
+                       sed -i 's/peer_timeout: '$pto'/peer_timeout: '$lnd_pto'/' \
+                               $TMP/sanity-lnet-$testnum-expected.yaml
 
-       reinit_dlc || return $?
+               compare_yaml_files || error "Wrong config after import"
 
-       # lnet/include/lnet/lib-lnet.h defines DEFAULT_PEER_TIMEOUT 180
-       sed -i 's/peer_timeout: .*$/peer_timeout: 180/' \
-               $TMP/sanity-lnet-$testnum-expected.yaml
+               do_lnetctl net del $opts || error "Failed to delete net $net"
 
-       sed -i '/^.*peer_timeout:.*$/d' $TMP/sanity-lnet-$testnum-actual.yaml
+               do_lnetctl net add $opts --peer-timeout=$pto ||
+                       error "Failed to add net with peer-timeout=$pto"
 
-       do_lnetctl import $TMP/sanity-lnet-$testnum-actual.yaml ||
-               error "Failed to import config without peer_timeout"
+               $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
 
-       $LNETCTL export --backup > $TMP/sanity-lnet-$testnum-actual.yaml
+               compare_yaml_files || error "Wrong config after lnetctl net add"
+       done
 
-       compare_yaml_files
+       return 0
 }
 run_test 231 "Check DLC handling of peer_timeout parameter"