Skip to contentSkip to conversation

Make the NVMe tests more reliable

PATCH In review Bart Van Assche 4 participants 6 messages Aug 5, 2019 – Aug 7, 2019 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make the NVMe tests more reliable

When running blktests with kernel debugging enabled it can happen that _find_nvme_loop_dev() returns before the NVMe block device has appeared in sysfs. This patch avoids that the NVMe tests fail as follows:

+cat: /sys/block/nvme1n1/uuid: No such file or directory +cat: /sys/block/nvme1n1/wwid: No such file or directory

Cc Logan Gunthorpe <[email protected]>
Cc Chaitanya Kulkarni <[email protected]>
Cc Johannes Thumshirn <[email protected]>
---
 tests/nvme/rc | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/nvme/rc +8 -0
index 348b4a3c2cbc..05dfc5915a13 100644
@@ -169,8 +169,16 @@ _find_nvme_loop_dev() {
 		transport="$(cat "/sys/class/nvme/${dev}/transport")"
 		if [[ "$transport" == "loop" ]]; then
 			echo "$dev"
+			for ((i=0;i<10;i++)); do
+				[ -e /sys/block/$dev/uuid ] &&
+					[ -e /sys/block/$dev/wwid ] &&
+					return 0
+				sleep .1
+			done
+			return 1
 		fi
 	done
+	return 1
 }
 
 _filter_discovery() {
Signature · 1 line
2.22.0.770.g0f2c4a37fd-goog
#1 lore raw

On 06/08/2019 01:25, Bart Van Assche wrote:
[...]

tests/nvme/rc _find_nvme_loop_dev() { · line 181

Quoted 10 lines
tests/nvme/rc +8 -0
+			for ((i=0;i<10;i++)); do
+				[ -e /sys/block/$dev/uuid ] &&
+					[ -e /sys/block/$dev/wwid ] &&
+					return 0
+				sleep .1
+			done
+			return 1
 		fi
 	done
+	return 1

Hmmm, I don't really understand why you're adding the return {0,1} here. None of the callers of _find_nvme_loop_dev() does anything with the return value of the function.

They expect either a nvme-device or an empty string and fail if the string is empty due to a non-empty diff in the golden output.

Thanks,
Johannes

Signature · 6 lines
Johannes Thumshirn                            SUSE Labs Filesystems
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
#2 lore raw
Quoted 18 lines · Johannes Thumshirn

On 06/08/2019 01:25, Bart Van Assche wrote:
[...]

tests/nvme/rc _find_nvme_loop_dev() { · line 181

Quoted 10 lines
tests/nvme/rc +8 -0
+			for ((i=0;i<10;i++)); do
+				[ -e /sys/block/$dev/uuid ] &&
+					[ -e /sys/block/$dev/wwid ] &&
+					return 0
+				sleep .1
+			done
+			return 1
  		fi
  	done
+	return 1

Hmmm, I don't really understand why you're adding the return {0,1} here. None of the callers of _find_nvme_loop_dev() does anything with the return value of the function.

Quoted 2 lines

They expect either a nvme-device or an empty string and fail if the string is empty due to a non-empty diff in the golden output.

Hi Johannes,

The "return 0" statement has been added to break out of the two for-loops. The first "return 1" statement has been added to make sure that the echo "$dev" statement is executed at most once. The final "return 1" statement has been added to make the return value consistent.

Do you perhaps want me to leave out {0,1} from the return statements?

Bart.

Reviewed-by
#3 lore raw
Quoted 22 lines · Bart Van Assche
Quoted 18 lines · Johannes Thumshirn

On 06/08/2019 01:25, Bart Van Assche wrote:
[...]

tests/nvme/rc _find_nvme_loop_dev() { · line 181

Quoted 10 lines
tests/nvme/rc +8 -0
+			for ((i=0;i<10;i++)); do
+				[ -e /sys/block/$dev/uuid ] &&
+					[ -e /sys/block/$dev/wwid ] &&
+					return 0
+				sleep .1
+			done
+			return 1
  		fi
  	done
+	return 1

Hmmm, I don't really understand why you're adding the return {0,1} here. None of the callers of _find_nvme_loop_dev() does anything with the return value of the function.

Quoted 2 lines

They expect either a nvme-device or an empty string and fail if the string is empty due to a non-empty diff in the golden output.

Quoted 8 lines

Hi Johannes,

The "return 0" statement has been added to break out of the two for-loops. The first "return 1" statement has been added to make sure that the echo "$dev" statement is executed at most once. The final "return 1" statement has been added to make the return value consistent.

Do you perhaps want me to leave out {0,1} from the return statements?

Yes, I think this is less confusing for readers.

With that,

Signature · 6 lines
Johannes Thumshirn                            SUSE Labs Filesystems
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Reviewed-by on v1 1/1
#4 lore raw
In reply to Bart Van Assche
Quoted 11 lines · Bart Van Assche

When running blktests with kernel debugging enabled it can happen that _find_nvme_loop_dev() returns before the NVMe block device has appeared in sysfs. This patch avoids that the NVMe tests fail as follows:

(quoted diff) +2 -0
+cat: /sys/block/nvme1n1/uuid: No such file or directory
+cat: /sys/block/nvme1n1/wwid: No such file or directory
Cc Logan Gunthorpe <[email protected]>
Cc Chaitanya Kulkarni <[email protected]>
Cc Johannes Thumshirn <[email protected]>

Makes sense to me.

Quoted 26 lines
---
 tests/nvme/rc | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/nvme/rc +8 -0
index 348b4a3c2cbc..05dfc5915a13 100644
@@ -169,8 +169,16 @@ _find_nvme_loop_dev() {
 		transport="$(cat "/sys/class/nvme/${dev}/transport")"
 		if [[ "$transport" == "loop" ]]; then
 			echo "$dev"
+			for ((i=0;i<10;i++)); do
+				[ -e /sys/block/$dev/uuid ] &&
+					[ -e /sys/block/$dev/wwid ] &&
+					return 0
+				sleep .1
+			done
+			return 1
 		fi
 	done
+	return 1
 }
 
 _filter_discovery() {
#5 lore raw
In reply to Bart Van Assche
Quoted 7 lines · Bart Van Assche

When running blktests with kernel debugging enabled it can happen that _find_nvme_loop_dev() returns before the NVMe block device has appeared in sysfs. This patch avoids that the NVMe tests fail as follows:

(quoted diff) +2 -0
+cat: /sys/block/nvme1n1/uuid: No such file or directory
+cat: /sys/block/nvme1n1/wwid: No such file or directory
Quoted 7 lines
Cc Logan Gunthorpe <[email protected]>
Cc Chaitanya Kulkarni <[email protected]>
Cc Johannes Thumshirn <[email protected]>
---
 tests/nvme/rc | 8 ++++++++
 1 file changed, 8 insertions(+)

Thanks, Bart, I made Johannes' suggested change and applied.