Whamcloud - gitweb
LU-16314 tests: enable debug_raw_pointers on mount 54/54254/8
authorShaun Tancheff <shaun.tancheff@hpe.com>
Wed, 17 Apr 2024 08:44:12 +0000 (15:44 +0700)
committerOleg Drokin <green@whamcloud.com>
Wed, 29 May 2024 04:45:42 +0000 (04:45 +0000)
When the MGS is mounted:
  do_facet mgs "$LCTL set_param -P debug_raw_pointers=Y"

So debug_raw_pointers need only be set once instead of
enabled and distabled for each test.

Switching kptr_restrict for every node on every test (twice)
does not add value when testing on dedicated test VMs.

This adds a KPTR_ON_MOUNT to allow a less restrictive setting
during test-framework setupall()/cleanall().

The initial kptr restrict values are persisted to and restored
from a well-known temporary file $TMP/kptr-$PPID-env

The patch enables KPTR_ON_MOUNT by default.

HPE-bug-id: LUS-10945
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I4d8975f26e57ea064608663f309400d09406d500
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54254
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/tests/test-framework.sh

index 22387a6..655f06d 100755 (executable)
@@ -33,6 +33,9 @@ export JOBID_VAR=${JOBID_VAR:-"procname_uid"}  # or "existing" or "disable"
 export MOUNT_CMD=${MOUNT_CMD:-"mount -t lustre"}
 export UMOUNT=${UMOUNT:-"umount -d"}
 
+# A switch to enable kptr less restrictively
+export KPTR_ON_MOUNT=${KPTR_ON_MOUNT:-true}
+
 export LSNAPSHOT_CONF="/etc/ldev.conf"
 export LSNAPSHOT_LOG="/var/log/lsnapshot.log"
 
@@ -5123,6 +5126,33 @@ cleanup_echo_devs () {
        done
 }
 
+# Allow %pK to print raw pointers and save the initial value
+kptr_enable_and_save() {
+       # do not overwrite whatever was initially saved:
+       [[ -f $TMP/kptr-$PPID-env ]] && return
+
+       declare -A kptr
+       for node in $(all_nodes); do
+               kptr[$node]=$(do_node $node "sysctl --values kernel/kptr_restrict")
+               do_node $node "sysctl -wq kernel/kptr_restrict=1"
+       done
+       declare -p kptr > $TMP/kptr-$PPID-env
+}
+
+# Restore the initial %pK settings
+kptr_restore() {
+       [[ ! -f $TMP/kptr-$PPID-env ]] && return
+
+       source $TMP/kptr-$PPID-env
+
+       local param
+       for node in $(all_nodes); do
+               [[ -z ${kptr[$node]} ]] && continue
+               param="kernel/kptr_restrict=${kptr[$node]}"
+               do_node $node "sysctl -wq ${param} || true"
+       done
+}
+
 cleanupall() {
        nfs_client_mode && return
        cifs_client_mode && return
@@ -5130,6 +5160,8 @@ cleanupall() {
        cleanup_echo_devs
        CLEANUP_DM_DEV=true stopall $*
 
+       [[ $KPTR_ON_MOUNT ]] && kptr_restore
+
        unload_modules
        cleanup_sk
        cleanup_gss
@@ -5488,6 +5520,7 @@ writeconf_all () {
 mountmgs() {
        if ! combined_mgs_mds ; then
                start mgs $(mgsdevname) $MGS_MOUNT_OPTS
+               do_facet mgs "$LCTL set_param -P debug_raw_pointers=Y"
        fi
 }
 
@@ -5513,6 +5546,9 @@ mountmds() {
                        switch_identity $num $IDENTITY_UPCALL
                fi
        done
+       if combined_mgs_mds ; then
+               do_facet mgs "$LCTL set_param -P debug_raw_pointers=Y"
+       fi
 }
 
 unmountoss() {
@@ -5636,6 +5672,8 @@ setupall() {
        mountcli
        init_param_vars
 
+       [[ $KPTR_ON_MOUNT ]] && kptr_enable_and_save
+
        # by remounting mdt before ost, initial connect from mdt to ost might
        # timeout because ost is not ready yet. wait some time to its fully
        # recovery. initial obd_connect timeout is 5s; in GSS case it's
@@ -7404,17 +7442,9 @@ run_one_logged() {
        local SAVE_UMASK=$(umask)
        local rc=0
        local node
-       declare -A kptr_restrict
-       declare -A debug_raw
        umask 0022
 
-       for node in $(all_nodes); do
-               kptr_restrict[$node]=$(do_node $node "sysctl --values kernel/kptr_restrict")
-               do_node $node "sysctl -wq kernel/kptr_restrict=1"
-               # Enable %p to be unhashed (if supported)
-               debug_raw[$node]=$(do_node $node "$LCTL get_param -n debug_raw_pointers" || echo 0)
-               do_node $node "$LCTL set_param debug_raw_pointers=Y || true"
-       done
+       [[ $KPTR_ON_MOUNT ]] || kptr_enable_and_save
 
        rm -f $LOGDIR/err $LOGDIR/ignore $LOGDIR/skip
        echo
@@ -7487,14 +7517,7 @@ run_one_logged() {
                ((testiter++))
        done
 
-       local param
-       for node in $(all_nodes); do
-               param="kernel/kptr_restrict=${kptr_restrict[$node]}"
-               do_node $node "sysctl -wq ${param} || true"
-               # Restore %p to initial state
-               param="debug_raw_pointers=${debug_raw[$node]}"
-               do_node $node "$LCTL set_param ${param} || true"
-       done
+       [[ $KPTR_ON_MOUNT ]] || kptr_restore
 
        if [[ "$TEST_STATUS" != "SKIP" && -f $TF_SKIP ]]; then
                rm -f $TF_SKIP