Skip to contentSkip to conversation

nvme/040: Free loop back resources

PATCH In review Daniel Wagner 2 participants 4 messages Jun 12, 2023 – Jun 15, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme/040: Free loop back resources

The tests does not cleanup all resources after it has finished. This leads to rm not being able to remove the TMPDIR cleanly:

+ rm -rf blktests/results/tmpdir.nvme.040.m2J
rm: cannot remove 'blktests/results/tmpdir.nvme.040.m2J': Directory not empty

---
 tests/nvme/040 | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tests/nvme/040 +7 -2
index b6ab34d611ba..688a0939a376 100755
@@ -18,6 +18,7 @@ requires() {
 
 test() {
 	local subsys="blktests-subsystem-1"
+	local file_path="${TMPDIR}/img"
 	local port
 	local loop_dev
 	local nvmedev
@@ -26,8 +27,8 @@ test() {
 	echo "Running ${TEST_NAME}"
 
 	_setup_nvmet
-	truncate -s "${nvme_img_size}" "$TMPDIR/img"
-	loop_dev="$(losetup -f --show "$TMPDIR/img")"
+	truncate -s "${nvme_img_size}" "${file_path}"
+	loop_dev="$(losetup -f --show "${file_path}")"
 
 	port="$(_create_nvmet_port "${nvme_trtype}")"
 	_create_nvmet_subsystem "${subsys}" "${loop_dev}"
@@ -57,5 +58,9 @@ test() {
 	_remove_nvmet_subsystem "${subsys}"
 	_remove_nvmet_port "${port}"
 
+	losetup -d "${loop_dev}"
+
+	rm -f "${file_path}"
+
 	echo "Test complete"
 }
Signature · 1 line
2.40.1
#1 lore raw
Quoted 7 lines · Daniel Wagner

The tests does not cleanup all resources after it has finished. This leads to rm not being able to remove the TMPDIR cleanly:

+ rm -rf blktests/results/tmpdir.nvme.040.m2J
rm: cannot remove 'blktests/results/tmpdir.nvme.040.m2J': Directory not empty

Hi Daniel, thanks for the patch. It looks good to me. Now the test case leaves a loop device. This patch avoids it. Good.

Question, I do not observe the rm command failure in my test environments. Do you have insight why you were able to find the failure?

#2 lore raw
Quoted 7 lines · Shinichiro Kawasaki
Quoted 6 lines · Daniel Wagner

The tests does not cleanup all resources after it has finished. This leads to rm not being able to remove the TMPDIR cleanly:

+ rm -rf blktests/results/tmpdir.nvme.040.m2J
rm: cannot remove 'blktests/results/tmpdir.nvme.040.m2J': Directory not empty

Quoted 7 lines
Quoted 1 line

Hi Daniel, thanks for the patch. It looks good to me. Now the test case leaves a loop device. This patch avoids it. Good.

Question, I do not observe the rm command failure in my test environments. Do you have insight why you were able to find the failure?

I am running the tests inside a VM and I am sharing a part of my host filesystem via NFS which contain the blktests. If I understood it correctly, the NFS server is behaving slightly differently here. I can't observe it either with xfs or btrfs.

#3 lore raw
Quoted 13 lines · Daniel Wagner
Quoted 12 lines · Shinichiro Kawasaki
Quoted 7 lines · Daniel Wagner

The tests does not cleanup all resources after it has finished. This leads to rm not being able to remove the TMPDIR cleanly:

+ rm -rf blktests/results/tmpdir.nvme.040.m2J
rm: cannot remove 'blktests/results/tmpdir.nvme.040.m2J': Directory not empty

Hi Daniel, thanks for the patch. It looks good to me. Now the test case leaves a loop device. This patch avoids it. Good.

Quoted 7 lines
Quoted 2 lines

Question, I do not observe the rm command failure in my test environments. Do you have insight why you were able to find the failure?

I am running the tests inside a VM and I am sharing a part of my host filesystem via NFS which contain the blktests. If I understood it correctly, the NFS server is behaving slightly differently here. I can't observe it either with xfs or btrfs.

I see, the NFS sounds triggering the failure. I've applied the patch. Thanks!