Commit 803f3197 authored by unknown's avatar unknown

Merge polly.(none):/home/kaa/src/maint/bug5731/my50-bug5731_keycache

into  polly.(none):/home/kaa/src/maint/bug5731/my50-bug5731
parents 276dd9e4 1a77dda8
...@@ -46,7 +46,7 @@ typedef struct st_key_cache ...@@ -46,7 +46,7 @@ typedef struct st_key_cache
my_bool key_cache_inited; my_bool key_cache_inited;
my_bool resize_in_flush; /* true during flush of resize operation */ my_bool resize_in_flush; /* true during flush of resize operation */
my_bool can_be_used; /* usage of cache for read/write is allowed */ my_bool can_be_used; /* usage of cache for read/write is allowed */
ulong key_cache_mem_size; /* specified size of the cache memory */ size_t key_cache_mem_size; /* specified size of the cache memory */
uint key_cache_block_size; /* size of the page buffer of a cache block */ uint key_cache_block_size; /* size of the page buffer of a cache block */
ulong min_warm_blocks; /* min number of warm blocks; */ ulong min_warm_blocks; /* min number of warm blocks; */
ulong age_threshold; /* age threshold for hot blocks */ ulong age_threshold; /* age threshold for hot blocks */
...@@ -101,11 +101,11 @@ typedef struct st_key_cache ...@@ -101,11 +101,11 @@ typedef struct st_key_cache
extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache; extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache;
extern int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, extern int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
ulong use_mem, uint division_limit, size_t use_mem, uint division_limit,
uint age_threshold); uint age_threshold);
extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
ulong use_mem, uint division_limit, size_t use_mem, uint division_limit,
uint age_threshold); uint age_threshold);
extern void change_key_cache_param(KEY_CACHE *keycache, uint division_limit, extern void change_key_cache_param(KEY_CACHE *keycache, uint division_limit,
uint age_threshold); uint age_threshold);
extern byte *key_cache_read(KEY_CACHE *keycache, extern byte *key_cache_read(KEY_CACHE *keycache,
......
...@@ -301,10 +301,11 @@ static uint next_power(uint value) ...@@ -301,10 +301,11 @@ static uint next_power(uint value)
*/ */
int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
ulong use_mem, uint division_limit, size_t use_mem, uint division_limit,
uint age_threshold) uint age_threshold)
{ {
uint blocks, hash_links, length; ulong blocks, hash_links;
size_t length;
int error; int error;
DBUG_ENTER("init_key_cache"); DBUG_ENTER("init_key_cache");
DBUG_ASSERT(key_cache_block_size >= 512); DBUG_ASSERT(key_cache_block_size >= 512);
...@@ -332,8 +333,8 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, ...@@ -332,8 +333,8 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
DBUG_PRINT("info", ("key_cache_block_size: %u", DBUG_PRINT("info", ("key_cache_block_size: %u",
key_cache_block_size)); key_cache_block_size));
blocks= (uint) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) + blocks= (ulong) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) +
sizeof(HASH_LINK*) * 5/4 + key_cache_block_size)); sizeof(HASH_LINK*) * 5/4 + key_cache_block_size));
/* It doesn't make sense to have too few blocks (less than 8) */ /* It doesn't make sense to have too few blocks (less than 8) */
if (blocks >= 8 && keycache->disk_blocks < 0) if (blocks >= 8 && keycache->disk_blocks < 0)
{ {
...@@ -351,18 +352,18 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, ...@@ -351,18 +352,18 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
ALIGN_SIZE(hash_links * sizeof(HASH_LINK)) + ALIGN_SIZE(hash_links * sizeof(HASH_LINK)) +
ALIGN_SIZE(sizeof(HASH_LINK*) * ALIGN_SIZE(sizeof(HASH_LINK*) *
keycache->hash_entries))) + keycache->hash_entries))) +
((ulong) blocks * keycache->key_cache_block_size) > use_mem) ((size_t) blocks * keycache->key_cache_block_size) > use_mem)
blocks--; blocks--;
/* Allocate memory for cache page buffers */ /* Allocate memory for cache page buffers */
if ((keycache->block_mem= if ((keycache->block_mem=
my_large_malloc((ulong) blocks * keycache->key_cache_block_size, my_large_malloc((size_t) blocks * keycache->key_cache_block_size,
MYF(MY_WME)))) MYF(MY_WME))))
{ {
/* /*
Allocate memory for blocks, hash_links and hash entries; Allocate memory for blocks, hash_links and hash entries;
For each block 2 hash links are allocated For each block 2 hash links are allocated
*/ */
if ((keycache->block_root= (BLOCK_LINK*) my_malloc((uint) length, if ((keycache->block_root= (BLOCK_LINK*) my_malloc(length,
MYF(0)))) MYF(0))))
break; break;
my_large_free(keycache->block_mem, MYF(0)); my_large_free(keycache->block_mem, MYF(0));
...@@ -375,7 +376,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, ...@@ -375,7 +376,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
} }
blocks= blocks / 4*3; blocks= blocks / 4*3;
} }
keycache->blocks_unused= (ulong) blocks; keycache->blocks_unused= blocks;
keycache->disk_blocks= (int) blocks; keycache->disk_blocks= (int) blocks;
keycache->hash_links= hash_links; keycache->hash_links= hash_links;
keycache->hash_root= (HASH_LINK**) ((char*) keycache->block_root + keycache->hash_root= (HASH_LINK**) ((char*) keycache->block_root +
...@@ -480,8 +481,8 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, ...@@ -480,8 +481,8 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
*/ */
int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
ulong use_mem, uint division_limit, size_t use_mem, uint division_limit,
uint age_threshold) uint age_threshold)
{ {
int blocks; int blocks;
struct st_my_thread_var *thread; struct st_my_thread_var *thread;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment