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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>

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

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

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);
 
-- 
2.28.0




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux