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, hch@lst.de, kbusch@kernel.org,
	sagi@grimberg.me, axboe@kernel.dk, chaitanyak@nvidia.com,
	gjoyce@linux.ibm.com
Subject: [PATCH blktests 2/2] nvme: add test for writing to file-ns just after disabling it
Date: Fri, 29 Nov 2024 13:31:37 +0530	[thread overview]
Message-ID: <20241129080231.2994578-3-nilay@linux.ibm.com> (raw)
In-Reply-To: <20241129080231.2994578-1-nilay@linux.ibm.com>

This is a regression test for commit 505363957fad ("nvmet: fix nvme
status code when namespace is disabled")[1].

This test creates a regular file backed loop target namespace and
then write to that namespace just after disabling it in a loop.

[1] https://lore.kernel.org/linux-nvme/tqcy3sveity7p56v7ywp7ssyviwcb3w4623cnxj3knoobfcanq@yxgt2mjkbkam/

Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
 tests/nvme/055     | 74 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/055.out |  2 ++
 2 files changed, 76 insertions(+)
 create mode 100755 tests/nvme/055
 create mode 100644 tests/nvme/055.out

diff --git a/tests/nvme/055 b/tests/nvme/055
new file mode 100755
index 0000000..0dbba74
--- /dev/null
+++ b/tests/nvme/055
@@ -0,0 +1,74 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2024 Nilay Shroff
+#
+# Regression test for commit 505363957fad ("nvmet: fix nvme
+# status code when namespace is disabled").
+
+. tests/nvme/rc
+
+DESCRIPTION="Test nvme write to a loop target ns just after ns is disabled"
+
+QUICK=1
+
+requires() {
+	_nvme_requires
+	_have_loop
+	_require_nvme_trtype_is_loop
+}
+
+set_conditions() {
+	_set_nvme_trtype "$@"
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	local iterations=10
+
+	_setup_nvmet
+
+	_nvmet_target_setup
+
+	_nvme_connect_subsys
+
+	img="$(mktemp /tmp/blk_img_XXXXXX)"
+	dd if=/dev/urandom of="$img" bs=512 count=1 status=none
+
+	subsys_path="${NVMET_CFS}/subsystems/${def_subsysnqn}"
+	ns_path="${subsys_path}/namespaces/${def_nsid}"
+
+	for ((i = 0; i < iterations; i++)); do
+
+		# wait until async request is processed and ns is created
+		if ! _nvmf_wait_for_ns "${def_subsys_uuid}" created; then
+			echo "FAIL"
+			break
+		fi
+
+		disk="/dev/$(_find_nvme_ns "${def_subsys_uuid}")"
+
+		# disable target namespace and write to it
+		echo 0 > ${ns_path}/enable
+		nvme write --start-block=1 --block-count=0 \
+			--data-size=512 --data="$img" "$disk" 2>>"$FULL"
+
+		# wait until async request is processed and ns is removed
+		if ! _nvmf_wait_for_ns "${def_subsys_uuid}" removed; then
+			echo "FAIL"
+			break
+		fi
+
+		# enable target namespace
+		echo 1 > ${ns_path}/enable
+	done
+
+	rm "$img"
+
+	_nvme_disconnect_subsys >> "$FULL" 2>&1
+
+	_nvmet_target_cleanup
+
+
+	echo "Test complete"
+}
diff --git a/tests/nvme/055.out b/tests/nvme/055.out
new file mode 100644
index 0000000..bbefc28
--- /dev/null
+++ b/tests/nvme/055.out
@@ -0,0 +1,2 @@
+Running nvme/055
+Test complete
-- 
2.45.2



  parent reply	other threads:[~2024-11-29  8:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-29  8:01 [PATCH blktests 0/2] add nvme test for creating sleep while atomic kernel BUG Nilay Shroff
2024-11-29  8:01 ` [PATCH blktests 1/2] nvme/052: move nvmf_wait_for_ns() to common/nvme Nilay Shroff
2024-12-03  4:18   ` Chaitanya Kulkarni
2024-11-29  8:01 ` Nilay Shroff [this message]
2024-11-30  9:10 ` [PATCH blktests 0/2] add nvme test for creating sleep while atomic kernel BUG Shinichiro Kawasaki
2024-12-03  4:20   ` Chaitanya Kulkarni
2024-12-03  5:38   ` Nilay Shroff
2024-12-03  8:26     ` Shinichiro Kawasaki
2024-12-03  9:05       ` Nilay Shroff
2024-12-06  1:09         ` Shinichiro Kawasaki
2024-12-03  8:26     ` Chaitanya Kulkarni
2024-12-04 10:08       ` 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=20241129080231.2994578-3-nilay@linux.ibm.com \
    --to=nilay@linux.ibm.com \
    --cc=axboe@kernel.dk \
    --cc=chaitanyak@nvidia.com \
    --cc=gjoyce@linux.ibm.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --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