diff options
Diffstat (limited to 'xlators/performance/nl-cache/src')
| -rw-r--r-- | xlators/performance/nl-cache/src/nl-cache-helper.c | 63 | ||||
| -rw-r--r-- | xlators/performance/nl-cache/src/nl-cache-mem-types.h | 5 | ||||
| -rw-r--r-- | xlators/performance/nl-cache/src/nl-cache-messages.h | 2 | ||||
| -rw-r--r-- | xlators/performance/nl-cache/src/nl-cache.c | 22 | ||||
| -rw-r--r-- | xlators/performance/nl-cache/src/nl-cache.h | 10 |
5 files changed, 53 insertions, 49 deletions
diff --git a/xlators/performance/nl-cache/src/nl-cache-helper.c b/xlators/performance/nl-cache/src/nl-cache-helper.c index b057ed4b5d6..29b99b5b8ea 100644 --- a/xlators/performance/nl-cache/src/nl-cache-helper.c +++ b/xlators/performance/nl-cache/src/nl-cache-helper.c @@ -10,7 +10,7 @@ #include "nl-cache.h" #include "timer-wheel.h" -#include "statedump.h" +#include <glusterfs/statedump.h> /* Caching guidelines: * This xlator serves negative lookup(ENOENT lookups) from the cache, @@ -113,7 +113,7 @@ out: } void -nlc_update_child_down_time(xlator_t *this, time_t *now) +nlc_update_child_down_time(xlator_t *this, time_t now) { nlc_conf_t *conf = NULL; @@ -121,7 +121,7 @@ nlc_update_child_down_time(xlator_t *this, time_t *now) LOCK(&conf->lock); { - conf->last_child_down = *now; + conf->last_child_down = now; } UNLOCK(&conf->lock); @@ -145,12 +145,10 @@ nlc_disable_cache(xlator_t *this) } static int -__nlc_inode_ctx_get(xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p, - nlc_pe_t **nlc_pe_p) +__nlc_inode_ctx_get(xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p) { int ret = 0; nlc_ctx_t *nlc_ctx = NULL; - nlc_pe_t *nlc_pe = NULL; uint64_t nlc_ctx_int = 0; uint64_t nlc_pe_int = 0; @@ -159,10 +157,6 @@ __nlc_inode_ctx_get(xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p, nlc_ctx = (void *)(long)(nlc_ctx_int); *nlc_ctx_p = nlc_ctx; } - if (ret == 0 && nlc_pe_p) { - nlc_pe = (void *)(long)(nlc_pe_int); - *nlc_pe_p = nlc_pe; - } return ret; } @@ -170,30 +164,32 @@ static int nlc_inode_ctx_set(xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx, nlc_pe_t *nlc_pe_p) { + uint64_t ctx1, ctx2; int ret = -1; + ctx1 = (uint64_t)(uintptr_t)nlc_ctx; + ctx2 = (uint64_t)(uintptr_t)nlc_pe_p; + /* The caller may choose to set one of the ctxs, hence check * if the ctx1/2 is non zero and then send the address. If we * blindly send the address of both the ctxs, it may reset the * ctx the caller had sent NULL(intended as leave untouched) for.*/ LOCK(&inode->lock); { - ret = __inode_ctx_set2(inode, this, nlc_ctx ? (uint64_t *)&nlc_ctx : 0, - nlc_pe_p ? (uint64_t *)&nlc_pe_p : 0); + ret = __inode_ctx_set2(inode, this, ctx1 ? &ctx1 : 0, ctx2 ? &ctx2 : 0); } UNLOCK(&inode->lock); return ret; } static void -nlc_inode_ctx_get(xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p, - nlc_pe_t **nlc_pe_p) +nlc_inode_ctx_get(xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p) { int ret = 0; LOCK(&inode->lock); { - ret = __nlc_inode_ctx_get(this, inode, nlc_ctx_p, nlc_pe_p); + ret = __nlc_inode_ctx_get(this, inode, nlc_ctx_p); if (ret < 0) gf_msg_debug(this->name, 0, "inode ctx get failed for " @@ -243,6 +239,8 @@ nlc_init_invalid_ctx(xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx) int ret = -1; conf = this->private; + if (!nlc_ctx) + goto out; LOCK(&nlc_ctx->lock); { @@ -264,7 +262,7 @@ nlc_init_invalid_ctx(xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx) if (nlc_ctx->timer) { gf_tw_mod_timer_pending(conf->timer_wheel, nlc_ctx->timer, conf->cache_timeout); - time(&nlc_ctx->cache_time); + nlc_ctx->cache_time = gf_time(); goto unlock; } @@ -283,14 +281,14 @@ nlc_init_invalid_ctx(xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx) } unlock: UNLOCK(&nlc_ctx->lock); - +out: return; } static nlc_ctx_t * -nlc_inode_ctx_get_set(xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p, - nlc_pe_t **nlc_pe_p) +nlc_inode_ctx_get_set(xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p) { + uint64_t ctx; int ret = 0; nlc_ctx_t *nlc_ctx = NULL; nlc_conf_t *conf = NULL; @@ -299,7 +297,7 @@ nlc_inode_ctx_get_set(xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p, LOCK(&inode->lock); { - ret = __nlc_inode_ctx_get(this, inode, &nlc_ctx, nlc_pe_p); + ret = __nlc_inode_ctx_get(this, inode, &nlc_ctx); if (nlc_ctx) goto unlock; @@ -321,7 +319,8 @@ nlc_inode_ctx_get_set(xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p, goto unlock; } - ret = __inode_ctx_set2(inode, this, (uint64_t *)&nlc_ctx, NULL); + ctx = (uint64_t)(uintptr_t)nlc_ctx; + ret = __inode_ctx_set2(inode, this, &ctx, NULL); if (ret) { gf_msg(this->name, GF_LOG_ERROR, ENOMEM, NLC_MSG_NO_MEMORY, "inode ctx set failed"); @@ -408,7 +407,7 @@ nlc_set_dir_state(xlator_t *this, inode_t *inode, uint64_t state) goto out; } - nlc_inode_ctx_get_set(this, inode, &nlc_ctx, NULL); + nlc_inode_ctx_get_set(this, inode, &nlc_ctx); if (!nlc_ctx) goto out; @@ -428,7 +427,7 @@ nlc_cache_timeout_handler(struct gf_tw_timer_list *timer, void *data, nlc_timer_data_t *tmp = data; nlc_ctx_t *nlc_ctx = NULL; - nlc_inode_ctx_get(tmp->this, tmp->inode, &nlc_ctx, NULL); + nlc_inode_ctx_get(tmp->this, tmp->inode, &nlc_ctx); if (!nlc_ctx) goto out; @@ -497,7 +496,7 @@ __nlc_inode_ctx_timer_start(xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx) nlc_ctx->timer_data = tmp; gf_tw_add_timer(conf->timer_wheel, timer); - time(&nlc_ctx->cache_time); + nlc_ctx->cache_time = gf_time(); gf_msg_trace(this->name, 0, "Registering timer:%p, inode:%p, " "gfid:%s", @@ -694,7 +693,7 @@ nlc_inode_clear_cache(xlator_t *this, inode_t *inode, int reason) { nlc_ctx_t *nlc_ctx = NULL; - nlc_inode_ctx_get(this, inode, &nlc_ctx, NULL); + nlc_inode_ctx_get(this, inode, &nlc_ctx); if (!nlc_ctx) goto out; @@ -881,7 +880,7 @@ nlc_dir_add_ne(xlator_t *this, inode_t *inode, const char *name) goto out; } - nlc_inode_ctx_get_set(this, inode, &nlc_ctx, NULL); + nlc_inode_ctx_get_set(this, inode, &nlc_ctx); if (!nlc_ctx) goto out; @@ -912,7 +911,7 @@ nlc_dir_remove_pe(xlator_t *this, inode_t *parent, inode_t *entry_ino, goto out; } - nlc_inode_ctx_get(this, parent, &nlc_ctx, NULL); + nlc_inode_ctx_get(this, parent, &nlc_ctx); if (!nlc_ctx) goto out; @@ -943,7 +942,7 @@ nlc_dir_add_pe(xlator_t *this, inode_t *inode, inode_t *entry_ino, goto out; } - nlc_inode_ctx_get_set(this, inode, &nlc_ctx, NULL); + nlc_inode_ctx_get_set(this, inode, &nlc_ctx); if (!nlc_ctx) goto out; @@ -1049,7 +1048,7 @@ nlc_is_negative_lookup(xlator_t *this, loc_t *loc) goto out; } - nlc_inode_ctx_get(this, inode, &nlc_ctx, NULL); + nlc_inode_ctx_get(this, inode, &nlc_ctx); if (!nlc_ctx) goto out; @@ -1100,7 +1099,7 @@ nlc_get_real_file_name(xlator_t *this, loc_t *loc, const char *fname, goto out; } - nlc_inode_ctx_get(this, inode, &nlc_ctx, NULL); + nlc_inode_ctx_get(this, inode, &nlc_ctx); if (!nlc_ctx) goto out; @@ -1150,7 +1149,7 @@ nlc_dump_inodectx(xlator_t *this, inode_t *inode) nlc_ne_t *ne = NULL; nlc_ne_t *tmp1 = NULL; - nlc_inode_ctx_get(this, inode, &nlc_ctx, NULL); + nlc_inode_ctx_get(this, inode, &nlc_ctx); if (!nlc_ctx) goto out; @@ -1174,7 +1173,7 @@ 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", "%" GF_PRI_TIME, nlc_ctx->cache_time); + gf_proc_dump_write("cache-time", "%ld", 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); diff --git a/xlators/performance/nl-cache/src/nl-cache-mem-types.h b/xlators/performance/nl-cache/src/nl-cache-mem-types.h index bc61eeca9da..93a17b3fd5a 100644 --- a/xlators/performance/nl-cache/src/nl-cache-mem-types.h +++ b/xlators/performance/nl-cache/src/nl-cache-mem-types.h @@ -11,11 +11,10 @@ #ifndef __NL_CACHE_MEM_TYPES_H__ #define __NL_CACHE_MEM_TYPES_H__ -#include "mem-types.h" +#include <glusterfs/mem-types.h> enum gf_nlc_mem_types_ { - gf_nlc_mt_conf_t = gf_common_mt_end + 1, - gf_nlc_mt_nlc_conf_t, + gf_nlc_mt_nlc_conf_t = gf_common_mt_end + 1, gf_nlc_mt_nlc_ctx_t, gf_nlc_mt_nlc_local_t, gf_nlc_mt_nlc_pe_t, diff --git a/xlators/performance/nl-cache/src/nl-cache-messages.h b/xlators/performance/nl-cache/src/nl-cache-messages.h index 17fd96de17c..222d709e133 100644 --- a/xlators/performance/nl-cache/src/nl-cache-messages.h +++ b/xlators/performance/nl-cache/src/nl-cache-messages.h @@ -11,7 +11,7 @@ #ifndef __NL_CACHE_MESSAGES_H__ #define __NL_CACHE_MESSAGES_H__ -#include "glfs-message-id.h" +#include <glusterfs/glfs-message-id.h> /* To add new message IDs, append new identifiers at the end of the list. * diff --git a/xlators/performance/nl-cache/src/nl-cache.c b/xlators/performance/nl-cache/src/nl-cache.c index 02d6df55349..33a7c471663 100644 --- a/xlators/performance/nl-cache/src/nl-cache.c +++ b/xlators/performance/nl-cache/src/nl-cache.c @@ -9,8 +9,8 @@ */ #include "nl-cache.h" -#include "statedump.h" -#include "upcall-utils.h" +#include <glusterfs/statedump.h> +#include <glusterfs/upcall-utils.h> static void nlc_dentry_op(call_frame_t *frame, xlator_t *this, gf_boolean_t multilink) @@ -520,15 +520,13 @@ int nlc_notify(xlator_t *this, int event, void *data, ...) { int ret = 0; - time_t now = 0; switch (event) { case GF_EVENT_CHILD_DOWN: case GF_EVENT_SOME_DESCENDENT_DOWN: case GF_EVENT_CHILD_UP: case GF_EVENT_SOME_DESCENDENT_UP: - time(&now); - nlc_update_child_down_time(this, &now); + nlc_update_child_down_time(this, gf_time()); /* TODO: nlc_clear_all_cache (this); else lru prune will lazily clear it*/ break; @@ -604,7 +602,7 @@ nlc_priv_dump(xlator_t *this) GF_ATOMIC_GET(conf->nlc_counter.pe_inode_cnt)); gf_proc_dump_write("inodes_with_negative_dentry_cache", "%" PRId64, GF_ATOMIC_GET(conf->nlc_counter.ne_inode_cnt)); - gf_proc_dump_write("dentry_invalidations_recieved", "%" PRId64, + gf_proc_dump_write("dentry_invalidations_received", "%" PRId64, GF_ATOMIC_GET(conf->nlc_counter.nlc_invals)); gf_proc_dump_write("cache_limit", "%" PRIu64, conf->cache_size); gf_proc_dump_write("consumed_cache_size", "%" PRId64, @@ -637,7 +635,7 @@ nlc_dump_metrics(xlator_t *this, int fd) this->name, GF_ATOMIC_GET(conf->nlc_counter.pe_inode_cnt)); dprintf(fd, "%s.inodes_with_negative_dentry_cache %" PRId64 "\n", this->name, GF_ATOMIC_GET(conf->nlc_counter.ne_inode_cnt)); - dprintf(fd, "%s.dentry_invalidations_recieved %" PRId64 "\n", this->name, + dprintf(fd, "%s.dentry_invalidations_received %" PRId64 "\n", this->name, GF_ATOMIC_GET(conf->nlc_counter.nlc_invals)); dprintf(fd, "%s.cache_limit %" PRIu64 "\n", this->name, conf->cache_size); dprintf(fd, "%s.consumed_cache_size %" PRId64 "\n", this->name, @@ -731,7 +729,7 @@ nlc_init(xlator_t *this) GF_ATOMIC_INIT(conf->nlc_counter.nlc_invals, 0); INIT_LIST_HEAD(&conf->lru); - time(&conf->last_child_down); + conf->last_child_down = gf_time(); conf->timer_wheel = glusterfs_ctx_tw_get(this->ctx); if (!conf->timer_wheel) { @@ -779,6 +777,14 @@ struct xlator_dumpops nlc_dumpops = { struct volume_options nlc_options[] = { { + .key = {"nl-cache"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "off", + .description = "enable/disable nl-cache", + .op_version = {GD_OP_VERSION_6_0}, + .flags = OPT_FLAG_SETTABLE, + }, + { .key = {"nl-cache-positive-entry"}, .type = GF_OPTION_TYPE_BOOL, .default_value = "false", diff --git a/xlators/performance/nl-cache/src/nl-cache.h b/xlators/performance/nl-cache/src/nl-cache.h index 9c9682f6396..85fcc176342 100644 --- a/xlators/performance/nl-cache/src/nl-cache.h +++ b/xlators/performance/nl-cache/src/nl-cache.h @@ -13,10 +13,10 @@ #include "nl-cache-mem-types.h" #include "nl-cache-messages.h" -#include "glusterfs.h" -#include "xlator.h" -#include "defaults.h" -#include "atomic.h" +#include <glusterfs/glusterfs.h> +#include <glusterfs/xlator.h> +#include <glusterfs/defaults.h> +#include <glusterfs/atomic.h> #define NLC_INVALID 0x0000 #define NLC_PE_FULL 0x0001 @@ -155,7 +155,7 @@ nlc_local_init(call_frame_t *frame, xlator_t *this, glusterfs_fop_t fop, loc_t *loc, loc_t *loc2); void -nlc_update_child_down_time(xlator_t *this, time_t *now); +nlc_update_child_down_time(xlator_t *this, time_t now); void nlc_inode_clear_cache(xlator_t *this, inode_t *inode, int reason); |
