Use partition size for deleting GSS contexts
Currently we don't have a count of GSS contexts in a cache partition,
and mistakenly use global cache size for deleting GSS contexts from a
partition. This patch adds number of GSS contexts in a cache partition
and uses it while deleting GSS contexts.
Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
diff --git a/src/authgss_hash.c b/src/authgss_hash.c
index 4ca53b5..d88a378 100644
--- a/src/authgss_hash.c
+++ b/src/authgss_hash.c
@@ -44,6 +44,7 @@
struct authgss_x_part {
uint32_t gen;
+ uint32_t size;
TAILQ_HEAD(ctx_tailq, svc_rpc_gss_data) lru_q;
};
@@ -119,7 +120,7 @@
sizeof(struct opr_rbtree_node *));
/* partition ctx LRU */
- axp = (struct authgss_x_part *)mem_alloc(sizeof(*axp));
+ axp = (struct authgss_x_part *)mem_zalloc(sizeof(*axp));
TAILQ_INIT(&axp->lru_q);
xp->u1 = axp;
}
@@ -195,6 +196,7 @@
/* lru */
axp = (struct authgss_x_part *)t->u1;
TAILQ_INSERT_TAIL(&axp->lru_q, gd, lru_q);
+ ++(axp->size);
mutex_unlock(&t->mtx);
/* global size */
@@ -216,6 +218,7 @@
rbtree_x_cached_remove(&authgss_hash_st.xt, t, &gd->node_k, gd->hk.k);
axp = (struct authgss_x_part *)t->u1;
TAILQ_REMOVE(&axp->lru_q, gd, lru_q);
+ --(axp->size);
mutex_unlock(&t->mtx);
/* global size */
@@ -266,13 +269,14 @@
/* Remove the least-recently-used entry in this hash
* partition iff it is expired, or the partition size
* limit is exceeded */
- if (unlikely((authgss_hash_st.size > authgss_hash_st.max_part)
+ if (unlikely((axp->size > authgss_hash_st.max_part)
|| (authgss_ctx_expired(gd)))) {
/* remove entry */
rbtree_x_cached_remove(&authgss_hash_st.xt, xp,
&gd->node_k, gd->hk.k);
TAILQ_REMOVE(&axp->lru_q, gd, lru_q);
+ --(axp->size);
(void)atomic_dec_uint32_t(&authgss_hash_st.size);
/* drop sentinel ref (may free gd) */