aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/client.c
diff options
context:
space:
mode:
authorBryan Schumaker <bjschuma@netapp.com>2012-06-20 15:53:46 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-06-29 11:46:46 -0400
commit6663ee7f8187708143255c057bc132bbc84c1894 (patch)
tree17e47c1be9da2b3e67d74155676fdba92f435efe /fs/nfs/client.c
parentcdb7ecedec766861e7c4cc35a203518f92023bff (diff)
NFS: Create an alloc_client rpc_op
This gives NFS v4 a way to set up callbacks and sessions without v2 or v3 having to do them as well. Signed-off-by: Bryan Schumaker <bjschuma@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/client.c')
-rw-r--r--fs/nfs/client.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 82cb8a386a8f..254719c4a575 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -147,7 +147,7 @@ struct nfs_client_initdata {
147 * Since these are allocated/deallocated very rarely, we don't 147 * Since these are allocated/deallocated very rarely, we don't
148 * bother putting them in a slab cache... 148 * bother putting them in a slab cache...
149 */ 149 */
150static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init) 150struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
151{ 151{
152 struct nfs_client *clp; 152 struct nfs_client *clp;
153 struct rpc_cred *cred; 153 struct rpc_cred *cred;
@@ -177,18 +177,6 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
177 clp->cl_proto = cl_init->proto; 177 clp->cl_proto = cl_init->proto;
178 clp->cl_net = get_net(cl_init->net); 178 clp->cl_net = get_net(cl_init->net);
179 179
180#ifdef CONFIG_NFS_V4
181 err = nfs_get_cb_ident_idr(clp, cl_init->minorversion);
182 if (err)
183 goto error_cleanup;
184
185 spin_lock_init(&clp->cl_lock);
186 INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state);
187 rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client");
188 clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
189 clp->cl_minorversion = cl_init->minorversion;
190 clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion];
191#endif
192 cred = rpc_lookup_machine_cred("*"); 180 cred = rpc_lookup_machine_cred("*");
193 if (!IS_ERR(cred)) 181 if (!IS_ERR(cred))
194 clp->cl_machine_cred = cred; 182 clp->cl_machine_cred = cred;
@@ -218,6 +206,30 @@ static void nfs4_shutdown_session(struct nfs_client *clp)
218} 206}
219#endif /* CONFIG_NFS_V4_1 */ 207#endif /* CONFIG_NFS_V4_1 */
220 208
209struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
210{
211 int err;
212 struct nfs_client *clp = nfs_alloc_client(cl_init);
213 if (IS_ERR(clp))
214 return clp;
215
216 err = nfs_get_cb_ident_idr(clp, cl_init->minorversion);
217 if (err)
218 goto error;
219
220 spin_lock_init(&clp->cl_lock);
221 INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state);
222 rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client");
223 clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
224 clp->cl_minorversion = cl_init->minorversion;
225 clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion];
226 return clp;
227
228error:
229 kfree(clp);
230 return ERR_PTR(err);
231}
232
221/* 233/*
222 * Destroy the NFS4 callback service 234 * Destroy the NFS4 callback service
223 */ 235 */
@@ -588,7 +600,7 @@ nfs_get_client(const struct nfs_client_initdata *cl_init,
588 600
589 spin_unlock(&nn->nfs_client_lock); 601 spin_unlock(&nn->nfs_client_lock);
590 602
591 new = nfs_alloc_client(cl_init); 603 new = cl_init->rpc_ops->alloc_client(cl_init);
592 } while (!IS_ERR(new)); 604 } while (!IS_ERR(new));
593 605
594 dprintk("<-- nfs_get_client() Failed to find %s (%ld)\n", 606 dprintk("<-- nfs_get_client() Failed to find %s (%ld)\n",