Skip to content

Commit f7d1ddb

Browse files
kinglongmeeJ. Bruce Fields
authored andcommitted
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>
1 parent c3821b3 commit f7d1ddb

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

fs/nfsd/nfs4callback.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,14 @@ int set_callback_cred(void)
753753
return 0;
754754
}
755755

756+
void cleanup_callback_cred(void)
757+
{
758+
if (callback_cred) {
759+
put_rpccred(callback_cred);
760+
callback_cred = NULL;
761+
}
762+
}
763+
756764
static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc_clnt *client, struct nfsd4_session *ses)
757765
{
758766
if (clp->cl_minorversion == 0) {

fs/nfsd/nfs4state.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7012,23 +7012,24 @@ nfs4_state_start(void)
70127012

70137013
ret = set_callback_cred();
70147014
if (ret)
7015-
return -ENOMEM;
7015+
return ret;
7016+
70167017
laundry_wq = alloc_workqueue("%s", WQ_UNBOUND, 0, "nfsd4");
70177018
if (laundry_wq == NULL) {
70187019
ret = -ENOMEM;
7019-
goto out_recovery;
7020+
goto out_cleanup_cred;
70207021
}
70217022
ret = nfsd4_create_callback_queue();
70227023
if (ret)
70237024
goto out_free_laundry;
70247025

70257026
set_max_delegations();
7026-
70277027
return 0;
70287028

70297029
out_free_laundry:
70307030
destroy_workqueue(laundry_wq);
7031-
out_recovery:
7031+
out_cleanup_cred:
7032+
cleanup_callback_cred();
70327033
return ret;
70337034
}
70347035

@@ -7086,6 +7087,7 @@ nfs4_state_shutdown(void)
70867087
{
70877088
destroy_workqueue(laundry_wq);
70887089
nfsd4_destroy_callback_queue();
7090+
cleanup_callback_cred();
70897091
}
70907092

70917093
static void

fs/nfsd/state.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ extern struct nfs4_client_reclaim *nfsd4_find_reclaim_client(const char *recdir,
615615
extern __be32 nfs4_check_open_reclaim(clientid_t *clid,
616616
struct nfsd4_compound_state *cstate, struct nfsd_net *nn);
617617
extern int set_callback_cred(void);
618+
extern void cleanup_callback_cred(void);
618619
extern void nfsd4_probe_callback(struct nfs4_client *clp);
619620
extern void nfsd4_probe_callback_sync(struct nfs4_client *clp);
620621
extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *);

0 commit comments

Comments
 (0)