Last active
December 15, 2015 09:49
-
-
Save portante/5241308 to your computer and use it in GitHub Desktop.
gluster internal inode and dirent hashtable increases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff -rcw boo/glusterfs-3.3.0catalyst3/libglusterfs/src/inode.c foo/glusterfs-3.3.0catalyst3p/libglusterfs/src/inode.c | |
| *** boo/glusterfs-3.3.0catalyst3/libglusterfs/src/inode.c 2012-10-16 13:32:42.000000000 -0400 | |
| --- foo/glusterfs-3.3.0catalyst3p/libglusterfs/src/inode.c 2013-03-25 17:53:54.172430688 -0400 | |
| *************** | |
| *** 49,54 **** | |
| --- 49,56 ---- | |
| void | |
| fd_dump (struct list_head *head, char *prefix); | |
| + #define NAME_HASHSIZE 999983 /* Was 14057 */ | |
| + | |
| static int | |
| hash_dentry (inode_t *parent, const char *name, int mod) | |
| { | |
| *************** | |
| *** 66,83 **** | |
| return ret; | |
| } | |
| static int | |
| ! hash_gfid (uuid_t uuid, int mod) | |
| { | |
| ! int ret = 0; | |
| ! | |
| ! ret = uuid[15] + (uuid[14] << 8); | |
| ! | |
| ! return ret; | |
| } | |
| - | |
| static void | |
| __dentry_hash (dentry_t *dentry) | |
| { | |
| --- 68,89 ---- | |
| return ret; | |
| } | |
| + #define INODE_HASHPOWER 24 | |
| + #if INODE_HASHPOWER > 30 || INODE_HASHPOWER < 16 | |
| + # error "Consider well the size of the hash table" | |
| + #endif | |
| + #define INODE_HASHMASK ~(~0 << INODE_HASHPOWER) | |
| + #define INODE_HASHSIZE (2 ** INODE_HASHPOWER) | |
| static int | |
| ! hash_gfid (uuid_t uuid) | |
| { | |
| ! // Get the low-order 4 bytes | |
| ! int ret = *(int *)&uuid[12]; | |
| ! // Mask out what we want | |
| ! return ret & INODE_HASHMASK; | |
| } | |
| static void | |
| __dentry_hash (dentry_t *dentry) | |
| { | |
| *************** | |
| *** 258,264 **** | |
| } | |
| table = inode->table; | |
| ! hash = hash_gfid (inode->gfid, 65536); | |
| list_del_init (&inode->hash); | |
| list_add (&inode->hash, &table->inode_hash[hash]); | |
| --- 264,270 ---- | |
| } | |
| table = inode->table; | |
| ! hash = hash_gfid (inode->gfid); | |
| list_del_init (&inode->hash); | |
| list_add (&inode->hash, &table->inode_hash[hash]); | |
| *************** | |
| *** 759,765 **** | |
| if (__is_root_gfid (gfid)) | |
| return table->root; | |
| ! hash = hash_gfid (gfid, 65536); | |
| list_for_each_entry (tmp, &table->inode_hash[hash], hash) { | |
| if (uuid_compare (tmp->gfid, gfid) == 0) { | |
| --- 765,771 ---- | |
| if (__is_root_gfid (gfid)) | |
| return table->root; | |
| ! hash = hash_gfid (gfid); | |
| list_for_each_entry (tmp, &table->inode_hash[hash], hash) { | |
| if (uuid_compare (tmp->gfid, gfid) == 0) { | |
| *************** | |
| *** 1275,1281 **** | |
| new->lru_limit = lru_limit; | |
| ! new->hashsize = 14057; /* TODO: Random Number?? */ | |
| /* In case FUSE is initing the inode table. */ | |
| if (lru_limit == 0) | |
| --- 1281,1287 ---- | |
| new->lru_limit = lru_limit; | |
| ! new->hashsize = NAME_HASHSIZE; | |
| /* In case FUSE is initing the inode table. */ | |
| if (lru_limit == 0) | |
| *************** | |
| *** 1291,1297 **** | |
| if (!new->dentry_pool) | |
| goto out; | |
| ! new->inode_hash = (void *)GF_CALLOC (65536, | |
| sizeof (struct list_head), | |
| gf_common_mt_list_head); | |
| if (!new->inode_hash) | |
| --- 1297,1303 ---- | |
| if (!new->dentry_pool) | |
| goto out; | |
| ! new->inode_hash = (void *)GF_CALLOC (INODE_HASHSIZE, | |
| sizeof (struct list_head), | |
| gf_common_mt_list_head); | |
| if (!new->inode_hash) | |
| *************** | |
| *** 1310,1316 **** | |
| if (!new->fd_mem_pool) | |
| goto out; | |
| ! for (i = 0; i < 65536; i++) { | |
| INIT_LIST_HEAD (&new->inode_hash[i]); | |
| } | |
| --- 1316,1322 ---- | |
| if (!new->fd_mem_pool) | |
| goto out; | |
| ! for (i = 0; i < INODE_HASHSIZE; i++) { | |
| INIT_LIST_HEAD (&new->inode_hash[i]); | |
| } | |
| diff -rcw boo/glusterfs-3.3.0catalyst3/libglusterfs/src/inode.h foo/glusterfs-3.3.0catalyst3p/libglusterfs/src/inode.h | |
| *** boo/glusterfs-3.3.0catalyst3/libglusterfs/src/inode.h 2012-10-16 13:32:42.000000000 -0400 | |
| --- foo/glusterfs-3.3.0catalyst3p/libglusterfs/src/inode.h 2013-03-25 17:57:59.057430125 -0400 | |
| *************** | |
| *** 19,25 **** | |
| #include <stdint.h> | |
| #include <sys/types.h> | |
| ! #define DEFAULT_INODE_MEMPOOL_ENTRIES 32 * 1024 | |
| #define INODE_PATH_FMT "<gfid:%s>" | |
| struct _inode_table; | |
| typedef struct _inode_table inode_table_t; | |
| --- 19,25 ---- | |
| #include <stdint.h> | |
| #include <sys/types.h> | |
| ! #define DEFAULT_INODE_MEMPOOL_ENTRIES 32 * 1024 * 4 | |
| #define INODE_PATH_FMT "<gfid:%s>" | |
| struct _inode_table; | |
| typedef struct _inode_table inode_table_t; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * $ cc -o this -g2 this.c | |
| * $ ./this 02040608101214161820222426283032 | |
| */ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #define INODE_HASHPOWER 24 | |
| #if INODE_HASHPOWER > 30 || INODE_HASHPOWER < 16 | |
| # error "Consider well the size of the hash table" | |
| #endif | |
| #define INODE_HASHMASK ~(~0 << INODE_HASHPOWER) | |
| #define INODE_HASHSIZE (2 ** INODE_HASHPOWER) | |
| typedef unsigned char uuid_t[16]; | |
| static int | |
| hash_gfid (uuid_t uuid) | |
| { | |
| // Get the low-order 4 bytes | |
| int ret = *(int *)&uuid[12]; | |
| // Mask out what we want | |
| return ret & INODE_HASHMASK; | |
| } | |
| int main(int argc, char *argv[]) { | |
| uuid_t uuid; | |
| char c[3]; | |
| int i, j; | |
| for (i = 0; i < 16; i++) { | |
| j = 2 * i; | |
| c[0] = argv[1][j]; | |
| c[1] = argv[1][j+1]; | |
| c[2] = '\0'; | |
| uuid[i] = (unsigned char)atoi(c); | |
| printf("c = %s, uuid[%d] = %d\n", c, i, uuid[i]); | |
| } | |
| printf("uuid[12..15]=%d%d%d%d\n", uuid[12], uuid[13], uuid[14], uuid[15]); | |
| printf("uuid[12..15]=%0x\n", *(unsigned int *)&uuid[12]); | |
| printf("hash = %0x\n", hash_gfid(uuid)); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment