Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 34764
b: refs/heads/master
c: 5006a76
h: refs/heads/master
v: v3
  • Loading branch information
David Howells authored and Trond Myklebust committed Sep 23, 2006
1 parent 30e5ae0 commit 095b3a6
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 180 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8fa5c000d7f986ef9cdc6d95f9f7fcee20e0a7d6
refs/heads/master: 5006a76cca8f86c6975c16fcf67e83b8b0eee2b6
119 changes: 119 additions & 0 deletions trunk/fs/nfs/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,48 @@ static DEFINE_SPINLOCK(nfs_client_lock);
static LIST_HEAD(nfs_client_list);
static DECLARE_WAIT_QUEUE_HEAD(nfs_client_active_wq);

/*
* RPC cruft for NFS
*/
static struct rpc_version *nfs_version[5] = {
[2] = &nfs_version2,
#ifdef CONFIG_NFS_V3
[3] = &nfs_version3,
#endif
#ifdef CONFIG_NFS_V4
[4] = &nfs_version4,
#endif
};

struct rpc_program nfs_program = {
.name = "nfs",
.number = NFS_PROGRAM,
.nrvers = ARRAY_SIZE(nfs_version),
.version = nfs_version,
.stats = &nfs_rpcstat,
.pipe_dir_name = "/nfs",
};

struct rpc_stat nfs_rpcstat = {
.program = &nfs_program
};


#ifdef CONFIG_NFS_V3_ACL
static struct rpc_stat nfsacl_rpcstat = { &nfsacl_program };
static struct rpc_version * nfsacl_version[] = {
[3] = &nfsacl_version3,
};

struct rpc_program nfsacl_program = {
.name = "nfsacl",
.number = NFS_ACL_PROGRAM,
.nrvers = ARRAY_SIZE(nfsacl_version),
.version = nfsacl_version,
.stats = &nfsacl_rpcstat,
};
#endif /* CONFIG_NFS_V3_ACL */

/*
* Allocate a shared client record
*
Expand Down Expand Up @@ -310,3 +352,80 @@ void nfs_mark_client_ready(struct nfs_client *clp, int state)
clp->cl_cons_state = state;
wake_up_all(&nfs_client_active_wq);
}

/*
* Initialise the timeout values for a connection
*/
static void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
unsigned int timeo, unsigned int retrans)
{
to->to_initval = timeo * HZ / 10;
to->to_retries = retrans;
if (!to->to_retries)
to->to_retries = 2;

switch (proto) {
case IPPROTO_TCP:
if (!to->to_initval)
to->to_initval = 60 * HZ;
if (to->to_initval > NFS_MAX_TCP_TIMEOUT)
to->to_initval = NFS_MAX_TCP_TIMEOUT;
to->to_increment = to->to_initval;
to->to_maxval = to->to_initval + (to->to_increment * to->to_retries);
to->to_exponential = 0;
break;
case IPPROTO_UDP:
default:
if (!to->to_initval)
to->to_initval = 11 * HZ / 10;
if (to->to_initval > NFS_MAX_UDP_TIMEOUT)
to->to_initval = NFS_MAX_UDP_TIMEOUT;
to->to_maxval = NFS_MAX_UDP_TIMEOUT;
to->to_exponential = 1;
break;
}
}

/*
* Create an RPC client handle
*/
int nfs_create_rpc_client(struct nfs_client *clp, int proto,
unsigned int timeo,
unsigned int retrans,
rpc_authflavor_t flavor)
{
struct rpc_timeout timeparms;
struct rpc_xprt *xprt = NULL;
struct rpc_clnt *clnt = NULL;

if (!IS_ERR(clp->cl_rpcclient))
return 0;

nfs_init_timeout_values(&timeparms, proto, timeo, retrans);
clp->retrans_timeo = timeparms.to_initval;
clp->retrans_count = timeparms.to_retries;

/* create transport and client */
xprt = xprt_create_proto(proto, &clp->cl_addr, &timeparms);
if (IS_ERR(xprt)) {
dprintk("%s: cannot create RPC transport. Error = %ld\n",
__FUNCTION__, PTR_ERR(xprt));
return PTR_ERR(xprt);
}

/* Bind to a reserved port! */
xprt->resvport = 1;
/* Create the client RPC handle */
clnt = rpc_create_client(xprt, clp->cl_hostname, &nfs_program,
clp->rpc_ops->version, RPC_AUTH_UNIX);
if (IS_ERR(clnt)) {
dprintk("%s: cannot create RPC client. Error = %ld\n",
__FUNCTION__, PTR_ERR(clnt));
return PTR_ERR(clnt);
}

clnt->cl_intr = 1;
clnt->cl_softrtry = 1;
clp->cl_rpcclient = clnt;
return 0;
}
2 changes: 2 additions & 0 deletions trunk/fs/nfs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ extern void nfs_put_client(struct nfs_client *);
extern struct nfs_client *nfs_find_client(const struct sockaddr_in *, int);
extern struct nfs_client *nfs_get_client(const char *, const struct sockaddr_in *, int);
extern void nfs_mark_client_ready(struct nfs_client *, int);
extern int nfs_create_rpc_client(struct nfs_client *, int, unsigned int,
unsigned int, rpc_authflavor_t);

/* nfs4namespace.c */
#ifdef CONFIG_NFS_V4
Expand Down
6 changes: 3 additions & 3 deletions trunk/fs/nfs/nfs3proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
int status;

status = do_proc_get_root(server->client, fhandle, info);
if (status && server->client_sys != server->client)
status = do_proc_get_root(server->client_sys, fhandle, info);
if (status && server->nfs_client->cl_rpcclient != server->client)
status = do_proc_get_root(server->nfs_client->cl_rpcclient, fhandle, info);
return status;
}

Expand Down Expand Up @@ -785,7 +785,7 @@ nfs3_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,

dprintk("NFS call fsinfo\n");
nfs_fattr_init(info->fattr);
status = rpc_call_sync(server->client_sys, &msg, 0);
status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
dprintk("NFS reply fsinfo: %d\n", status);
return status;
}
Expand Down
4 changes: 2 additions & 2 deletions trunk/fs/nfs/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,

dprintk("%s: call getattr\n", __FUNCTION__);
nfs_fattr_init(fattr);
status = rpc_call_sync(server->client_sys, &msg, 0);
status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
dprintk("%s: reply getattr: %d\n", __FUNCTION__, status);
if (status)
return status;
dprintk("%s: call statfs\n", __FUNCTION__);
msg.rpc_proc = &nfs_procedures[NFSPROC_STATFS];
msg.rpc_resp = &fsinfo;
status = rpc_call_sync(server->client_sys, &msg, 0);
status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
dprintk("%s: reply statfs: %d\n", __FUNCTION__, status);
if (status)
return status;
Expand Down
Loading

0 comments on commit 095b3a6

Please sign in to comment.