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>
This commit is contained in:
parent
cdb7ecedec
commit
6663ee7f81
@ -147,7 +147,7 @@ struct nfs_client_initdata {
|
|||||||
* Since these are allocated/deallocated very rarely, we don't
|
* Since these are allocated/deallocated very rarely, we don't
|
||||||
* bother putting them in a slab cache...
|
* bother putting them in a slab cache...
|
||||||
*/
|
*/
|
||||||
static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
|
struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
|
||||||
{
|
{
|
||||||
struct nfs_client *clp;
|
struct nfs_client *clp;
|
||||||
struct rpc_cred *cred;
|
struct rpc_cred *cred;
|
||||||
@ -177,18 +177,6 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
|
|||||||
clp->cl_proto = cl_init->proto;
|
clp->cl_proto = cl_init->proto;
|
||||||
clp->cl_net = get_net(cl_init->net);
|
clp->cl_net = get_net(cl_init->net);
|
||||||
|
|
||||||
#ifdef CONFIG_NFS_V4
|
|
||||||
err = nfs_get_cb_ident_idr(clp, cl_init->minorversion);
|
|
||||||
if (err)
|
|
||||||
goto error_cleanup;
|
|
||||||
|
|
||||||
spin_lock_init(&clp->cl_lock);
|
|
||||||
INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state);
|
|
||||||
rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client");
|
|
||||||
clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
|
|
||||||
clp->cl_minorversion = cl_init->minorversion;
|
|
||||||
clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion];
|
|
||||||
#endif
|
|
||||||
cred = rpc_lookup_machine_cred("*");
|
cred = rpc_lookup_machine_cred("*");
|
||||||
if (!IS_ERR(cred))
|
if (!IS_ERR(cred))
|
||||||
clp->cl_machine_cred = cred;
|
clp->cl_machine_cred = cred;
|
||||||
@ -218,6 +206,30 @@ static void nfs4_shutdown_session(struct nfs_client *clp)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NFS_V4_1 */
|
#endif /* CONFIG_NFS_V4_1 */
|
||||||
|
|
||||||
|
struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
struct nfs_client *clp = nfs_alloc_client(cl_init);
|
||||||
|
if (IS_ERR(clp))
|
||||||
|
return clp;
|
||||||
|
|
||||||
|
err = nfs_get_cb_ident_idr(clp, cl_init->minorversion);
|
||||||
|
if (err)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
spin_lock_init(&clp->cl_lock);
|
||||||
|
INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state);
|
||||||
|
rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client");
|
||||||
|
clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
|
||||||
|
clp->cl_minorversion = cl_init->minorversion;
|
||||||
|
clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion];
|
||||||
|
return clp;
|
||||||
|
|
||||||
|
error:
|
||||||
|
kfree(clp);
|
||||||
|
return ERR_PTR(err);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Destroy the NFS4 callback service
|
* Destroy the NFS4 callback service
|
||||||
*/
|
*/
|
||||||
@ -588,7 +600,7 @@ nfs_get_client(const struct nfs_client_initdata *cl_init,
|
|||||||
|
|
||||||
spin_unlock(&nn->nfs_client_lock);
|
spin_unlock(&nn->nfs_client_lock);
|
||||||
|
|
||||||
new = nfs_alloc_client(cl_init);
|
new = cl_init->rpc_ops->alloc_client(cl_init);
|
||||||
} while (!IS_ERR(new));
|
} while (!IS_ERR(new));
|
||||||
|
|
||||||
dprintk("<-- nfs_get_client() Failed to find %s (%ld)\n",
|
dprintk("<-- nfs_get_client() Failed to find %s (%ld)\n",
|
||||||
|
@ -148,6 +148,7 @@ extern void nfs_umount(const struct nfs_mount_request *info);
|
|||||||
/* client.c */
|
/* client.c */
|
||||||
extern const struct rpc_program nfs_program;
|
extern const struct rpc_program nfs_program;
|
||||||
extern void nfs_clients_init(struct net *net);
|
extern void nfs_clients_init(struct net *net);
|
||||||
|
extern struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *);
|
||||||
|
|
||||||
extern void nfs_cleanup_cb_ident_idr(struct net *);
|
extern void nfs_cleanup_cb_ident_idr(struct net *);
|
||||||
extern void nfs_put_client(struct nfs_client *);
|
extern void nfs_put_client(struct nfs_client *);
|
||||||
|
@ -934,6 +934,7 @@ const struct nfs_rpc_ops nfs_v3_clientops = {
|
|||||||
.close_context = nfs_close_context,
|
.close_context = nfs_close_context,
|
||||||
.have_delegation = nfs3_have_delegation,
|
.have_delegation = nfs3_have_delegation,
|
||||||
.return_delegation = nfs3_return_delegation,
|
.return_delegation = nfs3_return_delegation,
|
||||||
|
.alloc_client = nfs_alloc_client,
|
||||||
.init_client = nfs_init_client,
|
.init_client = nfs_init_client,
|
||||||
.free_client = nfs_free_client,
|
.free_client = nfs_free_client,
|
||||||
};
|
};
|
||||||
|
@ -303,6 +303,8 @@ extern const u32 nfs4_fs_locations_bitmap[2];
|
|||||||
|
|
||||||
void nfs4_free_client(struct nfs_client *);
|
void nfs4_free_client(struct nfs_client *);
|
||||||
|
|
||||||
|
struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *);
|
||||||
|
|
||||||
/* nfs4renewd.c */
|
/* nfs4renewd.c */
|
||||||
extern void nfs4_schedule_state_renewal(struct nfs_client *);
|
extern void nfs4_schedule_state_renewal(struct nfs_client *);
|
||||||
extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
|
extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
|
||||||
|
@ -6806,6 +6806,7 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
|
|||||||
.open_context = nfs4_atomic_open,
|
.open_context = nfs4_atomic_open,
|
||||||
.have_delegation = nfs4_have_delegation,
|
.have_delegation = nfs4_have_delegation,
|
||||||
.return_delegation = nfs4_inode_return_delegation,
|
.return_delegation = nfs4_inode_return_delegation,
|
||||||
|
.alloc_client = nfs4_alloc_client,
|
||||||
.init_client = nfs4_init_client,
|
.init_client = nfs4_init_client,
|
||||||
.free_client = nfs4_free_client,
|
.free_client = nfs4_free_client,
|
||||||
};
|
};
|
||||||
|
@ -790,6 +790,7 @@ const struct nfs_rpc_ops nfs_v2_clientops = {
|
|||||||
.close_context = nfs_close_context,
|
.close_context = nfs_close_context,
|
||||||
.have_delegation = nfs_have_delegation,
|
.have_delegation = nfs_have_delegation,
|
||||||
.return_delegation = nfs_return_delegation,
|
.return_delegation = nfs_return_delegation,
|
||||||
|
.alloc_client = nfs_alloc_client,
|
||||||
.init_client = nfs_init_client,
|
.init_client = nfs_init_client,
|
||||||
.free_client = nfs_free_client,
|
.free_client = nfs_free_client,
|
||||||
};
|
};
|
||||||
|
@ -1353,6 +1353,7 @@ struct nfs_renamedata {
|
|||||||
struct nfs_access_entry;
|
struct nfs_access_entry;
|
||||||
struct nfs_client;
|
struct nfs_client;
|
||||||
struct rpc_timeout;
|
struct rpc_timeout;
|
||||||
|
struct nfs_client_initdata;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RPC procedure vector for NFSv2/NFSv3 demuxing
|
* RPC procedure vector for NFSv2/NFSv3 demuxing
|
||||||
@ -1424,6 +1425,7 @@ struct nfs_rpc_ops {
|
|||||||
struct iattr *iattr);
|
struct iattr *iattr);
|
||||||
int (*have_delegation)(struct inode *, fmode_t);
|
int (*have_delegation)(struct inode *, fmode_t);
|
||||||
int (*return_delegation)(struct inode *);
|
int (*return_delegation)(struct inode *);
|
||||||
|
struct nfs_client *(*alloc_client) (const struct nfs_client_initdata *);
|
||||||
struct nfs_client *
|
struct nfs_client *
|
||||||
(*init_client) (struct nfs_client *, const struct rpc_timeout *,
|
(*init_client) (struct nfs_client *, const struct rpc_timeout *,
|
||||||
const char *, rpc_authflavor_t);
|
const char *, rpc_authflavor_t);
|
||||||
|
Loading…
Reference in New Issue
Block a user