Skip to content

Commit 4ca9f31

Browse files
olgakorn1amschuma-ntap
authored andcommitted
NFSv4.1 test and add 4.1 trunking transport
For each location returned in FS_LOCATION query, establish a transport to the server, send EXCHANGE_ID and test for trunking, if successful, add the transport to the exiting client. Signed-off-by: Olga Kornievskaia <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent b8a0961 commit 4ca9f31

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

fs/nfs/nfs4proc.c

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3935,6 +3935,56 @@ int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle)
39353935
return err;
39363936
}
39373937

3938+
static void test_fs_location_for_trunking(struct nfs4_fs_location *location,
3939+
struct nfs_client *clp,
3940+
struct nfs_server *server)
3941+
{
3942+
int i;
3943+
3944+
for (i = 0; i < location->nservers; i++) {
3945+
struct nfs4_string *srv_loc = &location->servers[i];
3946+
struct sockaddr addr;
3947+
size_t addrlen;
3948+
struct xprt_create xprt_args = {
3949+
.ident = 0,
3950+
.net = clp->cl_net,
3951+
};
3952+
struct nfs4_add_xprt_data xprtdata = {
3953+
.clp = clp,
3954+
};
3955+
struct rpc_add_xprt_test rpcdata = {
3956+
.add_xprt_test = clp->cl_mvops->session_trunk,
3957+
.data = &xprtdata,
3958+
};
3959+
char *servername = NULL;
3960+
3961+
if (!srv_loc->len)
3962+
continue;
3963+
3964+
addrlen = nfs_parse_server_name(srv_loc->data, srv_loc->len,
3965+
&addr, sizeof(addr),
3966+
clp->cl_net, server->port);
3967+
if (!addrlen)
3968+
return;
3969+
xprt_args.dstaddr = &addr;
3970+
xprt_args.addrlen = addrlen;
3971+
servername = kmalloc(srv_loc->len + 1, GFP_KERNEL);
3972+
if (!servername)
3973+
return;
3974+
memcpy(servername, srv_loc->data, srv_loc->len);
3975+
servername[srv_loc->len] = '\0';
3976+
xprt_args.servername = servername;
3977+
3978+
xprtdata.cred = nfs4_get_clid_cred(clp);
3979+
rpc_clnt_add_xprt(clp->cl_rpcclient, &xprt_args,
3980+
rpc_clnt_setup_test_and_add_xprt,
3981+
&rpcdata);
3982+
if (xprtdata.cred)
3983+
put_cred(xprtdata.cred);
3984+
kfree(servername);
3985+
}
3986+
}
3987+
39383988
static int _nfs4_discover_trunking(struct nfs_server *server,
39393989
struct nfs_fh *fhandle)
39403990
{
@@ -3944,7 +3994,7 @@ static int _nfs4_discover_trunking(struct nfs_server *server,
39443994
struct nfs_client *clp = server->nfs_client;
39453995
const struct nfs4_state_maintenance_ops *ops =
39463996
clp->cl_mvops->state_renewal_ops;
3947-
int status = -ENOMEM;
3997+
int status = -ENOMEM, i;
39483998

39493999
cred = ops->get_state_renewal_cred(clp);
39504000
if (cred == NULL) {
@@ -3962,6 +4012,10 @@ static int _nfs4_discover_trunking(struct nfs_server *server,
39624012
cred);
39634013
if (status)
39644014
goto out;
4015+
4016+
for (i = 0; i < locations->nlocations; i++)
4017+
test_fs_location_for_trunking(&locations->locations[i], clp,
4018+
server);
39654019
out:
39664020
if (page)
39674021
__free_page(page);

0 commit comments

Comments
 (0)