linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org
Cc: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Subject: [PATCH blktests 3/3] block/011: recover test target NVME device capacity
Date: Fri, 26 May 2023 13:58:43 +0900	[thread overview]
Message-ID: <20230526045843.168739-4-shinichiro.kawasaki@wdc.com> (raw)
In-Reply-To: <20230526045843.168739-1-shinichiro.kawasaki@wdc.com>

The test case runs fio while disabling and enabling PCI device of the
test target block device. When the block device is a NVME PCI device,
the test triggers NVME controller reset. When an error happens during
the reset, NVME PCI driver marks zero capacity for the device. This
zero capacity device causes failures of the following test cases.

To avoid the failures by zero device capacity, check the capacity at the
test end. If it is zero, remove the device and rescan PCI bus to detect
the device again, and regain the correct capacity.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 tests/block/011 | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tests/block/011 b/tests/block/011
index 0699936..a4230f4 100755
--- a/tests/block/011
+++ b/tests/block/011
@@ -59,4 +59,18 @@ test_device() {
 	done
 
 	echo "Test complete"
+
+	# This test triggers NVME controller resets. When any failure happens
+	# during the resets, the driver marks the NVME block devices with zero
+	# capacity. Then following tests fail with the zero capacity devices. To
+	# get back the correct capacity, remove and rescan the devices.
+	if ((!$(<"$TEST_DEV_SYSFS/size"))); then
+		echo "$TEST_DEV has zero capacity" >> "$FULL"
+		if [[ -w $TEST_DEV_SYSFS/device/device/remove ]] &&
+			   [[ -w /sys/bus/pci/rescan ]]; then
+			echo "Rescan to tegain the correct capacity" >> "$FULL"
+			echo 1 > "$TEST_DEV_SYSFS/device/device/remove"
+			echo 1 > /sys/bus/pci/rescan
+		fi
+	fi
 }
-- 
2.40.1



  parent reply	other threads:[~2023-05-26  4:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26  4:58 [PATCH blktests 0/3] improve block/011 Shin'ichiro Kawasaki
2023-05-26  4:58 ` [PATCH blktests 1/3] common/rc: introduce _get_pci_from_dev_sysfs Shin'ichiro Kawasaki
2023-05-26  4:58 ` [PATCH blktests 2/3] block/011: skip when mounted block devices are affected Shin'ichiro Kawasaki
2023-05-26  4:58 ` Shin'ichiro Kawasaki [this message]
2023-06-13 11:35 ` [PATCH blktests 0/3] improve block/011 Shinichiro Kawasaki

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=20230526045843.168739-4-shinichiro.kawasaki@wdc.com \
    --to=shinichiro.kawasaki@wdc.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).