Commit 5c796096 authored by unknown's avatar unknown

Merge desktop.sanja.is.com.ua:/home/bell/mysql/bk/mysql-maria

into  desktop.sanja.is.com.ua:/home/bell/mysql/bk/work-maria-pagecache

parents 4b10971a 6ea0c5c7
...@@ -127,11 +127,10 @@ my_bool my_disable_flush_pagecache_blocks= 0; ...@@ -127,11 +127,10 @@ my_bool my_disable_flush_pagecache_blocks= 0;
(TYPE *) ((char *) (a) - offsetof(TYPE, MEMBER)) (TYPE *) ((char *) (a) - offsetof(TYPE, MEMBER))
/* types of condition variables */ /* types of condition variables */
#define COND_FOR_REQUESTED 0 #define COND_FOR_REQUESTED 0 /* queue of thread waiting for read operation */
#define COND_FOR_SAVED 1 #define COND_FOR_SAVED 1 /* queue of thread waiting for flush */
#define COND_FOR_WRLOCK 2 #define COND_FOR_WRLOCK 2 /* queue of write lock */
#define COND_FOR_COPY 3 #define COND_SIZE 3 /* number of COND_* queues */
#define COND_SIZE 4
typedef pthread_cond_t KEYCACHE_CONDVAR; typedef pthread_cond_t KEYCACHE_CONDVAR;
...@@ -296,8 +295,8 @@ struct st_pagecache_block_link ...@@ -296,8 +295,8 @@ struct st_pagecache_block_link
wqueue[COND_SIZE]; /* queues on waiting requests for new/old pages */ wqueue[COND_SIZE]; /* queues on waiting requests for new/old pages */
uint requests; /* number of requests for the block */ uint requests; /* number of requests for the block */
byte *buffer; /* buffer for the block page */ byte *buffer; /* buffer for the block page */
volatile uint status; /* state of the block */ uint status; /* state of the block */
volatile uint pins; /* pin counter */ uint pins; /* pin counter */
#ifdef PAGECACHE_DEBUG #ifdef PAGECACHE_DEBUG
PAGECACHE_PIN_INFO *pin_list; PAGECACHE_PIN_INFO *pin_list;
PAGECACHE_LOCK_INFO *lock_list; PAGECACHE_LOCK_INFO *lock_list;
...@@ -354,6 +353,20 @@ my_bool info_check_pin(PAGECACHE_BLOCK_LINK *block, ...@@ -354,6 +353,20 @@ my_bool info_check_pin(PAGECACHE_BLOCK_LINK *block,
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/*
Debug function which checks current lock/pin state and requested changes
SYNOPSIS
info_check_lock()
lock requested lock changes
pin requested pin changes
RETURN
0 - OK
1 - Error
*/
my_bool info_check_lock(PAGECACHE_BLOCK_LINK *block, my_bool info_check_lock(PAGECACHE_BLOCK_LINK *block,
enum pagecache_page_lock lock, enum pagecache_page_lock lock,
enum pagecache_page_pin pin) enum pagecache_page_pin pin)
...@@ -368,90 +381,58 @@ my_bool info_check_lock(PAGECACHE_BLOCK_LINK *block, ...@@ -368,90 +381,58 @@ my_bool info_check_lock(PAGECACHE_BLOCK_LINK *block,
case PAGECACHE_LOCK_LEFT_UNLOCKED: case PAGECACHE_LOCK_LEFT_UNLOCKED:
DBUG_ASSERT(pin == PAGECACHE_PIN_LEFT_UNPINNED); DBUG_ASSERT(pin == PAGECACHE_PIN_LEFT_UNPINNED);
if (info) if (info)
{ goto error;
DBUG_PRINT("info",
("info_check_lock: thread: 0x%lx block 0x%lx: %c : U->U",
(ulong)thread, (ulong)block, (info->write_lock?'W':'R')));
DBUG_RETURN(1);
}
break; break;
case PAGECACHE_LOCK_LEFT_READLOCKED: case PAGECACHE_LOCK_LEFT_READLOCKED:
DBUG_ASSERT(pin == PAGECACHE_PIN_LEFT_UNPINNED || DBUG_ASSERT(pin == PAGECACHE_PIN_LEFT_UNPINNED ||
pin == PAGECACHE_PIN_LEFT_PINNED); pin == PAGECACHE_PIN_LEFT_PINNED);
if (info == 0 || info->write_lock) if (info == 0 || info->write_lock)
{ goto error;
DBUG_PRINT("info",
("info_check_lock: thread: 0x%lx block 0x%lx: %c : R->R",
(ulong)thread, (ulong)block, (info?'W':'U')));
DBUG_RETURN(1);
}
break; break;
case PAGECACHE_LOCK_LEFT_WRITELOCKED: case PAGECACHE_LOCK_LEFT_WRITELOCKED:
DBUG_ASSERT(pin == PAGECACHE_PIN_LEFT_PINNED); DBUG_ASSERT(pin == PAGECACHE_PIN_LEFT_PINNED);
if (info == 0 || !info->write_lock) if (info == 0 || !info->write_lock)
{ goto error;
DBUG_PRINT("info",
("info_check_lock: thread: 0x%lx block 0x%lx: %c : W->W",
(ulong)thread, (ulong)block, (info?'R':'U')));
DBUG_RETURN(1);
}
break; break;
case PAGECACHE_LOCK_READ: case PAGECACHE_LOCK_READ:
DBUG_ASSERT(pin == PAGECACHE_PIN_LEFT_UNPINNED || DBUG_ASSERT(pin == PAGECACHE_PIN_LEFT_UNPINNED ||
pin == PAGECACHE_PIN); pin == PAGECACHE_PIN);
if (info != 0) if (info != 0)
{ goto error;
DBUG_PRINT("info",
("info_check_lock: thread: 0x%lx block 0x%lx: %c : U->R",
(ulong)thread, (ulong)block, (info->write_lock?'W':'R')));
DBUG_RETURN(1);
}
break; break;
case PAGECACHE_LOCK_WRITE: case PAGECACHE_LOCK_WRITE:
DBUG_ASSERT(pin == PAGECACHE_PIN); DBUG_ASSERT(pin == PAGECACHE_PIN);
if (info != 0) if (info != 0)
{ goto error;
DBUG_PRINT("info",
("info_check_lock: thread: 0x%lx block 0x%lx: %c : U->W",
(ulong)thread, (ulong)block, (info->write_lock?'W':'R')));
DBUG_RETURN(1);
}
break; break;
case PAGECACHE_LOCK_READ_UNLOCK: case PAGECACHE_LOCK_READ_UNLOCK:
DBUG_ASSERT(pin == PAGECACHE_PIN_LEFT_UNPINNED || DBUG_ASSERT(pin == PAGECACHE_PIN_LEFT_UNPINNED ||
pin == PAGECACHE_UNPIN); pin == PAGECACHE_UNPIN);
if (info == 0 || info->write_lock) if (info == 0 || info->write_lock)
{ goto error;
DBUG_PRINT("info",
("info_check_lock: thread: 0x%lx block 0x%lx: %c : R->U",
(ulong)thread, (ulong)block, (info?'W':'U')));
DBUG_RETURN(1);
}
break; break;
case PAGECACHE_LOCK_WRITE_UNLOCK: case PAGECACHE_LOCK_WRITE_UNLOCK:
DBUG_ASSERT(pin == PAGECACHE_UNPIN); DBUG_ASSERT(pin == PAGECACHE_UNPIN);
if (info == 0 || !info->write_lock) if (info == 0 || !info->write_lock)
{ goto error;
DBUG_PRINT("info",
("info_check_lock: thread: 0x%lx block 0x%lx: %c : W->U",
(ulong)thread, (ulong)block, (info?'R':'U')));
DBUG_RETURN(1);
}
break; break;
case PAGECACHE_LOCK_WRITE_TO_READ: case PAGECACHE_LOCK_WRITE_TO_READ:
DBUG_ASSERT(pin == PAGECACHE_PIN_LEFT_PINNED || DBUG_ASSERT(pin == PAGECACHE_PIN_LEFT_PINNED ||
pin == PAGECACHE_UNPIN); pin == PAGECACHE_UNPIN);
if (info == 0 || !info->write_lock) if (info == 0 || !info->write_lock)
{ goto error;
DBUG_PRINT("info",
("info_check_lock: thread: 0x%lx block 0x%lx: %c : W->U",
(ulong)thread, (ulong)block, (info?'R':'U')));
DBUG_RETURN(1);
}
break; break;
} }
DBUG_RETURN(0); DBUG_RETURN(0);
error:
DBUG_PRINT("info",
("info_check_lock: thread: 0x%lx block 0x%lx: info: %d wrt: %d,"
"to lock: %s, to pin: %s",
(ulong)thread, (ulong)block, test(info),
(info ? info->write_lock : 0),
page_cache_page_lock_str[lock],
page_cache_page_pin_str[pin]));
DBUG_RETURN(1);
} }
#endif #endif
...@@ -1629,7 +1610,8 @@ static void unlink_hash(PAGECACHE *pagecache, PAGECACHE_HASH_LINK *hash_link) ...@@ -1629,7 +1610,8 @@ static void unlink_hash(PAGECACHE *pagecache, PAGECACHE_HASH_LINK *hash_link)
/* /*
Get the hash link for the page if it is in the cache Get the hash link for the page if it is in the cache (do not put the
page in the cache if it is absent there)
SYNOPSIS SYNOPSIS
get_present_hash_link() get_present_hash_link()
...@@ -2982,6 +2964,7 @@ my_bool pagecache_delete_page(PAGECACHE *pagecache, ...@@ -2982,6 +2964,7 @@ my_bool pagecache_delete_page(PAGECACHE *pagecache,
if (!link) if (!link)
{ {
DBUG_PRINT("info", ("There is no such page in the cache")); DBUG_PRINT("info", ("There is no such page in the cache"));
pagecache_pthread_mutex_unlock(&pagecache->cache_lock);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
block= link->block; block= link->block;
...@@ -2998,32 +2981,31 @@ my_bool pagecache_delete_page(PAGECACHE *pagecache, ...@@ -2998,32 +2981,31 @@ my_bool pagecache_delete_page(PAGECACHE *pagecache,
if (block->status & BLOCK_CHANGED && flush) if (block->status & BLOCK_CHANGED && flush)
{ {
if (flush) /* The block contains a dirty page - push it out of the cache */
{
/* The block contains a dirty page - push it out of the cache */
KEYCACHE_DBUG_PRINT("find_key_block", ("block is dirty")); KEYCACHE_DBUG_PRINT("find_key_block", ("block is dirty"));
pagecache_pthread_mutex_unlock(&pagecache->cache_lock); pagecache_pthread_mutex_unlock(&pagecache->cache_lock);
/* /*
The call is thread safe because only the current The call is thread safe because only the current
thread might change the block->hash_link value thread might change the block->hash_link value
*/ */
DBUG_ASSERT(block->pins == 1); DBUG_ASSERT(block->pins == 1);
error= pagecache_fwrite(pagecache, error= pagecache_fwrite(pagecache,
&block->hash_link->file, &block->hash_link->file,
block->buffer, block->buffer,
block->hash_link->pageno, block->hash_link->pageno,
block->type, block->type,
MYF(MY_NABP | MY_WAIT_IF_FULL)); MYF(MY_NABP | MY_WAIT_IF_FULL));
pagecache_pthread_mutex_lock(&pagecache->cache_lock); pagecache_pthread_mutex_lock(&pagecache->cache_lock);
pagecache->global_cache_write++; pagecache->global_cache_write++;
if (error)
{ if (error)
block->status|= BLOCK_ERROR; {
goto err; block->status|= BLOCK_ERROR;
} goto err;
} }
pagecache->blocks_changed--; pagecache->blocks_changed--;
pagecache->global_blocks_changed--; pagecache->global_blocks_changed--;
/* /*
......
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