diff options
-rw-r--r-- | libglusterfs/src/common-utils.c | 15 | ||||
-rw-r--r-- | libglusterfs/src/common-utils.h | 1 | ||||
-rw-r--r-- | xlators/performance/io-cache/src/io-cache.c | 16 | ||||
-rw-r--r-- | xlators/performance/io-cache/src/ioc-inode.c | 12 |
4 files changed, 32 insertions, 12 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index de0cb774b74..3f52a90a010 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -56,6 +56,21 @@ struct dnscache6 { struct addrinfo *next; }; + +int +gf_log2 (unsigned long x) +{ + int val = 0; + + while (x != 1) { + x /= 2; + val++; + } + + return val; +} + + int32_t gf_resolve_ip6 (const char *hostname, uint16_t port, diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index c5869f4a424..48788d29545 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -330,6 +330,7 @@ int gf_lockfd (int fd); int gf_unlockfd (int fd); int get_checksum_for_file (int fd, uint32_t *checksum); +int gf_log2 (unsigned long x); #endif /* _COMMON_UTILS_H */ diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c index 5c1f74db12f..da3f4f15da3 100644 --- a/xlators/performance/io-cache/src/io-cache.c +++ b/xlators/performance/io-cache/src/io-cache.c @@ -30,6 +30,8 @@ #include <assert.h> #include <sys/time.h> +extern int ioc_log2_page_size; + uint32_t ioc_get_priority (ioc_table_t *table, const char *path); @@ -1234,11 +1236,12 @@ out: int32_t init (xlator_t *this) { - ioc_table_t *table = NULL; - dict_t *options = this->options; - uint32_t index = 0; - char *cache_size_string = NULL; - int32_t ret = -1; + ioc_table_t *table = NULL; + dict_t *options = this->options; + uint32_t index = 0; + char *cache_size_string = NULL; + int32_t ret = -1; + glusterfs_ctx_t *ctx = NULL; if (!this->children || this->children->next) { gf_log (this->name, GF_LOG_ERROR, @@ -1320,6 +1323,9 @@ init (xlator_t *this) this->private = table; ret = 0; + ctx = this->ctx; + ioc_log2_page_size = gf_log2 (ctx->page_size); + out: if (ret == -1) { if (table != NULL) { diff --git a/xlators/performance/io-cache/src/ioc-inode.c b/xlators/performance/io-cache/src/ioc-inode.c index e647b318342..11da863123f 100644 --- a/xlators/performance/io-cache/src/ioc-inode.c +++ b/xlators/performance/io-cache/src/ioc-inode.c @@ -24,18 +24,16 @@ #include "io-cache.h" +int ioc_log2_page_size; inline uint32_t ioc_hashfn (void *data, int len) { - uint32_t hash = 0; - while (len > 0) { - hash ^= *(uint32_t *)data; - data += sizeof (uint32_t); - len -= sizeof (uint32_t); - } + off_t offset; + + offset = *(off_t *) data; - return hash; + return (offset >> ioc_log2_page_size); } /* |