diff --git a/configure.d/1_blk_queue_exit_workaround_for_rhel.conf b/configure.d/1_blk_queue_exit_workaround_for_rhel.conf index 2f85ced..e3a9377 100644 --- a/configure.d/1_blk_queue_exit_workaround_for_rhel.conf +++ b/configure.d/1_blk_queue_exit_workaround_for_rhel.conf @@ -6,14 +6,51 @@ . $(dirname $3)/conf_framework.sh -# RHEL8.5 kernel 4.18 subversion targeted for the workaround is 348.7.1. -# The workaround is needed starting this version and up. -QUEUE_PUT_WA_LINUX_MAJOR_SINCE=4 -QUEUE_PUT_WA_LINUX_MINOR_SINCE=18 -QUEUE_PUT_WA_LINUX_SUB_SINCE=0 -QUEUE_PUT_WA_RHEL_MAJOR_SINCE=348 -QUEUE_PUT_WA_RHEL_MINOR_SINCE=7 -QUEUE_PUT_WA_RHEL_SUB_SINCE=1 +# Check whether version A is the same as (or newer than) version B. +# +# Version consists of three elements: major, minor and sub. +# The last argument (GT_LVL) tells at which level it is acceptable +# for version A to be newer than B. It can be "major", "minor", "sub" +# or unspecified. +# - For GT_LVL="major" used, then all versions that are newer than B +# are accepted. +# - For GT=LVL="minor" only versions that are newer and have the same +# major number. +# - For GT_LVL="sub" only version that are newer and have the same major +# and minor number are accepted. +# - For GT_LVL unspecified version A needs to be exactly the same as +# version B. +compare_version () { + MAJOR_A=$1 + MINOR_A=$2 + SUB_A=$3 + MAJOR_B=$4 + MINOR_B=$5 + SUB_B=$6 + GT_LVL=$7 + if [ "$MAJOR_A" -eq "$MAJOR_B" ]; then + if [ "$MINOR_A" -eq "$MINOR_B" ]; then + if [ "$SUB_A" -eq "$SUB_B" ]; then + return 0 + elif [ -n "$GT_LVL" ] && [ "$SUB_A" -gt "$SUB_B" ]; then + return 0 + fi + elif [ "$GT_LVL" = "major" -o "$GT_LVL" = "minor" ] && + [ "$MINOR_A" -gt "$MINOR_B" ]; then + return 0 + fi + elif [ "$GT_LVL" = "major" ] && [ "$MAJOR_A" -gt "$MAJOR_B" ]; then + return 0 + fi + return 1 +} + +compare_kernel_version () { + compare_version $1 $2 $3 $LINUX_MAJOR $LINUX_MINOR $LINUX_SUB $4 +} +compare_rhel_kernel_version () { + compare_version $1 $2 $3 $RHEL_MAJOR $RHEL_MINOR $RHEL_SUB $4 +} check () { cur_name=$(basename $2) @@ -24,9 +61,7 @@ check () { LINUX_MINOR=$((LINUX_VERSION_CODE >> 8 & 0xff)) LINUX_SUB=$((LINUX_VERSION_CODE & 0xff)) - if [ -z $RHEL_RELEASE ]; then - echo $cur_name "2" >> $config_file_path; #not RHEL, no workaround needed - else + if [ -n $RHEL_RELEASE ]; then #it's RHEL, check versions to see if the workaround is needed IFS=. read -a arr <<< $RHEL_RELEASE @@ -34,32 +69,21 @@ check () { RHEL_MINOR="${arr[1]:=0}" RHEL_SUB="${arr[2]:=0}" - #check kernel and rhel version (major/minor/sub) - if [ "$LINUX_MAJOR" -eq "$QUEUE_PUT_WA_LINUX_MAJOR_SINCE" ] && - [ "$LINUX_MINOR" -eq "$QUEUE_PUT_WA_LINUX_MINOR_SINCE" ] && - [ "$LINUX_SUB" -eq "$QUEUE_PUT_WA_LINUX_SUB_SINCE" ]; - then - if [ "$RHEL_MAJOR" -gt "$QUEUE_PUT_WA_RHEL_MAJOR_SINCE" ]; then + #check linux kernel version + if compare_kernel_version 4 18 0; then + #check rhel kernel version + if compare_rhel_kernel_version 305 45 1 "minor"; then echo $cur_name "1" >> $config_file_path; #workaround needed - elif [ "$RHEL_MAJOR" -lt "$QUEUE_PUT_WA_RHEL_MAJOR_SINCE" ]; then - echo $cur_name "2" >> $config_file_path; #no workaround needed - else - if [ "$RHEL_MINOR" -gt "$QUEUE_PUT_WA_RHEL_MINOR_SINCE" ]; then - echo $cur_name "1" >> $config_file_path; #workaround needed - elif [ "$RHEL_MINOR" -lt "$QUEUE_PUT_WA_RHEL_MINOR_SINCE" ]; then - echo $cur_name "2" >> $config_file_path; #no workaround needed - else - if [ "$RHEL_SUB" -ge "$QUEUE_PUT_WA_RHEL_SUB_SINCE" ]; then - echo $cur_name "1" >> $config_file_path; #workaround needed - else - echo $cur_name "2" >> $config_file_path; #no workaround needed - fi - fi + return + fi + + if compare_rhel_kernel_version 348 7 1 "major"; then + echo $cur_name "1" >> $config_file_path; #workaround needed + return fi - else - echo $cur_name "2" >> $config_file_path; #no workaround needed fi fi + echo $cur_name "2" >> $config_file_path; #no workaround needed } apply() {