[PATCH blktests] nvme/058: detach loop device after test finish
Nilay Shroff
nilay at linux.ibm.com
Thu Jan 16 05:22:13 PST 2025
The nvme/058 creates three (temp file backed) namespaces and
attach each namespace to a loop device while starting the test.
However it never detach those namespaces from the loop device
once test finishes. Ideally, we should detach loop device from
namespace so that the associated loop device is later destroyed
and its resources are released. This patch helps detach each
namespace from its associated loop device after test finishes.
Signed-off-by: Nilay Shroff <nilay at linux.ibm.com>
---
tests/nvme/058 | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/tests/nvme/058 b/tests/nvme/058
index d230a21..99e7e81 100755
--- a/tests/nvme/058
+++ b/tests/nvme/058
@@ -99,6 +99,17 @@ test() {
done
_nvme_disconnect_subsys
+
+ for ((d = 1; d <= num_namespaces; d++)); do
+ local file_path
+ local blkdev
+
+ file_path="${TMPDIR}/img${d}"
+ blkdev="$(losetup -l | awk -v path="${file_path}" '$6 == path { print $1 }')"
+
+ losetup -d "${blkdev}"
+ done
+
_nvmet_target_cleanup
echo "Test complete"
--
2.47.1
More information about the Linux-nvme
mailing list