A umount/mount loop for a krb5 mount was sending RPCSEC_GSS_DESTROY
calls at times. We end up a huge number of contexts that are expired but
not destroyed, eventually failing mounts after some time.

Release reference we got on GSS data object after deleting it from hash
table.

Signed-off-by: Malahal Naineni <mala...@us.ibm.com>
---
 src/authgss_hash.c | 2 +-
 src/svc_auth_gss.c | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/authgss_hash.c b/src/authgss_hash.c
index d88a378..21ecaf9 100644
--- a/src/authgss_hash.c
+++ b/src/authgss_hash.c
@@ -187,7 +187,7 @@ authgss_ctx_hash_set(struct svc_rpc_gss_data *gd)
        gss_ctx = (gss_union_ctx_id_desc *) (gd->ctx);
        gd->hk.k = gss_ctx_hash(gss_ctx);
 
-       ++(gd->refcnt);         /* locked */
+       (void)atomic_inc_uint32_t(&gd->refcnt);
        t = rbtx_partition_of_scalar(&authgss_hash_st.xt, gd->hk.k);
        mutex_lock(&t->mtx);
        rslt =
diff --git a/src/svc_auth_gss.c b/src/svc_auth_gss.c
index 3322ab5..cc7b1f4 100644
--- a/src/svc_auth_gss.c
+++ b/src/svc_auth_gss.c
@@ -612,7 +612,7 @@ _svcauth_gss(struct svc_req *req, struct rpc_msg *msg,
 
                *no_dispatch = true;
 
-               (void)authgss_ctx_hash_del(gd); /* unrefs, can destroy gd */
+               (void)authgss_ctx_hash_del(gd);
 
                /* avoid lock order reversal gd->lock, xprt->xp_lock */
                mutex_unlock(&gd->lock);
@@ -622,6 +622,11 @@ _svcauth_gss(struct svc_req *req, struct rpc_msg *msg,
                    svc_sendreply(req->rq_xprt, req, (xdrproc_t) xdr_void,
                                  (caddr_t) NULL);
 
+               /* We acquired a reference on gd with authgss_ctx_hash_get
+                * call.  Time to release the reference as we don't need
+                * gd anymore.
+                */
+               unref_svc_rpc_gss_data(gd, SVC_RPC_GSS_FLAG_NONE);
                req->rq_auth = &svc_auth_none;
 
                break;
-- 
1.8.3.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Nfs-ganesha-devel mailing list
Nfs-ganesha-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel

Reply via email to