summaryrefslogtreecommitdiff
path: root/mysys/mf_keycache.c
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-07-02 22:08:51 +0200
committerSergei Golubchik <sergii@pisem.net>2011-07-02 22:08:51 +0200
commit9809f05199aeb0b67991fac41bd86f38730768dc (patch)
treefa2792ff86d0da014b535d743759810612338042 /mysys/mf_keycache.c
parent0accbd0364e0333e0b119aa9ce93e34ded9df6cb (diff)
parent5a0e7394a5ae0c7b6a1ea35b7ea3a8985325987a (diff)
downloadmariadb-git-9809f05199aeb0b67991fac41bd86f38730768dc.tar.gz
5.5-merge
Diffstat (limited to 'mysys/mf_keycache.c')
-rw-r--r--mysys/mf_keycache.c99
1 files changed, 6 insertions, 93 deletions
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 41b93517655..80111b3245d 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -318,16 +318,11 @@ KEY_CACHE *dflt_key_cache= &dflt_key_cache_var;
static int flush_all_key_blocks(SIMPLE_KEY_CACHE_CB *keycache);
static void end_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache, my_bool cleanup);
-#ifdef THREAD
static void wait_on_queue(KEYCACHE_WQUEUE *wqueue,
mysql_mutex_t *mutex);
static void release_whole_queue(KEYCACHE_WQUEUE *wqueue);
-#else
-#define wait_on_queue(wqueue, mutex) do {} while (0)
-#define release_whole_queue(wqueue) do {} while (0)
-#endif
static void free_block(SIMPLE_KEY_CACHE_CB *keycache, BLOCK_LINK *block);
-#if !defined(DBUG_OFF)
+#ifndef DBUG_OFF
static void test_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
const char *where, my_bool lock);
#endif
@@ -379,7 +374,6 @@ static void keycache_debug_print(const char *fmt,...);
#endif /* defined(KEYCACHE_DEBUG_LOG) && defined(KEYCACHE_DEBUG) */
#if defined(KEYCACHE_DEBUG) || !defined(DBUG_OFF)
-#ifdef THREAD
static long keycache_thread_id;
#define KEYCACHE_THREAD_TRACE(l) \
KEYCACHE_DBUG_PRINT(l,("|thread %ld",keycache_thread_id))
@@ -391,11 +385,6 @@ static long keycache_thread_id;
#define KEYCACHE_THREAD_TRACE_END(l) \
KEYCACHE_DBUG_PRINT(l,("]thread %ld",keycache_thread_id))
-#else /* THREAD */
-#define KEYCACHE_THREAD_TRACE(l) KEYCACHE_DBUG_PRINT(l,(""))
-#define KEYCACHE_THREAD_TRACE_BEGIN(l) KEYCACHE_DBUG_PRINT(l,(""))
-#define KEYCACHE_THREAD_TRACE_END(l) KEYCACHE_DBUG_PRINT(l,(""))
-#endif /* THREAD */
#else
#define KEYCACHE_THREAD_TRACE_BEGIN(l)
#define KEYCACHE_THREAD_TRACE_END(l)
@@ -685,7 +674,6 @@ int prepare_resize_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
keycache_pthread_mutex_lock(&keycache->cache_lock);
-#ifdef THREAD
/*
We may need to wait for another thread which is doing a resize
already. This cannot happen in the MySQL server though. It allows
@@ -698,7 +686,6 @@ int prepare_resize_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
wait_on_queue(&keycache->resize_queue, &keycache->cache_lock);
/* purecov: end */
}
-#endif
/*
Mark the operation in progress. This blocks other threads from doing
@@ -727,7 +714,6 @@ int prepare_resize_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
keycache->resize_in_flush= 0;
}
-#ifdef THREAD
/*
Some direct read/write operations (bypassing the cache) may still be
unfinished. Wait until they are done. If the key cache can be used,
@@ -741,9 +727,6 @@ int prepare_resize_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
*/
while (keycache->cnt_for_resize_op)
wait_on_queue(&keycache->waiting_for_resize_cnt, &keycache->cache_lock);
-#else
- KEYCACHE_DBUG_ASSERT(keycache->cnt_for_resize_op == 0);
-#endif
end_simple_key_cache(keycache, 0);
@@ -1022,8 +1005,6 @@ void end_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache, my_bool cleanup)
} /* end_key_cache */
-#ifdef THREAD
-
/*
Link a thread into double-linked queue of waiting threads.
@@ -1203,8 +1184,6 @@ static void release_whole_queue(KEYCACHE_WQUEUE *wqueue)
wqueue->last_thread= NULL;
}
-#endif /* THREAD */
-
/*
Unlink a block from the chain of dirty/clean blocks
@@ -1376,7 +1355,6 @@ static void link_block(SIMPLE_KEY_CACHE_CB *keycache, BLOCK_LINK *block,
DBUG_ASSERT(block->prev_changed && *block->prev_changed == block);
DBUG_ASSERT(!block->next_used);
DBUG_ASSERT(!block->prev_used);
-#ifdef THREAD
if (!hot && keycache->waiting_for_block.last_thread)
{
/* Signal that in the LRU warm sub-chain an available block has appeared */
@@ -1436,10 +1414,6 @@ static void link_block(SIMPLE_KEY_CACHE_CB *keycache, BLOCK_LINK *block,
#endif
return;
}
-#else /* THREAD */
- KEYCACHE_DBUG_ASSERT(! (!hot && keycache->waiting_for_block.last_thread));
- /* Condition not transformed using DeMorgan, to keep the text identical */
-#endif /* THREAD */
pins= hot ? &keycache->used_ins : &keycache->used_last;
ins= *pins;
if (ins)
@@ -1662,12 +1636,8 @@ static void remove_reader(BLOCK_LINK *block)
DBUG_ASSERT(!block->next_used);
DBUG_ASSERT(!block->prev_used);
DBUG_ASSERT(block->hash_link->requests);
-#ifdef THREAD
if (! --block->hash_link->requests && block->condvar)
keycache_pthread_cond_signal(block->condvar);
-#else
- --block->hash_link->requests;
-#endif
}
@@ -1679,7 +1649,6 @@ static void remove_reader(BLOCK_LINK *block)
static void wait_for_readers(SIMPLE_KEY_CACHE_CB *keycache,
BLOCK_LINK *block)
{
-#ifdef THREAD
struct st_my_thread_var *thread= my_thread_var;
DBUG_ASSERT(block->status & (BLOCK_READ | BLOCK_IN_USE));
DBUG_ASSERT(!(block->status & (BLOCK_IN_FLUSH | BLOCK_CHANGED)));
@@ -1701,9 +1670,6 @@ static void wait_for_readers(SIMPLE_KEY_CACHE_CB *keycache,
keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock);
block->condvar= NULL;
}
-#else
- KEYCACHE_DBUG_ASSERT(block->hash_link->requests == 0);
-#endif
}
@@ -1733,7 +1699,6 @@ static void unlink_hash(SIMPLE_KEY_CACHE_CB *keycache, HASH_LINK *hash_link)
if ((*hash_link->prev= hash_link->next))
hash_link->next->prev= hash_link->prev;
hash_link->block= NULL;
-#ifdef THREAD
if (keycache->waiting_for_hash_link.last_thread)
{
/* Signal that a free hash link has appeared */
@@ -1769,9 +1734,6 @@ static void unlink_hash(SIMPLE_KEY_CACHE_CB *keycache, HASH_LINK *hash_link)
hash_link);
return;
}
-#else /* THREAD */
- KEYCACHE_DBUG_ASSERT(! (keycache->waiting_for_hash_link.last_thread));
-#endif /* THREAD */
hash_link->next= keycache->free_hash_list;
keycache->free_hash_list= hash_link;
}
@@ -1836,7 +1798,6 @@ restart:
}
else
{
-#ifdef THREAD
/* Wait for a free hash link */
struct st_my_thread_var *thread= my_thread_var;
KEYCACHE_PAGE page;
@@ -1850,9 +1811,6 @@ restart:
keycache_pthread_cond_wait(&thread->suspend,
&keycache->cache_lock);
thread->opt_info= NULL;
-#else
- KEYCACHE_DBUG_ASSERT(0);
-#endif
goto restart;
}
hash_link->file= file;
@@ -1972,7 +1930,6 @@ restart:
- block assigned but not yet read from file (invalid data).
*/
-#ifdef THREAD
if (keycache->in_resize)
{
/* This is a request during a resize operation */
@@ -2214,9 +2171,6 @@ restart:
}
DBUG_RETURN(0);
}
-#else /* THREAD */
- DBUG_ASSERT(!keycache->in_resize);
-#endif
if (page_status == PAGE_READ &&
(block->status & (BLOCK_IN_EVICTION | BLOCK_IN_SWITCH |
@@ -2346,7 +2300,6 @@ restart:
from the LRU ring.
*/
-#ifdef THREAD
if (! keycache->used_last)
{
/*
@@ -2379,9 +2332,6 @@ restart:
DBUG_ASSERT(!hash_link->block->next_used);
DBUG_ASSERT(!hash_link->block->prev_used);
}
-#else
- KEYCACHE_DBUG_ASSERT(keycache->used_last);
-#endif
/*
If we waited above, hash_link->block has been assigned by
link_block(). Otherwise it is still NULL. In the latter case
@@ -2868,11 +2818,6 @@ uchar *simple_key_cache_read(SIMPLE_KEY_CACHE_CB *keycache,
set_if_smaller(read_length, keycache->key_cache_block_size-offset);
KEYCACHE_DBUG_ASSERT(read_length > 0);
-#ifndef THREAD
- if (block_length > keycache->key_cache_block_size || offset)
- return_buffer=0;
-#endif
-
/* Request the cache block that matches file/pos. */
keycache->global_cache_r_requests++;
@@ -2931,9 +2876,6 @@ uchar *simple_key_cache_read(SIMPLE_KEY_CACHE_CB *keycache,
/* block status may have added BLOCK_ERROR in the above 'if'. */
if (!(block->status & BLOCK_ERROR))
{
-#ifndef THREAD
- if (! return_buffer)
-#endif
{
DBUG_ASSERT(block->status & (BLOCK_READ | BLOCK_IN_USE));
#if !defined(SERIALIZED_READ_FROM_CACHE)
@@ -2972,20 +2914,6 @@ uchar *simple_key_cache_read(SIMPLE_KEY_CACHE_CB *keycache,
break;
}
-#ifndef THREAD
- /* This is only true if we where able to read everything in one block */
- if (return_buffer)
- {
- if (MYSQL_KEYCACHE_READ_DONE_ENABLED())
- {
- MYSQL_KEYCACHE_READ_DONE((ulong) (keycache->blocks_used *
- keycache->key_cache_block_size),
- (ulong) (keycache->blocks_unused *
- keycache->key_cache_block_size));
- }
- DBUG_RETURN(block->buffer);
- }
-#endif
next_block:
buff+= read_length;
filepos+= read_length+offset;
@@ -4262,17 +4190,11 @@ restart:
if (!(block->status & (BLOCK_IN_EVICTION | BLOCK_IN_SWITCH |
BLOCK_REASSIGNED)))
{
- struct st_hash_link *next_hash_link;
- my_off_t next_diskpos;
- File next_file;
- uint next_status;
- uint hash_requests;
-
- LINT_INIT(next_hash_link);
- LINT_INIT(next_diskpos);
- LINT_INIT(next_file);
- LINT_INIT(next_status);
- LINT_INIT(hash_requests);
+ struct st_hash_link *UNINIT_VAR(next_hash_link);
+ my_off_t UNINIT_VAR(next_diskpos);
+ File UNINIT_VAR(next_file);
+ uint UNINIT_VAR(next_status);
+ uint UNINIT_VAR(hash_requests);
total_found++;
found++;
@@ -5488,10 +5410,6 @@ uchar *partitioned_key_cache_read(PARTITIONED_KEY_CACHE_CB *keycache,
DBUG_PRINT("enter", ("fd: %u pos: %lu length: %u",
(uint) file, (ulong) filepos, length));
-#ifndef THREAD
- if (block_length > keycache->key_cache_block_size || offset)
- return_buffer=0;
-#endif
/* Read data in key_cache_block_size increments */
do
@@ -5507,11 +5425,6 @@ uchar *partitioned_key_cache_read(PARTITIONED_KEY_CACHE_CB *keycache,
block_length, return_buffer);
if (ret_buff == 0)
DBUG_RETURN(0);
-#ifndef THREAD
- /* This is only true if we were able to read everything in one block */
- if (return_buffer)
- DBUG_RETURN(ret_buff);
-#endif
filepos+= r_length;
buff+= r_length;
offset= 0;