Skip to contentSkip to conversation

don't require modular null_blk for fault-injection

PATCH Applied Akinobu Mita 2 participants 3 messages Apr 16, 2023 – Apr 21, 2023 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 don't require modular null_blk for fault-injection

This blktests change changes null_blk fault-injection settings to be configured via configfs instead of module parameters.
This allows null_blk fault-injection tests to run even if the null_blk is built-in the kernel and not built as a module.

If the null_blk does not yet support configuring fault-injection via configfs, fall back to set up with module parameter.

---
* v2
- don't skip the tests on older kernels without fault-injection via configfs

 tests/block/014 | 30 +++++++++++++++++++++++-------
 tests/block/015 | 30 +++++++++++++++++++++++-------
 tests/block/030 | 44 ++++++++++++++++++++++++++++++++------------
 3 files changed, 78 insertions(+), 26 deletions(-)
tests/block/014 +23 -7
index facd4bc..cac779b 100755
@@ -16,20 +16,36 @@ requires() {
 test() {
 	echo "Running ${TEST_NAME}"
 
-	# The format is "<interval>,<probability>,<space>,<times>". Here, we
-	# fail 50% of I/Os.
-	if ! _init_null_blk timeout='1,50,0,-1'; then
-		return 1
+	local faultb=faultb0
+
+	# Here, we fail 50% of I/Os.
+	if ! _configure_null_blk "$faultb" timeout_inject/probability=50 \
+	     timeout_inject/times=-1 timeout_inject/verbose=0 power=1 \
+	     > /dev/null 2>&1; then
+		rmdir /sys/kernel/config/nullb/"$faultb"
+		if _module_file_exists null_blk; then
+			faultb=nullb0
+
+			# Fall back to set up with module parameter. The format
+			# is "<interval>,<probability>,<space>,<times>"
+			if ! _init_null_blk timeout='1,50,0,-1'; then
+				echo "Configuring null_blk failed"
+				return 1
+			fi
+		else
+			SKIP_REASONS+=("requires fault injection via configfs or modular null_blk")
+			return 1
+		fi
 	fi
 
-	for sched in $(_io_schedulers nullb0); do
+	for sched in $(_io_schedulers "$faultb"); do
 		echo "Testing $sched" >> "$FULL"
-		echo "$sched" > /sys/block/nullb0/queue/scheduler
+		echo "$sched" > /sys/block/"$faultb"/queue/scheduler
 		# Do a bunch of I/Os which will timeout and then complete. The
 		# only thing we're really testing here is that this doesn't
 		# crash or hang.
 		for ((i = 0; i < 100; i++)); do
-			dd if=/dev/nullb0 of=/dev/null bs=4K count=4 \
+			dd if=/dev/"$faultb" of=/dev/null bs=4K count=4 \
 				iflag=direct status=none > /dev/null 2>&1 &
 		done
 		wait
tests/block/015 +23 -7
index 389c67f..afb4b82 100755
@@ -18,16 +18,32 @@ requires() {
 test() {
 	echo "Running ${TEST_NAME}"
 
-	# The format is "<interval>,<probability>,<space>,<times>". Here, we
-	# requeue 10% of the time.
-	if ! _init_null_blk requeue='1,10,0,-1'; then
-		return 1
+	local faultb=faultb0
+
+	# Here, we requeue 10% of the time.
+	if ! _configure_null_blk "$faultb" requeue_inject/probability=10 \
+	     requeue_inject/times=-1 requeue_inject/verbose=0 power=1 \
+	     > /dev/null 2>&1; then
+		rmdir /sys/kernel/config/nullb/"$faultb"
+		if _module_file_exists null_blk; then
+			faultb=nullb0
+
+			# Fall back to set up with module parameter. The format
+			# is "<interval>,<probability>,<space>,<times>"
+			if ! _init_null_blk requeue='1,10,0,-1'; then
+				echo "Configuring null_blk failed"
+				return 1
+			fi
+		else
+			SKIP_REASONS+=("requires fault injection via configfs or modular null_blk")
+			return 1
+		fi
 	fi
 
-	for sched in $(_io_schedulers nullb0); do
+	for sched in $(_io_schedulers "$faultb"); do
 		echo "Testing $sched" >> "$FULL"
-		echo "$sched" > /sys/block/nullb0/queue/scheduler
-		dd if=/dev/nullb0 of=/dev/null bs=4K count=$((512 * 1024)) \
+		echo "$sched" > /sys/block/"$faultb"/queue/scheduler
+		dd if=/dev/"$faultb" of=/dev/null bs=4K count=$((512 * 1024)) \
 			iflag=direct status=none
 	done
 
tests/block/030 +32 -12

65 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw
Quoted 5 lines · Akinobu Mita

This blktests change changes null_blk fault-injection settings to be configured via configfs instead of module parameters.
This allows null_blk fault-injection tests to run even if the null_blk is built-in the kernel and not built as a module.

Quoted 7 lines

If the null_blk does not yet support configuring fault-injection via configfs, fall back to set up with module parameter.

---
* v2
- don't skip the tests on older kernels without fault-injection via configfs

Thanks for this v2 patch. It looks good to me. I'll wait a few more days before I apply it in case anyone has some more comments.

One nit in the commit title: it's the better to have the prefix "block/{014,015,030}: " to clarify the test cases this commit touches. I'll do the edit when I apply this patch.

#2 lore raw
Quoted 14 lines · Shin'ichiro Kawasaki
Quoted 5 lines · Akinobu Mita

This blktests change changes null_blk fault-injection settings to be configured via configfs instead of module parameters.
This allows null_blk fault-injection tests to run even if the null_blk is built-in the kernel and not built as a module.

Quoted 7 lines

If the null_blk does not yet support configuring fault-injection via configfs, fall back to set up with module parameter.

---
* v2
- don't skip the tests on older kernels without fault-injection via configfs

Quoted 6 lines

Thanks for this v2 patch. It looks good to me. I'll wait a few more days before I apply it in case anyone has some more comments.

One nit in the commit title: it's the better to have the prefix "block/{014,015,030}: " to clarify the test cases this commit touches. I'll do the edit when I apply this patch.

I've applied the patch with the edit. Thanks!