From: trondmy@gmail.com
To: linux-nfs@vger.kernel.org
Subject: [PATCH v2 3/5] NFSv4/pNFS: Store the transport type in struct nfs4_pnfs_ds_addr
Date: Mon, 9 Nov 2020 16:10:27 -0500 [thread overview]
Message-ID: <20201109211029.540993-4-trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <20201109211029.540993-3-trond.myklebust@hammerspace.com>
From: Trond Myklebust <trond.myklebust@hammerspace.com>
We want to enable RDMA and UDP as valid transport methods if a
GETDEVICEINFO call specifies it. Do so by adding a parser for the
netid that translates it to an appropriate argument for the RPC
transport layer.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/pnfs.h | 1 +
fs/nfs/pnfs_nfs.c | 66 +++++++++++++++++++++++++++++++++++++----------
2 files changed, 53 insertions(+), 14 deletions(-)
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 2661c44c62db..20ee37b751e3 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -51,6 +51,7 @@ struct nfs4_pnfs_ds_addr {
size_t da_addrlen;
struct list_head da_node; /* nfs4_pnfs_dev_hlist dev_dslist */
char *da_remotestr; /* human readable addr+port */
+ int da_transport;
};
struct nfs4_pnfs_ds {
diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c
index 7027dac41cc7..d00750743100 100644
--- a/fs/nfs/pnfs_nfs.c
+++ b/fs/nfs/pnfs_nfs.c
@@ -854,13 +854,15 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv,
if (!IS_ERR(clp)) {
struct xprt_create xprt_args = {
- .ident = XPRT_TRANSPORT_TCP,
+ .ident = da->da_transport,
.net = clp->cl_net,
.dstaddr = (struct sockaddr *)&da->da_addr,
.addrlen = da->da_addrlen,
.servername = clp->cl_hostname,
};
+ if (da->da_transport != clp->cl_proto)
+ continue;
if (da->da_addr.ss_family != clp->cl_addr.ss_family)
continue;
/* Add this address as an alias */
@@ -870,7 +872,7 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv,
}
clp = get_v3_ds_connect(mds_srv,
(struct sockaddr *)&da->da_addr,
- da->da_addrlen, IPPROTO_TCP,
+ da->da_addrlen, da->da_transport,
timeo, retrans);
if (IS_ERR(clp))
continue;
@@ -908,7 +910,7 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv,
if (!IS_ERR(clp) && clp->cl_mvops->session_trunk) {
struct xprt_create xprt_args = {
- .ident = XPRT_TRANSPORT_TCP,
+ .ident = da->da_transport,
.net = clp->cl_net,
.dstaddr = (struct sockaddr *)&da->da_addr,
.addrlen = da->da_addrlen,
@@ -923,6 +925,8 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv,
.data = &xprtdata,
};
+ if (da->da_transport != clp->cl_proto)
+ continue;
if (da->da_addr.ss_family != clp->cl_addr.ss_family)
continue;
/**
@@ -937,8 +941,9 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv,
} else {
clp = nfs4_set_ds_client(mds_srv,
(struct sockaddr *)&da->da_addr,
- da->da_addrlen, IPPROTO_TCP,
- timeo, retrans, minor_version);
+ da->da_addrlen,
+ da->da_transport, timeo,
+ retrans, minor_version);
if (IS_ERR(clp))
continue;
@@ -1017,6 +1022,41 @@ int nfs4_pnfs_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds,
}
EXPORT_SYMBOL_GPL(nfs4_pnfs_ds_connect);
+struct xprt_lookup_transport {
+ const char *name;
+ sa_family_t protofamily;
+ int type;
+};
+
+static const struct xprt_lookup_transport xl_xprt[] = {
+ { "tcp", AF_INET, XPRT_TRANSPORT_TCP },
+ { "tcp6", AF_INET6, XPRT_TRANSPORT_TCP },
+ { "rdma", AF_INET, XPRT_TRANSPORT_RDMA },
+ { "rdma6", AF_INET6, XPRT_TRANSPORT_RDMA },
+ { "udp", AF_INET, XPRT_TRANSPORT_UDP },
+ { "udp6", AF_INET6, XPRT_TRANSPORT_UDP },
+ { NULL, 0, -1 },
+};
+
+static int
+nfs4_decode_transport(const char *str, size_t len, sa_family_t protofamily)
+{
+ const struct xprt_lookup_transport *p;
+
+ for (p = xl_xprt; p->name; p++) {
+ if (p->protofamily != protofamily)
+ continue;
+ if (strlen(p->name) != len)
+ continue;
+ if (memcmp(p->name, str, len) != 0)
+ continue;
+ if (xprt_load_transport(p->name) != 0)
+ continue;
+ return p->type;
+ }
+ return -1;
+}
+
/*
* Currently only supports ipv4, ipv6 and one multi-path address.
*/
@@ -1029,8 +1069,8 @@ nfs4_decode_mp_ds_addr(struct net *net, struct xdr_stream *xdr, gfp_t gfp_flags)
int nlen, rlen;
int tmp[2];
__be32 *p;
- char *netid, *match_netid;
- size_t len, match_netid_len;
+ char *netid;
+ size_t len;
char *startsep = "";
char *endsep = "";
@@ -1114,15 +1154,11 @@ nfs4_decode_mp_ds_addr(struct net *net, struct xdr_stream *xdr, gfp_t gfp_flags)
case AF_INET:
((struct sockaddr_in *)&da->da_addr)->sin_port = port;
da->da_addrlen = sizeof(struct sockaddr_in);
- match_netid = "tcp";
- match_netid_len = 3;
break;
case AF_INET6:
((struct sockaddr_in6 *)&da->da_addr)->sin6_port = port;
da->da_addrlen = sizeof(struct sockaddr_in6);
- match_netid = "tcp6";
- match_netid_len = 4;
startsep = "[";
endsep = "]";
break;
@@ -1133,9 +1169,11 @@ nfs4_decode_mp_ds_addr(struct net *net, struct xdr_stream *xdr, gfp_t gfp_flags)
goto out_free_da;
}
- if (nlen != match_netid_len || strncmp(netid, match_netid, nlen)) {
- dprintk("%s: ERROR: r_netid \"%s\" != \"%s\"\n",
- __func__, netid, match_netid);
+ da->da_transport = nfs4_decode_transport(netid, nlen,
+ da->da_addr.ss_family);
+ if (da->da_transport == -1) {
+ dprintk("%s: ERROR: unknown r_netid \"%*s\"\n",
+ __func__, nlen, netid);
goto out_free_da;
}
--
2.28.0
next prev parent reply other threads:[~2020-11-09 21:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-09 21:10 [PATCH v2 0/5] Add RDMA support to the pNFS file+flexfiles data channels trondmy
2020-11-09 21:10 ` [PATCH v2 1/5] SUNRPC: xprt_load_transport() needs to support the netid "rdma6" trondmy
2020-11-09 21:10 ` [PATCH v2 2/5] NFSv4/pNFS: Use connections to a DS that are all of the same protocol family trondmy
2020-11-09 21:10 ` trondmy [this message]
2020-11-09 21:10 ` [PATCH v2 4/5] pNFS/flexfiles: Fix up layoutstats reporting for non-TCP transports trondmy
2020-11-09 21:10 ` [PATCH v2 5/5] pNFS: Clean up open coded kmemdup_nul() trondmy
2020-11-09 21:50 ` [PATCH v2 1/5] SUNRPC: xprt_load_transport() needs to support the netid "rdma6" Chuck Lever
2020-11-09 22:06 ` Trond Myklebust
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201109211029.540993-4-trond.myklebust@hammerspace.com \
--to=trondmy@gmail.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).