Commit e82dc22d authored by Andy Adamson's avatar Andy Adamson Committed by Benny Halevy

nfs41: Allow NFSv4 and NFSv4.1 callback services to coexist

Tracks the nfs_callback_info for both versions, enabling the callback
service for v4 and v4.1 to run concurrently and be stopped independently
of each other.
Signed-off-by: default avatarRicardo Labiaga <ricardo.labiaga@netapp.com>
Signed-off-by: default avatarBenny Halevy <bhalevy@panasas.com>
parent 8f975242
...@@ -36,7 +36,7 @@ struct nfs_callback_data { ...@@ -36,7 +36,7 @@ struct nfs_callback_data {
struct task_struct *task; struct task_struct *task;
}; };
static struct nfs_callback_data nfs_callback_info; static struct nfs_callback_data nfs_callback_info[NFS4_MAX_MINOR_VERSION + 1];
static DEFINE_MUTEX(nfs_callback_mutex); static DEFINE_MUTEX(nfs_callback_mutex);
static struct svc_program nfs4_callback_program; static struct svc_program nfs4_callback_program;
...@@ -60,7 +60,7 @@ module_param_call(callback_tcpport, param_set_port, param_get_int, ...@@ -60,7 +60,7 @@ module_param_call(callback_tcpport, param_set_port, param_get_int,
&nfs_callback_set_tcpport, 0644); &nfs_callback_set_tcpport, 0644);
/* /*
* This is the callback kernel thread. * This is the NFSv4 callback kernel thread.
*/ */
static int static int
nfs4_callback_svc(void *vrqstp) nfs4_callback_svc(void *vrqstp)
...@@ -174,8 +174,6 @@ nfs41_callback_svc(void *vrqstp) ...@@ -174,8 +174,6 @@ nfs41_callback_svc(void *vrqstp)
finish_wait(&serv->sv_cb_waitq, &wq); finish_wait(&serv->sv_cb_waitq, &wq);
} }
unlock_kernel(); unlock_kernel();
nfs_callback_info.task = NULL;
svc_exit_thread(rqstp);
return 0; return 0;
} }
...@@ -251,13 +249,14 @@ int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt) ...@@ -251,13 +249,14 @@ int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt)
struct svc_serv *serv = NULL; struct svc_serv *serv = NULL;
struct svc_rqst *rqstp; struct svc_rqst *rqstp;
int (*callback_svc)(void *vrqstp); int (*callback_svc)(void *vrqstp);
struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
char svc_name[12]; char svc_name[12];
int ret = 0; int ret = 0;
int minorversion_setup; int minorversion_setup;
mutex_lock(&nfs_callback_mutex); mutex_lock(&nfs_callback_mutex);
if (nfs_callback_info.users++ || nfs_callback_info.task != NULL) { if (cb_info->users++ || cb_info->task != NULL) {
nfs_callback_bc_serv(minorversion, xprt, &nfs_callback_info); nfs_callback_bc_serv(minorversion, xprt, cb_info);
goto out; goto out;
} }
serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, NULL); serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, NULL);
...@@ -282,17 +281,14 @@ int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt) ...@@ -282,17 +281,14 @@ int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt)
svc_sock_update_bufs(serv); svc_sock_update_bufs(serv);
sprintf(svc_name, "nfsv4.%u-svc", minorversion); sprintf(svc_name, "nfsv4.%u-svc", minorversion);
nfs_callback_info.serv = serv; cb_info->serv = serv;
nfs_callback_info.rqst = rqstp; cb_info->rqst = rqstp;
nfs_callback_info.task = kthread_run(callback_svc, cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name);
nfs_callback_info.rqst, if (IS_ERR(cb_info->task)) {
svc_name); ret = PTR_ERR(cb_info->task);
if (IS_ERR(nfs_callback_info.task)) { svc_exit_thread(cb_info->rqst);
ret = PTR_ERR(nfs_callback_info.task); cb_info->rqst = NULL;
svc_exit_thread(nfs_callback_info.rqst); cb_info->task = NULL;
nfs_callback_info.serv = NULL;
nfs_callback_info.rqst = NULL;
nfs_callback_info.task = NULL;
goto out_err; goto out_err;
} }
out: out:
...@@ -309,23 +305,25 @@ int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt) ...@@ -309,23 +305,25 @@ int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt)
out_err: out_err:
dprintk("NFS: Couldn't create callback socket or server thread; " dprintk("NFS: Couldn't create callback socket or server thread; "
"err = %d\n", ret); "err = %d\n", ret);
nfs_callback_info.users--; cb_info->users--;
goto out; goto out;
} }
/* /*
* Kill the callback thread if it's no longer being used. * Kill the callback thread if it's no longer being used.
*/ */
void nfs_callback_down(void) void nfs_callback_down(int minorversion)
{ {
struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
mutex_lock(&nfs_callback_mutex); mutex_lock(&nfs_callback_mutex);
nfs_callback_info.users--; cb_info->users--;
if (nfs_callback_info.users == 0 && nfs_callback_info.task != NULL) { if (cb_info->users == 0 && cb_info->task != NULL) {
kthread_stop(nfs_callback_info.task); kthread_stop(cb_info->task);
svc_exit_thread(nfs_callback_info.rqst); svc_exit_thread(cb_info->rqst);
nfs_callback_info.serv = NULL; cb_info->serv = NULL;
nfs_callback_info.rqst = NULL; cb_info->rqst = NULL;
nfs_callback_info.task = NULL; cb_info->task = NULL;
} }
mutex_unlock(&nfs_callback_mutex); mutex_unlock(&nfs_callback_mutex);
} }
......
...@@ -64,11 +64,8 @@ extern __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy); ...@@ -64,11 +64,8 @@ extern __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy);
#ifdef CONFIG_NFS_V4 #ifdef CONFIG_NFS_V4
extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt); extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt);
extern void nfs_callback_down(void); extern void nfs_callback_down(int minorversion);
#else #endif /* CONFIG_NFS_V4 */
#define nfs_callback_up() (0)
#define nfs_callback_down() do {} while(0)
#endif
/* /*
* nfs41: Callbacks are expected to not cause substantial latency, * nfs41: Callbacks are expected to not cause substantial latency,
......
...@@ -181,7 +181,7 @@ static void nfs4_destroy_callback(struct nfs_client *clp) ...@@ -181,7 +181,7 @@ static void nfs4_destroy_callback(struct nfs_client *clp)
{ {
#ifdef CONFIG_NFS_V4 #ifdef CONFIG_NFS_V4
if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state)) if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
nfs_callback_down(); nfs_callback_down(clp->cl_minorversion);
#endif /* CONFIG_NFS_V4 */ #endif /* CONFIG_NFS_V4 */
} }
......
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