# \[PATCH blktests 2/2\] zbd/007: Reset test target zones at test end

- From: Shin'ichiro Kawasaki \<hidden\>
- Date: 2021-07-13 10:12:44 
- List: linux-block
- Page: https://ratatoskr.run/linux-block/2021/07/6403903
- Thread: https://ratatoskr.run/linux-block/2021/07/6403901/t.md

```text
The test case zbd/007 checks write pointer mapping between a logical
device and its container device. To do so, it moves write pointers of
the container device by writing data to the container device. When the
logical device is a dm-crypt device, this test case works as expected,
but the data written to the container device is not encrypted, then it
leaves broken data on the logical, dm-crypt device. This results in I/O
errors in the following operations to the dm-crypt device.

To avoid the I/O errors, reset the test target zones of the logical
device at the test case end to wipe out the broken data.

Signed-off-by: Shin'ichiro Kawasaki <redacted>
---
 tests/zbd/007 | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tests/zbd/007 b/tests/zbd/007
index 9d7ca67..2179647 100755
--- a/tests/zbd/007
+++ b/tests/zbd/007
@@ -109,5 +109,12 @@ test_device() {
 	done
 	_put_blkzone_report
 
+	# When the logical devices is dm-crypt, the write pointer moves on
+	# its container device break data contents on the logical device. Reset
+	# zones of the logical device to wipe out the broken data.
+	for ((i=0; i < ${#test_z[@]}; i++)); do
+		blkzone reset -o "${test_z_start[i]}" -c 1 "${TEST_DEV}"
+	done
+
 	echo "Test complete"
 }
-- 
2.31.1

```
