Commit 44950b67 authored by Trond Myklebust's avatar Trond Myklebust

NFSv4.1: Ensure that we initialise the session when following a referral

Put the code that is common to both the referral and ordinary mount cases
into a common helper routine.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent b76ce561
...@@ -1286,6 +1286,55 @@ static void nfs4_session_set_rwsize(struct nfs_server *server) ...@@ -1286,6 +1286,55 @@ static void nfs4_session_set_rwsize(struct nfs_server *server)
#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4_1 */
} }
static int nfs4_server_common_setup(struct nfs_server *server,
struct nfs_fh *mntfh)
{
struct nfs_fattr *fattr;
int error;
BUG_ON(!server->nfs_client);
BUG_ON(!server->nfs_client->rpc_ops);
BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops);
fattr = nfs_alloc_fattr();
if (fattr == NULL)
return -ENOMEM;
/* We must ensure the session is initialised first */
error = nfs4_init_session(server);
if (error < 0)
goto out;
/* Probe the root fh to retrieve its FSID and filehandle */
error = nfs4_get_rootfh(server, mntfh);
if (error < 0)
goto out;
dprintk("Server FSID: %llx:%llx\n",
(unsigned long long) server->fsid.major,
(unsigned long long) server->fsid.minor);
dprintk("Mount FH: %d\n", mntfh->size);
nfs4_session_set_rwsize(server);
error = nfs_probe_fsinfo(server, mntfh, fattr);
if (error < 0)
goto out;
if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
server->namelen = NFS4_MAXNAMLEN;
spin_lock(&nfs_client_lock);
list_add_tail(&server->client_link, &server->nfs_client->cl_superblocks);
list_add_tail(&server->master_link, &nfs_volume_list);
spin_unlock(&nfs_client_lock);
server->mount_time = jiffies;
out:
nfs_free_fattr(fattr);
return error;
}
/* /*
* Create a version 4 volume record * Create a version 4 volume record
*/ */
...@@ -1346,7 +1395,6 @@ static int nfs4_init_server(struct nfs_server *server, ...@@ -1346,7 +1395,6 @@ static int nfs4_init_server(struct nfs_server *server,
struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
struct nfs_fh *mntfh) struct nfs_fh *mntfh)
{ {
struct nfs_fattr *fattr;
struct nfs_server *server; struct nfs_server *server;
int error; int error;
...@@ -1356,55 +1404,19 @@ struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, ...@@ -1356,55 +1404,19 @@ struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
if (!server) if (!server)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
error = -ENOMEM;
fattr = nfs_alloc_fattr();
if (fattr == NULL)
goto error;
/* set up the general RPC client */ /* set up the general RPC client */
error = nfs4_init_server(server, data); error = nfs4_init_server(server, data);
if (error < 0) if (error < 0)
goto error; goto error;
BUG_ON(!server->nfs_client); error = nfs4_server_common_setup(server, mntfh);
BUG_ON(!server->nfs_client->rpc_ops);
BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops);
error = nfs4_init_session(server);
if (error < 0)
goto error;
/* Probe the root fh to retrieve its FSID */
error = nfs4_get_rootfh(server, mntfh);
if (error < 0) if (error < 0)
goto error; goto error;
dprintk("Server FSID: %llx:%llx\n",
(unsigned long long) server->fsid.major,
(unsigned long long) server->fsid.minor);
dprintk("Mount FH: %d\n", mntfh->size);
nfs4_session_set_rwsize(server);
error = nfs_probe_fsinfo(server, mntfh, fattr);
if (error < 0)
goto error;
if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
server->namelen = NFS4_MAXNAMLEN;
spin_lock(&nfs_client_lock);
list_add_tail(&server->client_link, &server->nfs_client->cl_superblocks);
list_add_tail(&server->master_link, &nfs_volume_list);
spin_unlock(&nfs_client_lock);
server->mount_time = jiffies;
dprintk("<-- nfs4_create_server() = %p\n", server); dprintk("<-- nfs4_create_server() = %p\n", server);
nfs_free_fattr(fattr);
return server; return server;
error: error:
nfs_free_fattr(fattr);
nfs_free_server(server); nfs_free_server(server);
dprintk("<-- nfs4_create_server() = error %d\n", error); dprintk("<-- nfs4_create_server() = error %d\n", error);
return ERR_PTR(error); return ERR_PTR(error);
...@@ -1418,7 +1430,6 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, ...@@ -1418,7 +1430,6 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
{ {
struct nfs_client *parent_client; struct nfs_client *parent_client;
struct nfs_server *server, *parent_server; struct nfs_server *server, *parent_server;
struct nfs_fattr *fattr;
int error; int error;
dprintk("--> nfs4_create_referral_server()\n"); dprintk("--> nfs4_create_referral_server()\n");
...@@ -1427,11 +1438,6 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, ...@@ -1427,11 +1438,6 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
if (!server) if (!server)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
error = -ENOMEM;
fattr = nfs_alloc_fattr();
if (fattr == NULL)
goto error;
parent_server = NFS_SB(data->sb); parent_server = NFS_SB(data->sb);
parent_client = parent_server->nfs_client; parent_client = parent_server->nfs_client;
...@@ -1456,40 +1462,14 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, ...@@ -1456,40 +1462,14 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
if (error < 0) if (error < 0)
goto error; goto error;
BUG_ON(!server->nfs_client); error = nfs4_server_common_setup(server, mntfh);
BUG_ON(!server->nfs_client->rpc_ops);
BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops);
/* Probe the root fh to retrieve its FSID and filehandle */
error = nfs4_get_rootfh(server, mntfh);
if (error < 0)
goto error;
/* probe the filesystem info for this server filesystem */
error = nfs_probe_fsinfo(server, mntfh, fattr);
if (error < 0) if (error < 0)
goto error; goto error;
if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
server->namelen = NFS4_MAXNAMLEN;
dprintk("Referral FSID: %llx:%llx\n",
(unsigned long long) server->fsid.major,
(unsigned long long) server->fsid.minor);
spin_lock(&nfs_client_lock);
list_add_tail(&server->client_link, &server->nfs_client->cl_superblocks);
list_add_tail(&server->master_link, &nfs_volume_list);
spin_unlock(&nfs_client_lock);
server->mount_time = jiffies;
nfs_free_fattr(fattr);
dprintk("<-- nfs_create_referral_server() = %p\n", server); dprintk("<-- nfs_create_referral_server() = %p\n", server);
return server; return server;
error: error:
nfs_free_fattr(fattr);
nfs_free_server(server); nfs_free_server(server);
dprintk("<-- nfs4_create_referral_server() = error %d\n", error); dprintk("<-- nfs4_create_referral_server() = error %d\n", error);
return ERR_PTR(error); return ERR_PTR(error);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment