]> git.hungrycats.org Git - linux/commitdiff
nfsd/callback: Cleanup callback cred on shutdown
authorKinglong Mee <kinglongmee@gmail.com>
Sun, 5 Feb 2017 01:57:07 +0000 (09:57 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 21 Oct 2017 15:09:06 +0000 (17:09 +0200)
[ 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>
fs/nfsd/nfs4callback.c
fs/nfsd/nfs4state.c
fs/nfsd/state.h

index 15bdc2d48cfe32fa10f623de37123acf52318451..24ace275160cca71d3ae3a223d28d0ca9356b6de 100644 (file)
@@ -696,6 +696,14 @@ int set_callback_cred(void)
        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)
 {
        if (clp->cl_minorversion == 0) {
index 9e5a6842346e74ac3d8cae71d727e4102d945448..ca9ebc3242d3d48dd4cb230df087b632f6217327 100644 (file)
@@ -6792,23 +6792,24 @@ nfs4_state_start(void)
 
        ret = set_callback_cred();
        if (ret)
-               return -ENOMEM;
+               return ret;
+
        laundry_wq = alloc_workqueue("%s", WQ_UNBOUND, 0, "nfsd4");
        if (laundry_wq == NULL) {
                ret = -ENOMEM;
-               goto out_recovery;
+               goto out_cleanup_cred;
        }
        ret = nfsd4_create_callback_queue();
        if (ret)
                goto out_free_laundry;
 
        set_max_delegations();
-
        return 0;
 
 out_free_laundry:
        destroy_workqueue(laundry_wq);
-out_recovery:
+out_cleanup_cred:
+       cleanup_callback_cred();
        return ret;
 }
 
@@ -6847,6 +6848,7 @@ nfs4_state_shutdown(void)
 {
        destroy_workqueue(laundry_wq);
        nfsd4_destroy_callback_queue();
+       cleanup_callback_cred();
 }
 
 static void
index 5134eedcb16c13189b0ac417fa33f41f5c08e409..86af697c21d398441e8de0b935565f2c82f57f74 100644 (file)
@@ -595,6 +595,7 @@ extern struct nfs4_client_reclaim *nfsd4_find_reclaim_client(const char *recdir,
 extern __be32 nfs4_check_open_reclaim(clientid_t *clid,
                struct nfsd4_compound_state *cstate, struct nfsd_net *nn);
 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_sync(struct nfs4_client *clp);
 extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *);