Commit 6663ee7f8187708143255c057bc132bbc84c1894
Committed by
Trond Myklebust
1 parent
cdb7ecedec
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 7 changed files with 34 additions and 14 deletions Side-by-side Diff
fs/nfs/client.c
... | ... | @@ -147,7 +147,7 @@ |
147 | 147 | * Since these are allocated/deallocated very rarely, we don't |
148 | 148 | * bother putting them in a slab cache... |
149 | 149 | */ |
150 | -static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init) | |
150 | +struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init) | |
151 | 151 | { |
152 | 152 | struct nfs_client *clp; |
153 | 153 | struct rpc_cred *cred; |
... | ... | @@ -177,18 +177,6 @@ |
177 | 177 | clp->cl_proto = cl_init->proto; |
178 | 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 | 180 | cred = rpc_lookup_machine_cred("*"); |
193 | 181 | if (!IS_ERR(cred)) |
194 | 182 | clp->cl_machine_cred = cred; |
... | ... | @@ -218,6 +206,30 @@ |
218 | 206 | } |
219 | 207 | #endif /* CONFIG_NFS_V4_1 */ |
220 | 208 | |
209 | +struct 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 | + | |
228 | +error: | |
229 | + kfree(clp); | |
230 | + return ERR_PTR(err); | |
231 | +} | |
232 | + | |
221 | 233 | /* |
222 | 234 | * Destroy the NFS4 callback service |
223 | 235 | */ |
... | ... | @@ -588,7 +600,7 @@ |
588 | 600 | |
589 | 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 | 604 | } while (!IS_ERR(new)); |
593 | 605 | |
594 | 606 | dprintk("<-- nfs_get_client() Failed to find %s (%ld)\n", |
fs/nfs/internal.h
... | ... | @@ -148,6 +148,7 @@ |
148 | 148 | /* client.c */ |
149 | 149 | extern const struct rpc_program nfs_program; |
150 | 150 | extern void nfs_clients_init(struct net *net); |
151 | +extern struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *); | |
151 | 152 | |
152 | 153 | extern void nfs_cleanup_cb_ident_idr(struct net *); |
153 | 154 | extern void nfs_put_client(struct nfs_client *); |
fs/nfs/nfs3proc.c
... | ... | @@ -934,6 +934,7 @@ |
934 | 934 | .close_context = nfs_close_context, |
935 | 935 | .have_delegation = nfs3_have_delegation, |
936 | 936 | .return_delegation = nfs3_return_delegation, |
937 | + .alloc_client = nfs_alloc_client, | |
937 | 938 | .init_client = nfs_init_client, |
938 | 939 | .free_client = nfs_free_client, |
939 | 940 | }; |
fs/nfs/nfs4_fs.h
... | ... | @@ -303,6 +303,8 @@ |
303 | 303 | |
304 | 304 | void nfs4_free_client(struct nfs_client *); |
305 | 305 | |
306 | +struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *); | |
307 | + | |
306 | 308 | /* nfs4renewd.c */ |
307 | 309 | extern void nfs4_schedule_state_renewal(struct nfs_client *); |
308 | 310 | extern void nfs4_renewd_prepare_shutdown(struct nfs_server *); |
fs/nfs/nfs4proc.c
... | ... | @@ -6806,6 +6806,7 @@ |
6806 | 6806 | .open_context = nfs4_atomic_open, |
6807 | 6807 | .have_delegation = nfs4_have_delegation, |
6808 | 6808 | .return_delegation = nfs4_inode_return_delegation, |
6809 | + .alloc_client = nfs4_alloc_client, | |
6809 | 6810 | .init_client = nfs4_init_client, |
6810 | 6811 | .free_client = nfs4_free_client, |
6811 | 6812 | }; |
fs/nfs/proc.c
... | ... | @@ -790,6 +790,7 @@ |
790 | 790 | .close_context = nfs_close_context, |
791 | 791 | .have_delegation = nfs_have_delegation, |
792 | 792 | .return_delegation = nfs_return_delegation, |
793 | + .alloc_client = nfs_alloc_client, | |
793 | 794 | .init_client = nfs_init_client, |
794 | 795 | .free_client = nfs_free_client, |
795 | 796 | }; |
include/linux/nfs_xdr.h
... | ... | @@ -1353,6 +1353,7 @@ |
1353 | 1353 | struct nfs_access_entry; |
1354 | 1354 | struct nfs_client; |
1355 | 1355 | struct rpc_timeout; |
1356 | +struct nfs_client_initdata; | |
1356 | 1357 | |
1357 | 1358 | /* |
1358 | 1359 | * RPC procedure vector for NFSv2/NFSv3 demuxing |
... | ... | @@ -1424,6 +1425,7 @@ |
1424 | 1425 | struct iattr *iattr); |
1425 | 1426 | int (*have_delegation)(struct inode *, fmode_t); |
1426 | 1427 | int (*return_delegation)(struct inode *); |
1428 | + struct nfs_client *(*alloc_client) (const struct nfs_client_initdata *); | |
1427 | 1429 | struct nfs_client * |
1428 | 1430 | (*init_client) (struct nfs_client *, const struct rpc_timeout *, |
1429 | 1431 | const char *, rpc_authflavor_t); |