All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH blktests 1/3] nvme: move _find_nvme_loop_dev to common code
@ 2018-05-03 15:00 Johannes Thumshirn
  2018-05-03 15:00 ` [PATCH blktests 2/3] nvme: fix counting the target port Johannes Thumshirn
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2018-05-03 15:00 UTC (permalink / raw)


_find_nvme_loop_dev is quite useful for all nvme test, so move it over
to common code.

Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
---
 common/nvme    | 10 ++++++++++
 tests/nvme/004 | 14 ++------------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/common/nvme b/common/nvme
index c6718f04811b..c4a44065cd9f 100644
--- a/common/nvme
+++ b/common/nvme
@@ -93,3 +93,13 @@ _remove_nvmet_subsystem_from_port() {
 
 	rm "${nvmet_cfs}/ports/${port}/subsystems/${nvmet_subsystem}"
 }
+
+_find_nvme_loop_dev() {
+	for dev in /sys/class/nvme/nvme*; do
+		dev="$(basename "$dev")"
+		transport="$(cat "/sys/class/nvme/${dev}/transport")"
+		if [[ "$transport" == "loop" ]]; then
+			echo "$dev"
+		fi
+	done
+}
diff --git a/tests/nvme/004 b/tests/nvme/004
index 65bcd40d86d1..2f970b366d41 100755
--- a/tests/nvme/004
+++ b/tests/nvme/004
@@ -27,16 +27,6 @@ requires() {
 		_have_configfs
 }
 
-_find_nvme_loop_dev() {
-	for dev in /sys/block/nvme*; do
-		dev="$(basename "$dev")"
-		transport="$(cat "/sys/block/${dev}/device/transport")"
-		if [[ "$transport" == "loop" ]]; then
-			echo "$dev"
-		fi
-	done
-}
-
 test() {
 	echo "Running ${TEST_NAME}"
 
@@ -59,8 +49,8 @@ test() {
 
 	local nvmedev
 	nvmedev="$(_find_nvme_loop_dev)"
-	cat "/sys/block/${nvmedev}/uuid"
-	cat "/sys/block/${nvmedev}/wwid"
+	cat "/sys/block/${nvmedev}n1/uuid"
+	cat "/sys/block/${nvmedev}n1/wwid"
 
 	_remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1"
 	_remove_nvmet_subsystem "blktests-subsystem-1"
-- 
2.16.3

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

* [PATCH blktests 2/3] nvme: fix counting the target port
  2018-05-03 15:00 [PATCH blktests 1/3] nvme: move _find_nvme_loop_dev to common code Johannes Thumshirn
@ 2018-05-03 15:00 ` Johannes Thumshirn
  2018-05-03 15:00 ` [PATCH blktests 3/3] nvme: add test for resetting the loopback controller Johannes Thumshirn
  2018-05-14 20:02 ` [PATCH blktests 1/3] nvme: move _find_nvme_loop_dev to common code Omar Sandoval
  2 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2018-05-03 15:00 UTC (permalink / raw)


Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
---
 common/nvme | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/nvme b/common/nvme
index c4a44065cd9f..3e20eeaa5744 100644
--- a/common/nvme
+++ b/common/nvme
@@ -27,11 +27,11 @@ _test_dev_is_nvme() {
 
 _create_nvmet_port() {
 	local trtype="$1"
-	local nvmet_cfs="/sys/kernel/config/nvmet/"
+	local nvmet_cfs="/sys/kernel/config/nvmet"
 
 	local port
 	for ((port = 0; ; port++)); do
-		if [[ ! -e "${nvmet_cfs}/${port}" ]]; then
+		if [[ ! -e "${nvmet_cfs}/ports/${port}" ]]; then
 			break
 		fi
 	done
-- 
2.16.3

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

* [PATCH blktests 3/3] nvme: add test for resetting the loopback controller
  2018-05-03 15:00 [PATCH blktests 1/3] nvme: move _find_nvme_loop_dev to common code Johannes Thumshirn
  2018-05-03 15:00 ` [PATCH blktests 2/3] nvme: fix counting the target port Johannes Thumshirn
@ 2018-05-03 15:00 ` Johannes Thumshirn
  2018-05-03 19:03   ` chaitany kulkarni
  2018-05-14 20:02 ` [PATCH blktests 1/3] nvme: move _find_nvme_loop_dev to common code Omar Sandoval
  2 siblings, 1 reply; 7+ messages in thread
From: Johannes Thumshirn @ 2018-05-03 15:00 UTC (permalink / raw)


Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
---
 tests/nvme/005     | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/005.out |  2 ++
 2 files changed, 79 insertions(+)
 create mode 100755 tests/nvme/005
 create mode 100644 tests/nvme/005.out

diff --git a/tests/nvme/005 b/tests/nvme/005
new file mode 100755
index 000000000000..77f843fed692
--- /dev/null
+++ b/tests/nvme/005
@@ -0,0 +1,77 @@
+#!/bin/bash
+#
+# Regression test for patch "nvmet: switch loopback target state to connecting
+# when resetting"
+#
+# Copyright (C) 2018 Johannes Thumshirn
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+DESCRIPTION="reset local loopback target"
+
+QUICK=1
+
+requires() {
+ 	_have_module nvme-loop && _have_module nvmet && _have_module loop && \
+		_have_configfs && _have_module nvme-core && \
+		_have_module_param nvme-core multipath
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	# Clean up all stale modules
+	modprobe -r nvme-loop
+	modprobe -r nvme-core
+	modprobe -r nvmet
+
+	modprobe nvme-core multipath=1
+	modprobe nvmet
+	modprobe nvme-loop
+
+	local port
+	port=$(_create_nvmet_port "loop")
+
+	truncate -s 1G "$TMPDIR/img"
+
+	local loop_dev
+	loop_dev="$(losetup -f --show "$TMPDIR/img")"
+
+	_create_nvmet_subsystem "blktests-subsystem-1" "${loop_dev}" \
+		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+	_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
+
+	nvme connect -t loop -n blktests-subsystem-1
+
+	local nvmedev
+	nvmedev="$(_find_nvme_loop_dev)"
+
+	udevadm settle
+
+	echo 1 > "/sys/class/nvme/${nvmedev}/reset_controller"
+
+	nvme disconnect -d "${nvmedev}"
+	_remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1"
+	_remove_nvmet_port "${port}"
+
+	_remove_nvmet_subsystem "blktests-subsystem-1"
+	losetup -d "$loop_dev"
+	rm "$TMPDIR/img"
+
+	modprobe -r nvme-loop
+	modprobe -r nvme-core
+	modprobe -r nvmet
+
+	echo "Test complete"
+}
diff --git a/tests/nvme/005.out b/tests/nvme/005.out
new file mode 100644
index 000000000000..6146a7b8b1a7
--- /dev/null
+++ b/tests/nvme/005.out
@@ -0,0 +1,2 @@
+Running nvme/005
+Test complete
-- 
2.16.3

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

* [PATCH blktests 3/3] nvme: add test for resetting the loopback controller
  2018-05-03 15:00 ` [PATCH blktests 3/3] nvme: add test for resetting the loopback controller Johannes Thumshirn
@ 2018-05-03 19:03   ` chaitany kulkarni
  2018-05-04  7:34     ` Johannes Thumshirn
  0 siblings, 1 reply; 7+ messages in thread
From: chaitany kulkarni @ 2018-05-03 19:03 UTC (permalink / raw)


Hi Johannes,

Thanks for submitting the test.

I was wondering if we can move the generic setup and clean up
functionality to the helpers for reference:-

+pre()
+{
+      # Clean up all stale modules
+       modprobe -r nvme-loop
+       modprobe -r nvme-core
+       modprobe -r nvmet
+
}

+post()
+{
+       modprobe -r nvme-loop
+       modprobe -r nvme-core
+       modprobe -r nvmet
+
+}

+test() {
+       echo "Running ${TEST_NAME}"
+
+       pre
+
+       modprobe nvme-core multipath=1
+       modprobe nvmet
+       modprobe nvme-loop
+
+       local port
+       port=$(_create_nvmet_port "loop")
+
+       truncate -s 1G "$TMPDIR/img"
+
+       local loop_dev
+       loop_dev="$(losetup -f --show "$TMPDIR/img")"
+
+       _create_nvmet_subsystem "blktests-subsystem-1" "${loop_dev}" \
+               "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+       _add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
+
+       nvme connect -t loop -n blktests-subsystem-1
+
+       local nvmedev
+       nvmedev="$(_find_nvme_loop_dev)"
+
+       udevadm settle
+
+       echo 1 > "/sys/class/nvme/${nvmedev}/reset_controller"
+
+       nvme disconnect -d "${nvmedev}"
+       _remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1"
+       _remove_nvmet_port "${port}"
+
+       _remove_nvmet_subsystem "blktests-subsystem-1"
+       losetup -d "$loop_dev"
+       rm "$TMPDIR/img"
+
+       post
+
+       echo "Test complete"
+}

In this way, we can move generic pre and post to the nvme/lib so that
all other tests can also use that?


On Thu, May 3, 2018@8:00 AM, Johannes Thumshirn <jthumshirn@suse.de> wrote:
> Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
> ---
>  tests/nvme/005     | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/nvme/005.out |  2 ++
>  2 files changed, 79 insertions(+)
>  create mode 100755 tests/nvme/005
>  create mode 100644 tests/nvme/005.out
>
> diff --git a/tests/nvme/005 b/tests/nvme/005
> new file mode 100755
> index 000000000000..77f843fed692
> --- /dev/null
> +++ b/tests/nvme/005
> @@ -0,0 +1,77 @@
> +#!/bin/bash
> +#
> +# Regression test for patch "nvmet: switch loopback target state to connecting
> +# when resetting"
> +#
> +# Copyright (C) 2018 Johannes Thumshirn
> +#
> +# This program is free software: you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation, either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +DESCRIPTION="reset local loopback target"
> +
> +QUICK=1
> +
> +requires() {
> +       _have_module nvme-loop && _have_module nvmet && _have_module loop && \
> +               _have_configfs && _have_module nvme-core && \
> +               _have_module_param nvme-core multipath
> +}
> +
> +test() {
> +       echo "Running ${TEST_NAME}"
> +
> +       # Clean up all stale modules
> +       modprobe -r nvme-loop
> +       modprobe -r nvme-core
> +       modprobe -r nvmet
> +
> +       modprobe nvme-core multipath=1
> +       modprobe nvmet
> +       modprobe nvme-loop
> +
> +       local port
> +       port=$(_create_nvmet_port "loop")
> +
> +       truncate -s 1G "$TMPDIR/img"
> +
> +       local loop_dev
> +       loop_dev="$(losetup -f --show "$TMPDIR/img")"
> +
> +       _create_nvmet_subsystem "blktests-subsystem-1" "${loop_dev}" \
> +               "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
> +       _add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
> +
> +       nvme connect -t loop -n blktests-subsystem-1
> +
> +       local nvmedev
> +       nvmedev="$(_find_nvme_loop_dev)"
> +
> +       udevadm settle
> +
> +       echo 1 > "/sys/class/nvme/${nvmedev}/reset_controller"
> +
> +       nvme disconnect -d "${nvmedev}"
> +       _remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1"
> +       _remove_nvmet_port "${port}"
> +
> +       _remove_nvmet_subsystem "blktests-subsystem-1"
> +       losetup -d "$loop_dev"
> +       rm "$TMPDIR/img"
> +
> +       modprobe -r nvme-loop
> +       modprobe -r nvme-core
> +       modprobe -r nvmet
> +
> +       echo "Test complete"
> +}
> diff --git a/tests/nvme/005.out b/tests/nvme/005.out
> new file mode 100644
> index 000000000000..6146a7b8b1a7
> --- /dev/null
> +++ b/tests/nvme/005.out
> @@ -0,0 +1,2 @@
> +Running nvme/005
> +Test complete
> --
> 2.16.3
>
>
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* [PATCH blktests 3/3] nvme: add test for resetting the loopback controller
  2018-05-03 19:03   ` chaitany kulkarni
@ 2018-05-04  7:34     ` Johannes Thumshirn
  0 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2018-05-04  7:34 UTC (permalink / raw)


On Thu, May 03, 2018@12:03:15PM -0700, chaitany kulkarni wrote:
> Hi Johannes,
> 
> Thanks for submitting the test.
> 
> I was wondering if we can move the generic setup and clean up
> functionality to the helpers for reference:-
> 
> +pre()
> +{
> +      # Clean up all stale modules
> +       modprobe -r nvme-loop
> +       modprobe -r nvme-core
> +       modprobe -r nvmet
> +
> }
> 
> +post()
> +{
> +       modprobe -r nvme-loop
> +       modprobe -r nvme-core
> +       modprobe -r nvmet
> +
> +}

I was thinking of the same as well but then I'd rather love "generic"
pre()/post() callbacks which the framework calles and not the actual
test case (just like requires() et al).

You can't really make the content's of pre()/post() generically enough
for all tests of a category unfortunately so I think placing them into
common/ won't work (i.e. for the next test I have in the pipeline I
need nvme-fcloop not nvme-loop, and so on).

Let me think a bit more about it.

    Johannes
-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

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

* [PATCH blktests 1/3] nvme: move _find_nvme_loop_dev to common code
  2018-05-03 15:00 [PATCH blktests 1/3] nvme: move _find_nvme_loop_dev to common code Johannes Thumshirn
  2018-05-03 15:00 ` [PATCH blktests 2/3] nvme: fix counting the target port Johannes Thumshirn
  2018-05-03 15:00 ` [PATCH blktests 3/3] nvme: add test for resetting the loopback controller Johannes Thumshirn
@ 2018-05-14 20:02 ` Omar Sandoval
  2018-05-15  6:50   ` Johannes Thumshirn
  2 siblings, 1 reply; 7+ messages in thread
From: Omar Sandoval @ 2018-05-14 20:02 UTC (permalink / raw)


On Thu, May 03, 2018@05:00:52PM +0200, Johannes Thumshirn wrote:
> _find_nvme_loop_dev is quite useful for all nvme test, so move it over
> to common code.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
> ---
>  common/nvme    | 10 ++++++++++
>  tests/nvme/004 | 14 ++------------
>  2 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/common/nvme b/common/nvme
> index c6718f04811b..c4a44065cd9f 100644
> --- a/common/nvme
> +++ b/common/nvme
> @@ -93,3 +93,13 @@ _remove_nvmet_subsystem_from_port() {
>  
>  	rm "${nvmet_cfs}/ports/${port}/subsystems/${nvmet_subsystem}"
>  }
> +
> +_find_nvme_loop_dev() {
> +	for dev in /sys/class/nvme/nvme*; do
> +		dev="$(basename "$dev")"
> +		transport="$(cat "/sys/class/nvme/${dev}/transport")"
> +		if [[ "$transport" == "loop" ]]; then
> +			echo "$dev"
> +		fi
> +	done
> +}
> diff --git a/tests/nvme/004 b/tests/nvme/004
> index 65bcd40d86d1..2f970b366d41 100755
> --- a/tests/nvme/004
> +++ b/tests/nvme/004
> @@ -27,16 +27,6 @@ requires() {
>  		_have_configfs
>  }
>  
> -_find_nvme_loop_dev() {
> -	for dev in /sys/block/nvme*; do
> -		dev="$(basename "$dev")"
> -		transport="$(cat "/sys/block/${dev}/device/transport")"
> -		if [[ "$transport" == "loop" ]]; then
> -			echo "$dev"
> -		fi
> -	done
> -}
> -
>  test() {
>  	echo "Running ${TEST_NAME}"
>  
> @@ -59,8 +49,8 @@ test() {
>  
>  	local nvmedev
>  	nvmedev="$(_find_nvme_loop_dev)"
> -	cat "/sys/block/${nvmedev}/uuid"
> -	cat "/sys/block/${nvmedev}/wwid"
> +	cat "/sys/block/${nvmedev}n1/uuid"
> +	cat "/sys/block/${nvmedev}n1/wwid"
>  
>  	_remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1"
>  	_remove_nvmet_subsystem "blktests-subsystem-1"
> -- 
> 2.16.3
> 

Thanks, Johannes, applied. I split patch 1 into two, though; one fixing
the test, and one just moving the function.

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

* [PATCH blktests 1/3] nvme: move _find_nvme_loop_dev to common code
  2018-05-14 20:02 ` [PATCH blktests 1/3] nvme: move _find_nvme_loop_dev to common code Omar Sandoval
@ 2018-05-15  6:50   ` Johannes Thumshirn
  0 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2018-05-15  6:50 UTC (permalink / raw)


On Mon, May 14, 2018@01:02:52PM -0700, Omar Sandoval wrote:
> Thanks, Johannes, applied. I split patch 1 into two, though; one fixing
> the test, and one just moving the function.

Thanks Omar
-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

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

end of thread, other threads:[~2018-05-15  6:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03 15:00 [PATCH blktests 1/3] nvme: move _find_nvme_loop_dev to common code Johannes Thumshirn
2018-05-03 15:00 ` [PATCH blktests 2/3] nvme: fix counting the target port Johannes Thumshirn
2018-05-03 15:00 ` [PATCH blktests 3/3] nvme: add test for resetting the loopback controller Johannes Thumshirn
2018-05-03 19:03   ` chaitany kulkarni
2018-05-04  7:34     ` Johannes Thumshirn
2018-05-14 20:02 ` [PATCH blktests 1/3] nvme: move _find_nvme_loop_dev to common code Omar Sandoval
2018-05-15  6:50   ` Johannes Thumshirn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.