From 582ab3b5292701242ee2259c5abc8dfe741d59f9 Mon Sep 17 00:00:00 2001
From: Poornima G <pgurusid@redhat.com>
Date: Tue, 25 Apr 2017 15:04:34 +0530
Subject: [PATCH 436/473] nl-cache: Fix the issue in refd_inode counting and
prune the cache
>Reviewed-on: https://review.gluster.org/17110
>Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
>Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: Niels de Vos <ndevos@redhat.com>
>Signed-off-by: Poornima G <pgurusid@redhat.com>
Change-Id: I5b9beb8502667bc3876385900bc01b6491348716
BUG: 1450330
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/106135
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
xlators/performance/nl-cache/src/nl-cache-helper.c | 8 +++++---
xlators/performance/nl-cache/src/nl-cache.c | 8 +++++---
xlators/performance/nl-cache/src/nl-cache.h | 3 +++
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/xlators/performance/nl-cache/src/nl-cache-helper.c b/xlators/performance/nl-cache/src/nl-cache-helper.c
index 34438ed..edc8c16 100644
--- a/xlators/performance/nl-cache/src/nl-cache-helper.c
+++ b/xlators/performance/nl-cache/src/nl-cache-helper.c
@@ -558,13 +558,13 @@ __nlc_free_pe (xlator_t *this, nlc_ctx_t *nlc_ctx, nlc_pe_t *pe)
{
uint64_t pe_int = 0;
nlc_conf_t *conf = NULL;
- uint64_t *nlc_ctx_int = NULL;
+ uint64_t nlc_ctx_int = 0;
conf = this->private;
if (pe->inode) {
inode_ctx_reset1 (pe->inode, this, &pe_int);
- inode_ctx_get2 (pe->inode, this, nlc_ctx_int, NULL);
+ inode_ctx_get2 (pe->inode, this, &nlc_ctx_int, NULL);
inode_unref (pe->inode);
}
list_del (&pe->list);
@@ -1118,6 +1118,8 @@ nlc_dump_inodectx (xlator_t *this, inode_t *inode)
gf_proc_dump_write ("state", "%"PRIu64, nlc_ctx->state);
gf_proc_dump_write ("timer", "%p", nlc_ctx->timer);
gf_proc_dump_write ("cache-time", "%lld", nlc_ctx->cache_time);
+ gf_proc_dump_write ("cache-size", "%zu", nlc_ctx->cache_size);
+ gf_proc_dump_write ("refd-inodes", "%"PRIu64, nlc_ctx->refd_inodes);
if (IS_PE_VALID (nlc_ctx->state))
list_for_each_entry_safe (pe, tmp, &nlc_ctx->pe, list) {
@@ -1130,7 +1132,7 @@ nlc_dump_inodectx (xlator_t *this, inode_t *inode)
gf_proc_dump_write ("ne", "%s", ne->name);
}
- UNLOCK (&nlc_ctx->lock);
+ UNLOCK (&nlc_ctx->lock);
}
if (ret && nlc_ctx)
diff --git a/xlators/performance/nl-cache/src/nl-cache.c b/xlators/performance/nl-cache/src/nl-cache.c
index 08e7d9e..675b5de 100644
--- a/xlators/performance/nl-cache/src/nl-cache.c
+++ b/xlators/performance/nl-cache/src/nl-cache.c
@@ -54,6 +54,8 @@ nlc_dentry_op (call_frame_t *frame, xlator_t *this, gf_boolean_t multilink)
default:
return;
}
+
+ nlc_lru_prune (this, NULL);
out:
return;
}
@@ -766,10 +768,10 @@ struct volume_options options[] = {
"a while and the cache is cleared based on LRU",
},
{ .key = {"nl-cache-timeout"},
- .type = GF_OPTION_TYPE_INT,
+ .type = GF_OPTION_TYPE_TIME,
.min = 0,
- .max = 600,
- .default_value = "600",
+ .max = 1 * GF_DAY_IN_SECONDS,
+ .default_value = "60",
.description = "Time period after which cache has to be refreshed",
},
{ .key = {NULL} },
diff --git a/xlators/performance/nl-cache/src/nl-cache.h b/xlators/performance/nl-cache/src/nl-cache.h
index e94641c..10ec022 100644
--- a/xlators/performance/nl-cache/src/nl-cache.h
+++ b/xlators/performance/nl-cache/src/nl-cache.h
@@ -170,4 +170,7 @@ nlc_clear_all_cache (xlator_t *this);
void
nlc_disable_cache (xlator_t *this);
+void
+nlc_lru_prune (xlator_t *this, inode_t *inode);
+
#endif /* __NL_CACHE_H__ */
--
1.8.3.1