Skip to contentSkip to conversation

nvme/068: add a test for multipath delayed removal

PATCH Applied John Garry 3 participants 3 messages Apr 30 – May 15

Subsystems (2)
lore
Share & tools
lore

John Garry

author
#0 lore raw

PATCH v3 1/1 nvme/068: add a test for multipath delayed removal

For NVMe multipath, the delayed removal feature allows the multipath gendisk to remain present when all available paths are gone. The purpose of this feature is to ensure that we keep the gendisk for intermittent path failures.

The delayed removal works on a timer - when all paths are gone, a timer is kicked off; once the timer expires and no paths have returned, the gendisk is removed.

When all paths are gone and the gendisk is still present, all reads and writes to the disk are queued. If a path returns before the timer expiration, the timer canceled and the queued IO is submitted; otherwise they fail when the timer expires.

This testcase covers two scenarios in separate parts:
a. test that IOs submitted after all paths are removed (and do not return)
fail
b. test that IOs submitted between all paths removed and a path
returning succeed

During the period of the timer being active, it must be ensured that the nvme-core module is not removed. Otherwise the driver may not be present to handle the timeout expiry. The kernel ensures this by taking a reference to the module. Ideally, we would try to remove the module during this test to prove that this is not possible (and the kernel behaves as expected), but that module will probably not be removable anyway due to many references. To test this feature, check that the refcount of the nvme-core module is incremented when the delayed timer is active.

---

@Chaitanya, @Nilay, Please check changes since RB tag granted

Differences to v2:
- Stop using sleeps so often (Daniel)
- Add RB tag from Nilay (Thanks!)

Differences to v1:
- Add RB tag from Chaitanya (Thanks!)
- Address shellcheck issues (Shinichiro)
- Drop Quick=1 (Shinichiro)
- Reference kernel commit (Nilay)
- Tidy setting refcnt (Nilay)

Note that a fix for a refcnt issue has been merged into nvme-7.1 queue

common/nvme +32 -0
index 565de59..3dc9e2c 100644
@@ -268,6 +268,38 @@ _nvme_disconnect_ctrl() {
 	nvme disconnect --device "${ctrl}"
 }
 
+_nvme_disconnect_ctrl_sync() {
+	local ctrl="$1"
+	local subsysnqn="$2"
+
+	_nvme_disconnect_ctrl "${ctrl}"
+
+	for ((i = 0; i < 10; i++)); do
+		_nvme_ctrl_ready "${ctrl}" "${subsysnqn}"
+		if [[ $? -eq 1 ]]; then
+			break
+		fi
+		sleep .1
+	done
+}
+
+_nvme_wait_subsys_removed() {
+	local subsysnqn="$def_subsysnqn"
+
+	for subsyspath in /sys/class/nvme-subsystem/*; do
+		_subsysnqn=$(cat "${subsyspath}/subsysnqn" 2> /dev/null)
+		if [ "$subsysnqn" == "$_subsysnqn" ]; then
+			for ((i = 0; i < 10; i++)); do
+				if [ ! -d "$subsyspath" ]; then
+					break
+				fi
+				sleep .1
+			done
+			break
+		fi
+	done
+}
+
 _nvme_connect_subsys() {
 	local subsysnqn="$def_subsysnqn"
 	local hostnqn="$def_hostnqn"
common/rc +10 -0
index d2c1d74..f73c22f 100644
@@ -117,6 +117,16 @@ _module_not_in_use() {
 	fi
 }
 
+_module_use_count() {
+	local refcnt
+	if [ -f "/sys/module/$1/refcnt" ]; then
+		refcnt="$(cat /sys/module/"$1"/refcnt)"
+		echo "$refcnt"
+		return
+	fi
+	echo ""
+}
+
 _have_module_param() {
 	 _have_driver "$1" || return
 
tests/nvme/068 new file +113 -0

113 lines not on this page · raw message

tests/nvme/068.out new file +3 -0
new file mode 100644
index 0000000..b913d19
@@ -0,0 +1,3 @@
+Running nvme/068
+pwrite: Input/output error
+Test complete
Signature · 1 line
2.43.5
Reviewed-by on v3 1/1
#1 lore raw

Hi John,

Quoted 32 lines · John Garry

For NVMe multipath, the delayed removal feature allows the multipath gendisk to remain present when all available paths are gone. The purpose of this feature is to ensure that we keep the gendisk for intermittent path failures.

The delayed removal works on a timer - when all paths are gone, a timer is kicked off; once the timer expires and no paths have returned, the gendisk is removed.

When all paths are gone and the gendisk is still present, all reads and writes to the disk are queued. If a path returns before the timer expiration, the timer canceled and the queued IO is submitted; otherwise they fail when the timer expires.

This testcase covers two scenarios in separate parts:
a. test that IOs submitted after all paths are removed (and do not return)
fail
b. test that IOs submitted between all paths removed and a path
returning succeed

During the period of the timer being active, it must be ensured that the nvme-core module is not removed. Otherwise the driver may not be present to handle the timeout expiry. The kernel ensures this by taking a reference to the module. Ideally, we would try to remove the module during this test to prove that this is not possible (and the kernel behaves as expected), but that module will probably not be removable anyway due to many references. To test this feature, check that the refcount of the nvme-core module is incremented when the delayed timer is active.

Quoted 6 lines

---

@Chaitanya, @Nilay, Please check changes since RB tag granted

Differences to v2:
- Stop using sleeps so often (Daniel)

Thanks! Looks good to me.

#2 lore raw
In reply to John Garry
Quoted 29 lines · John Garry

For NVMe multipath, the delayed removal feature allows the multipath gendisk to remain present when all available paths are gone. The purpose of this feature is to ensure that we keep the gendisk for intermittent path failures.

The delayed removal works on a timer - when all paths are gone, a timer is kicked off; once the timer expires and no paths have returned, the gendisk is removed.

When all paths are gone and the gendisk is still present, all reads and writes to the disk are queued. If a path returns before the timer expiration, the timer canceled and the queued IO is submitted; otherwise they fail when the timer expires.

This testcase covers two scenarios in separate parts:
a. test that IOs submitted after all paths are removed (and do not return)
fail
b. test that IOs submitted between all paths removed and a path
returning succeed

During the period of the timer being active, it must be ensured that the nvme-core module is not removed. Otherwise the driver may not be present to handle the timeout expiry. The kernel ensures this by taking a reference to the module. Ideally, we would try to remove the module during this test to prove that this is not possible (and the kernel behaves as expected), but that module will probably not be removable anyway due to many references. To test this feature, check that the refcount of the nvme-core module is incremented when the delayed timer is active.

Quoted 3 lines

I applied this patch. Thanks!