nfsd/callback: Cleanup callback cred on shutdown

The rpccred gotten from rpc_lookup_machine_cred() should be put when
state is shutdown.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
Kinglong Mee 2017-02-05 09:57:07 +08:00 committed by J. Bruce Fields
parent c3821b3497
commit f7d1ddbe76
3 changed files with 15 additions and 4 deletions

View File

@ -753,6 +753,14 @@ int set_callback_cred(void)
return 0; return 0;
} }
void cleanup_callback_cred(void)
{
if (callback_cred) {
put_rpccred(callback_cred);
callback_cred = NULL;
}
}
static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc_clnt *client, struct nfsd4_session *ses) static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc_clnt *client, struct nfsd4_session *ses)
{ {
if (clp->cl_minorversion == 0) { if (clp->cl_minorversion == 0) {

View File

@ -7012,23 +7012,24 @@ nfs4_state_start(void)
ret = set_callback_cred(); ret = set_callback_cred();
if (ret) if (ret)
return -ENOMEM; return ret;
laundry_wq = alloc_workqueue("%s", WQ_UNBOUND, 0, "nfsd4"); laundry_wq = alloc_workqueue("%s", WQ_UNBOUND, 0, "nfsd4");
if (laundry_wq == NULL) { if (laundry_wq == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_recovery; goto out_cleanup_cred;
} }
ret = nfsd4_create_callback_queue(); ret = nfsd4_create_callback_queue();
if (ret) if (ret)
goto out_free_laundry; goto out_free_laundry;
set_max_delegations(); set_max_delegations();
return 0; return 0;
out_free_laundry: out_free_laundry:
destroy_workqueue(laundry_wq); destroy_workqueue(laundry_wq);
out_recovery: out_cleanup_cred:
cleanup_callback_cred();
return ret; return ret;
} }
@ -7086,6 +7087,7 @@ nfs4_state_shutdown(void)
{ {
destroy_workqueue(laundry_wq); destroy_workqueue(laundry_wq);
nfsd4_destroy_callback_queue(); nfsd4_destroy_callback_queue();
cleanup_callback_cred();
} }
static void static void

View File

@ -615,6 +615,7 @@ extern struct nfs4_client_reclaim *nfsd4_find_reclaim_client(const char *recdir,
extern __be32 nfs4_check_open_reclaim(clientid_t *clid, extern __be32 nfs4_check_open_reclaim(clientid_t *clid,
struct nfsd4_compound_state *cstate, struct nfsd_net *nn); struct nfsd4_compound_state *cstate, struct nfsd_net *nn);
extern int set_callback_cred(void); extern int set_callback_cred(void);
extern void cleanup_callback_cred(void);
extern void nfsd4_probe_callback(struct nfs4_client *clp); extern void nfsd4_probe_callback(struct nfs4_client *clp);
extern void nfsd4_probe_callback_sync(struct nfs4_client *clp); extern void nfsd4_probe_callback_sync(struct nfs4_client *clp);
extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *); extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *);