public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Nilay Shroff <nilay@linux.ibm.com>
To: linux-nvme@lists.infradead.org
Cc: shinichiro.kawasaki@wdc.com, hare@suse.de, gjoyce@ibm.com
Subject: [PATCH blktests] nvme/058: detach loop device after test finish
Date: Thu, 16 Jan 2025 18:52:13 +0530	[thread overview]
Message-ID: <20250116132231.349917-1-nilay@linux.ibm.com> (raw)

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@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



             reply	other threads:[~2025-01-16 13:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16 13:22 Nilay Shroff [this message]
2025-01-23  4:53 ` [PATCH blktests] nvme/058: detach loop device after test finish Shinichiro Kawasaki
2025-01-24  7:31   ` Nilay Shroff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250116132231.349917-1-nilay@linux.ibm.com \
    --to=nilay@linux.ibm.com \
    --cc=gjoyce@ibm.com \
    --cc=hare@suse.de \
    --cc=linux-nvme@lists.infradead.org \
    --cc=shinichiro.kawasaki@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox