Skip to content

Commit c2c6f43

Browse files
kinglongmeegregkh
authored andcommitted
nfsd/callback: Cleanup callback cred on shutdown
[ Upstream commit f7d1ddbe7648af7460d23688c8c131342eb43b3a ] 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> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 429a4ac commit c2c6f43

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

fs/nfsd/nfs4callback.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,14 @@ int set_callback_cred(void)
696696
return 0;
697697
}
698698

699+
void cleanup_callback_cred(void)
700+
{
701+
if (callback_cred) {
702+
put_rpccred(callback_cred);
703+
callback_cred = NULL;
704+
}
705+
}
706+
699707
static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc_clnt *client, struct nfsd4_session *ses)
700708
{
701709
if (clp->cl_minorversion == 0) {

fs/nfsd/nfs4state.c

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

67936793
ret = set_callback_cred();
67946794
if (ret)
6795-
return -ENOMEM;
6795+
return ret;
6796+
67966797
laundry_wq = alloc_workqueue("%s", WQ_UNBOUND, 0, "nfsd4");
67976798
if (laundry_wq == NULL) {
67986799
ret = -ENOMEM;
6799-
goto out_recovery;
6800+
goto out_cleanup_cred;
68006801
}
68016802
ret = nfsd4_create_callback_queue();
68026803
if (ret)
68036804
goto out_free_laundry;
68046805

68056806
set_max_delegations();
6806-
68076807
return 0;
68086808

68096809
out_free_laundry:
68106810
destroy_workqueue(laundry_wq);
6811-
out_recovery:
6811+
out_cleanup_cred:
6812+
cleanup_callback_cred();
68126813
return ret;
68136814
}
68146815

@@ -6847,6 +6848,7 @@ nfs4_state_shutdown(void)
68476848
{
68486849
destroy_workqueue(laundry_wq);
68496850
nfsd4_destroy_callback_queue();
6851+
cleanup_callback_cred();
68506852
}
68516853

68526854
static void

fs/nfsd/state.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ extern struct nfs4_client_reclaim *nfsd4_find_reclaim_client(const char *recdir,
595595
extern __be32 nfs4_check_open_reclaim(clientid_t *clid,
596596
struct nfsd4_compound_state *cstate, struct nfsd_net *nn);
597597
extern int set_callback_cred(void);
598+
extern void cleanup_callback_cred(void);
598599
extern void nfsd4_probe_callback(struct nfs4_client *clp);
599600
extern void nfsd4_probe_callback_sync(struct nfs4_client *clp);
600601
extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *);

0 commit comments

Comments
 (0)