diff mbox series

[v2,4/5] pNFS/flexfiles: Fix up layoutstats reporting for non-TCP transports

Message ID 20201109211029.540993-5-trond.myklebust@hammerspace.com (mailing list archive)
State New
Headers show
Series Add RDMA support to the pNFS file+flexfiles data channels | expand

Commit Message

Trond Myklebust Nov. 9, 2020, 9:10 p.m. UTC
From: Trond Myklebust <trond.myklebust@hammerspace.com>

Ensure that we report the correct netid when using UDP or RDMA
transports to the DSes.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/flexfilelayout/flexfilelayout.c | 34 ++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index a163533446fa..c760238ba649 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -2279,18 +2279,41 @@  ff_layout_encode_netaddr(struct xdr_stream *xdr, struct nfs4_pnfs_ds_addr *da)
 		if (ff_layout_ntop4(sap, addrbuf, sizeof(addrbuf)) == 0)
 			return;
 		port = ntohs(((struct sockaddr_in *)sap)->sin_port);
-		netid = "tcp";
-		netid_len = 3;
+		switch (da->da_transport) {
+		case XPRT_TRANSPORT_TCP:
+			netid = "tcp";
+			break;
+		case XPRT_TRANSPORT_RDMA:
+			netid = "rdma";
+			break;
+		case XPRT_TRANSPORT_UDP:
+			netid = "udp";
+			break;
+		default:
+			WARN_ON_ONCE(1);
+			return;
+		}
 		break;
 	case AF_INET6:
 		if (ff_layout_ntop6_noscopeid(sap, addrbuf, sizeof(addrbuf)) == 0)
 			return;
 		port = ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
-		netid = "tcp6";
-		netid_len = 4;
+		switch (da->da_transport) {
+		case XPRT_TRANSPORT_TCP:
+			netid = "tcp6";
+			break;
+		case XPRT_TRANSPORT_RDMA:
+			netid = "rdma6";
+			break;
+		case XPRT_TRANSPORT_UDP:
+			netid = "udp6";
+			break;
+		default:
+			WARN_ON_ONCE(1);
+			return;
+		}
 		break;
 	default:
-		/* we only support tcp and tcp6 */
 		WARN_ON_ONCE(1);
 		return;
 	}
@@ -2298,6 +2321,7 @@  ff_layout_encode_netaddr(struct xdr_stream *xdr, struct nfs4_pnfs_ds_addr *da)
 	snprintf(portbuf, sizeof(portbuf), ".%u.%u", port >> 8, port & 0xff);
 	len = strlcat(addrbuf, portbuf, sizeof(addrbuf));
 
+	netid_len = strlen(netid);
 	p = xdr_reserve_space(xdr, 4 + netid_len);
 	xdr_encode_opaque(p, netid, netid_len);