diff mbox series

[blktests] common/multipath-over-rdma: update is_rdma_device

Message ID 20210120231839.10267-1-yi.zhang@redhat.com (mailing list archive)
State New, archived
Headers show
Series [blktests] common/multipath-over-rdma: update is_rdma_device | expand

Commit Message

Yi Zhang Jan. 20, 2021, 11:18 p.m. UTC
Below patch make the siw/rxe device virtual in the device tree, update
is_rdma_device to match it.
a9d2e9ae953f RDMA/siw,rxe: Make emulated devices virtual in the device tree

Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
---
 common/multipath-over-rdma | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

Comments

Bart Van Assche Jan. 21, 2021, 4:01 a.m. UTC | #1
On 1/20/21 3:18 PM, Yi Zhang wrote:
> Below patch make the siw/rxe device virtual in the device tree, update
> is_rdma_device to match it.
> a9d2e9ae953f RDMA/siw,rxe: Make emulated devices virtual in the device tree
> 
> Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
> ---
>  common/multipath-over-rdma | 23 +++++++++++++++--------
>  1 file changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/common/multipath-over-rdma b/common/multipath-over-rdma
> index 355b169..e4269f6 100644
> --- a/common/multipath-over-rdma
> +++ b/common/multipath-over-rdma
> @@ -79,17 +79,24 @@ is_number() {
>  # Check whether a device is an RDMA device. An example argument:
>  # /sys/devices/pci0000:00/0000:00:03.0/0000:04:00.0
>  is_rdma_device() {
> -	local d i inode1 inode2
> +	local d i f inode1 inode2
>  
> -	inode1=$(stat -c %i "$1")
> -	# echo "inode1 = $inode1"
> +	f=$1
> +	inode1=$(stat -c %i "$f")
>  	for i in /sys/class/infiniband/*; do
>  		d=/sys/class/infiniband/"$(readlink "$i")"
> -		d=$(dirname "$(dirname "$d")")
> -		inode2=$(stat -c %i "$d")
> -		# echo "inode2 = $inode2"
> -		if [ "$inode1" = "$inode2" ]; then
> -			return
> +		if [[ "$d" == *"virtual"* ]]; then
> +			if [[ -e "$d/parent" && "${f%%/*}" == "$(<"$d"/parent)" ]] || \
> +				   [[ "${f%%/*}_siw" == "$(basename "$d")" ]]; then
> +				return
> +			fi
> +		else
> +			d1=$(dirname "$(dirname "$d")")
> +			inode2=$(stat -c %i "$d1")
> +			# echo "inode2 = $inode2"
> +			if [ "$inode1" = "$inode2" ]; then
> +				return
> +			fi
>  		fi
>  	done
>  	false

Jason Gunthorpe, the RDMA maintainer, asked some time ago to use rdma
link instead of inspecting /sys/class/infiniband to query rdma_rxe / siw
instance properties. Please take a look at the blktests patch that I
just posted and on which I cc-ed you.

Thanks,

Bart.
diff mbox series

Patch

diff --git a/common/multipath-over-rdma b/common/multipath-over-rdma
index 355b169..e4269f6 100644
--- a/common/multipath-over-rdma
+++ b/common/multipath-over-rdma
@@ -79,17 +79,24 @@  is_number() {
 # Check whether a device is an RDMA device. An example argument:
 # /sys/devices/pci0000:00/0000:00:03.0/0000:04:00.0
 is_rdma_device() {
-	local d i inode1 inode2
+	local d i f inode1 inode2
 
-	inode1=$(stat -c %i "$1")
-	# echo "inode1 = $inode1"
+	f=$1
+	inode1=$(stat -c %i "$f")
 	for i in /sys/class/infiniband/*; do
 		d=/sys/class/infiniband/"$(readlink "$i")"
-		d=$(dirname "$(dirname "$d")")
-		inode2=$(stat -c %i "$d")
-		# echo "inode2 = $inode2"
-		if [ "$inode1" = "$inode2" ]; then
-			return
+		if [[ "$d" == *"virtual"* ]]; then
+			if [[ -e "$d/parent" && "${f%%/*}" == "$(<"$d"/parent)" ]] || \
+				   [[ "${f%%/*}_siw" == "$(basename "$d")" ]]; then
+				return
+			fi
+		else
+			d1=$(dirname "$(dirname "$d")")
+			inode2=$(stat -c %i "$d1")
+			# echo "inode2 = $inode2"
+			if [ "$inode1" = "$inode2" ]; then
+				return
+			fi
 		fi
 	done
 	false