Skip to contentSkip to conversation

ndctl, test: make btt-pad-compat dynamically detect a patched kernel

PATCH In review Vishal Verma 2 participants 2 messages Feb 2, 2018 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Vishal Verma

author maintainer
#0 lore raw

PATCH 1/1 ndctl, test: make btt-pad-compat dynamically detect a patched kernel

The btt-pad-compat test can detect whether it is running on a patched kernel by checking for the two newly added debugfs files in the fix for this bug. Use that instead of hard coding a kernel version dependency.

---
 test/btt-pad-compat.sh | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
test/btt-pad-compat.sh +4 -11
index d10efe3..faa773c 100755
@@ -41,17 +41,6 @@ err()
 	exit "$rc"
 }
 
-check_min_kver()
-{
-	local ver="$1"
-	: "${KVER:=$(uname -r)}"
-
-	[ -n "$ver" ] || return 1
-	[[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)" ]]
-}
-
-check_min_kver "4.15" || { echo "kernel $KVER may not have btt padding compat fixes"; exit "$rc"; }
-
 check_prereq()
 {
 	if ! command -v "$1" >/dev/null; then
@@ -70,6 +59,10 @@ create()
 	[ $size -gt 0 ] || err "$LINENO" 2
 	bttdev=$(cat /sys/bus/nd/devices/$dev/holder)
 	[ -n "$bttdev" ] || err "$LINENO" 2
+	if [ ! -e /sys/kernel/debug/btt/$bttdev/arena0/log_index_0 ]; then
+		echo "kernel $(uname -r) seems to be missing the BTT compatibility fixes, skipping"
+		exit 77
+	fi
 }
 
 reset()
Signature · 6 lines
2.14.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw
Quoted 33 lines · Vishal Verma

The btt-pad-compat test can detect whether it is running on a patched kernel by checking for the two newly added debugfs files in the fix for this bug. Use that instead of hard coding a kernel version dependency.

---
 test/btt-pad-compat.sh | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
test/btt-pad-compat.sh +0 -11
index d10efe3..faa773c 100755
@@ -41,17 +41,6 @@ err()
        exit "$rc"
 }
 
-check_min_kver()
-{
-       local ver="$1"
-       : "${KVER:=$(uname -r)}"
-
-       [ -n "$ver" ] || return 1
-       [[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)" ]]
-}
-
-check_min_kver "4.15" || { echo "kernel $KVER may not have btt padding compat fixes"; exit "$rc"; }
-
 check_prereq()
 {
        if ! command -v "$1" >/dev/null; then

test/btt-pad-compat.sh create() · line 66

Quoted 8 lines
test/btt-pad-compat.sh +4 -0
@@ -70,6 +59,10 @@ create()
        [ $size -gt 0 ] || err "$LINENO" 2
        bttdev=$(cat /sys/bus/nd/devices/$dev/holder)
        [ -n "$bttdev" ] || err "$LINENO" 2
+       if [ ! -e /sys/kernel/debug/btt/$bttdev/arena0/log_index_0 ]; then
+               echo "kernel $(uname -r) seems to be missing the BTT compatibility fixes, skipping"
+               exit 77
+       fi
 }

Looks good to me. The less hard coded kernel version checks the better.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm