Commit 9bdaa86d authored by Benny Halevy's avatar Benny Halevy

nfs41: Refactor nfs4_{init,destroy}_callback for nfs4.0

Refactor-out code to bring the callback service up and down.
Signed-off-by: default avatarBenny Halevy <bhalevy@panasas.com>
parent f4a2e418
...@@ -47,6 +47,9 @@ ...@@ -47,6 +47,9 @@
#include "internal.h" #include "internal.h"
#include "fscache.h" #include "fscache.h"
static int nfs4_init_callback(struct nfs_client *);
static void nfs4_destroy_callback(struct nfs_client *);
#define NFSDBG_FACILITY NFSDBG_CLIENT #define NFSDBG_FACILITY NFSDBG_CLIENT
static DEFINE_SPINLOCK(nfs_client_lock); static DEFINE_SPINLOCK(nfs_client_lock);
...@@ -121,11 +124,8 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_ ...@@ -121,11 +124,8 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
clp->rpc_ops = cl_init->rpc_ops; clp->rpc_ops = cl_init->rpc_ops;
if (cl_init->rpc_ops->version == 4) { if (nfs4_init_callback(clp) < 0)
if (nfs_callback_up() < 0) goto error_2;
goto error_2;
__set_bit(NFS_CS_CALLBACK, &clp->cl_res_state);
}
atomic_set(&clp->cl_count, 1); atomic_set(&clp->cl_count, 1);
clp->cl_cons_state = NFS_CS_INITING; clp->cl_cons_state = NFS_CS_INITING;
...@@ -162,8 +162,7 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_ ...@@ -162,8 +162,7 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
return clp; return clp;
error_3: error_3:
if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state)) nfs4_destroy_callback(clp);
nfs_callback_down();
error_2: error_2:
kfree(clp); kfree(clp);
error_0: error_0:
...@@ -183,6 +182,17 @@ static void nfs4_shutdown_client(struct nfs_client *clp) ...@@ -183,6 +182,17 @@ static void nfs4_shutdown_client(struct nfs_client *clp)
#endif #endif
} }
/*
* Destroy the NFS4 callback service
*/
static void nfs4_destroy_callback(struct nfs_client *clp)
{
#ifdef CONFIG_NFS_V4
if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
nfs_callback_down();
#endif /* CONFIG_NFS_V4 */
}
/* /*
* Clears/puts all minor version specific parts from an nfs_client struct * Clears/puts all minor version specific parts from an nfs_client struct
* reverting it to minorversion 0. * reverting it to minorversion 0.
...@@ -215,8 +225,7 @@ static void nfs_free_client(struct nfs_client *clp) ...@@ -215,8 +225,7 @@ static void nfs_free_client(struct nfs_client *clp)
if (!IS_ERR(clp->cl_rpcclient)) if (!IS_ERR(clp->cl_rpcclient))
rpc_shutdown_client(clp->cl_rpcclient); rpc_shutdown_client(clp->cl_rpcclient);
if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state)) nfs4_destroy_callback(clp);
nfs_callback_down();
if (clp->cl_machine_cred != NULL) if (clp->cl_machine_cred != NULL)
put_rpccred(clp->cl_machine_cred); put_rpccred(clp->cl_machine_cred);
...@@ -1087,6 +1096,25 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data, ...@@ -1087,6 +1096,25 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data,
} }
#ifdef CONFIG_NFS_V4 #ifdef CONFIG_NFS_V4
/*
* Initialize the NFS4 callback service
*/
static int nfs4_init_callback(struct nfs_client *clp)
{
int error;
if (clp->rpc_ops->version == 4) {
error = nfs_callback_up();
if (error < 0) {
dprintk("%s: failed to start callback. Error = %d\n",
__func__, error);
return error;
}
__set_bit(NFS_CS_CALLBACK, &clp->cl_res_state);
}
return 0;
}
/* /*
* Initialize the minor version specific parts of an NFS4 client record * Initialize the minor version specific parts of an NFS4 client record
*/ */
......
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