Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 blktests] nvme/058: detach loop device after test finish
@ 2025-01-24  7:47 Nilay Shroff
  2025-01-24  8:28 ` Hannes Reinecke
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Nilay Shroff @ 2025-01-24  7:47 UTC (permalink / raw)
  To: linux-nvme; +Cc: shinichiro.kawasaki, hare, gjoyce

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>
---
Changes from v1:
    - keep blkdevs, which are used for setting up ns, in an array
      and then later access the array to free/detach each blkdev
      (Shinichiro Kawasaki)
    - use longer option name instead of short name for readability
      (Shinichiro Kawasaki)
---
 tests/nvme/058 | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tests/nvme/058 b/tests/nvme/058
index d230a21..815503f 100755
--- a/tests/nvme/058
+++ b/tests/nvme/058
@@ -65,11 +65,13 @@ test() {
 	for ((d = 1; d <= num_namespaces; d++)); do
 		local file_path
 		local blkdev
+		local -a blkdevs
 		local uuid
 
 		file_path="${TMPDIR}/img${d}"
 		truncate -s "${NVME_IMG_SIZE}" "${file_path}"
 		blkdev="$(losetup -f --show "${file_path}")"
+		blkdevs+=("$blkdev")
 		uuid="$(uuidgen)"
 		_create_nvmet_ns --nsid "${d}" --blkdev "${blkdev}" \
 				 --uuid "${uuid}" --grpid "${d}" > /dev/null
@@ -99,6 +101,11 @@ test() {
 	done
 
 	_nvme_disconnect_subsys
+
+	for blkdev in "${blkdevs[@]}"; do
+		losetup --detach "$blkdev"
+	done
+
 	_nvmet_target_cleanup
 
 	echo "Test complete"
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCHv2 blktests] nvme/058: detach loop device after test finish
  2025-01-24  7:47 [PATCHv2 blktests] nvme/058: detach loop device after test finish Nilay Shroff
@ 2025-01-24  8:28 ` Hannes Reinecke
  2025-01-24 11:02 ` Sagi Grimberg
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Hannes Reinecke @ 2025-01-24  8:28 UTC (permalink / raw)
  To: Nilay Shroff, linux-nvme; +Cc: shinichiro.kawasaki, gjoyce

On 1/24/25 08:47, Nilay Shroff wrote:
> 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>
> ---
> Changes from v1:
>      - keep blkdevs, which are used for setting up ns, in an array
>        and then later access the array to free/detach each blkdev
>        (Shinichiro Kawasaki)
>      - use longer option name instead of short name for readability
>        (Shinichiro Kawasaki)
> ---
>   tests/nvme/058 | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv2 blktests] nvme/058: detach loop device after test finish
  2025-01-24  7:47 [PATCHv2 blktests] nvme/058: detach loop device after test finish Nilay Shroff
  2025-01-24  8:28 ` Hannes Reinecke
@ 2025-01-24 11:02 ` Sagi Grimberg
  2025-01-26 23:25 ` Chaitanya Kulkarni
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sagi Grimberg @ 2025-01-24 11:02 UTC (permalink / raw)
  To: Nilay Shroff, linux-nvme; +Cc: shinichiro.kawasaki, hare, gjoyce

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv2 blktests] nvme/058: detach loop device after test finish
  2025-01-24  7:47 [PATCHv2 blktests] nvme/058: detach loop device after test finish Nilay Shroff
  2025-01-24  8:28 ` Hannes Reinecke
  2025-01-24 11:02 ` Sagi Grimberg
@ 2025-01-26 23:25 ` Chaitanya Kulkarni
  2025-01-27  7:01 ` Hannes Reinecke
  2025-01-27  9:01 ` Shinichiro Kawasaki
  4 siblings, 0 replies; 6+ messages in thread
From: Chaitanya Kulkarni @ 2025-01-26 23:25 UTC (permalink / raw)
  To: Nilay Shroff, linux-nvme@lists.infradead.org
  Cc: shinichiro.kawasaki@wdc.com, hare@suse.de, gjoyce@ibm.com

On 1/23/25 23:47, Nilay Shroff wrote:
> 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>

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv2 blktests] nvme/058: detach loop device after test finish
  2025-01-24  7:47 [PATCHv2 blktests] nvme/058: detach loop device after test finish Nilay Shroff
                   ` (2 preceding siblings ...)
  2025-01-26 23:25 ` Chaitanya Kulkarni
@ 2025-01-27  7:01 ` Hannes Reinecke
  2025-01-27  9:01 ` Shinichiro Kawasaki
  4 siblings, 0 replies; 6+ messages in thread
From: Hannes Reinecke @ 2025-01-27  7:01 UTC (permalink / raw)
  To: Nilay Shroff, linux-nvme; +Cc: shinichiro.kawasaki, gjoyce

On 1/24/25 08:47, Nilay Shroff wrote:
> 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>
> ---
> Changes from v1:
>      - keep blkdevs, which are used for setting up ns, in an array
>        and then later access the array to free/detach each blkdev
>        (Shinichiro Kawasaki)
>      - use longer option name instead of short name for readability
>        (Shinichiro Kawasaki)
> ---
>   tests/nvme/058 | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
Reviewed-by: Hannes Reinecke <hare@kernel.org>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv2 blktests] nvme/058: detach loop device after test finish
  2025-01-24  7:47 [PATCHv2 blktests] nvme/058: detach loop device after test finish Nilay Shroff
                   ` (3 preceding siblings ...)
  2025-01-27  7:01 ` Hannes Reinecke
@ 2025-01-27  9:01 ` Shinichiro Kawasaki
  4 siblings, 0 replies; 6+ messages in thread
From: Shinichiro Kawasaki @ 2025-01-27  9:01 UTC (permalink / raw)
  To: Nilay Shroff; +Cc: linux-nvme@lists.infradead.org, hare@suse.de, gjoyce@ibm.com

On Jan 24, 2025 / 13:17, Nilay Shroff wrote:
> 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>

FYI, I applied this patch with a slight edit to move local variable
declarations. Thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-01-27  9:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-24  7:47 [PATCHv2 blktests] nvme/058: detach loop device after test finish Nilay Shroff
2025-01-24  8:28 ` Hannes Reinecke
2025-01-24 11:02 ` Sagi Grimberg
2025-01-26 23:25 ` Chaitanya Kulkarni
2025-01-27  7:01 ` Hannes Reinecke
2025-01-27  9:01 ` Shinichiro Kawasaki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox