Commit 09cb2fe6 authored by unknown's avatar unknown

Postreview changes.


include/my_sys.h:
  The comments added.
include/pagecache.h:
  Functions names changed.
storage/maria/unittest/mf_pagecache_consist.c:
  Functions names changed.
storage/maria/unittest/mf_pagecache_single.c:
  Functions names changed.
parent 1f57759a
...@@ -280,7 +280,12 @@ enum cache_type ...@@ -280,7 +280,12 @@ enum cache_type
enum flush_type enum flush_type
{ {
FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE FLUSH_KEEP, /* flush block and keep it in the cache */
FLUSH_RELEASE, /* flush block and remove it from the cache */
FLUSH_IGNORE_CHANGED, /* remove block from the cache */
/* as my_disable_flush_pagecache_blocks is always 0, it is
strictly equivalent to FLUSH_KEEP */
FLUSH_FORCE_WRITE
}; };
typedef struct st_record_cache /* Used when cacheing records */ typedef struct st_record_cache /* Used when cacheing records */
......
...@@ -194,30 +194,30 @@ extern my_bool pagecache_write(PAGECACHE *pagecache, ...@@ -194,30 +194,30 @@ extern my_bool pagecache_write(PAGECACHE *pagecache,
enum pagecache_page_pin pin, enum pagecache_page_pin pin,
enum pagecache_write_mode write_mode, enum pagecache_write_mode write_mode,
PAGECACHE_PAGE_LINK *link); PAGECACHE_PAGE_LINK *link);
extern void pagecache_unlock_page(PAGECACHE *pagecache,
PAGECACHE_FILE *file,
pgcache_page_no_t pageno,
enum pagecache_page_lock lock,
enum pagecache_page_pin pin,
LSN first_REDO_LSN_for_page);
extern void pagecache_unlock(PAGECACHE *pagecache, extern void pagecache_unlock(PAGECACHE *pagecache,
PAGECACHE_PAGE_LINK *link, PAGECACHE_FILE *file,
pgcache_page_no_t pageno,
enum pagecache_page_lock lock, enum pagecache_page_lock lock,
enum pagecache_page_pin pin, enum pagecache_page_pin pin,
LSN first_REDO_LSN_for_page); LSN first_REDO_LSN_for_page);
extern void pagecache_unpin_page(PAGECACHE *pagecache, extern void pagecache_unlock_by_link(PAGECACHE *pagecache,
PAGECACHE_FILE *file, PAGECACHE_PAGE_LINK *link,
pgcache_page_no_t pageno); enum pagecache_page_lock lock,
enum pagecache_page_pin pin,
LSN first_REDO_LSN_for_page);
extern void pagecache_unpin(PAGECACHE *pagecache, extern void pagecache_unpin(PAGECACHE *pagecache,
PAGECACHE_PAGE_LINK *link); PAGECACHE_FILE *file,
pgcache_page_no_t pageno);
extern void pagecache_unpin_by_link(PAGECACHE *pagecache,
PAGECACHE_PAGE_LINK *link);
extern int flush_pagecache_blocks(PAGECACHE *keycache, extern int flush_pagecache_blocks(PAGECACHE *keycache,
PAGECACHE_FILE *file, PAGECACHE_FILE *file,
enum flush_type type); enum flush_type type);
extern my_bool pagecache_delete_page(PAGECACHE *pagecache, extern my_bool pagecache_delete(PAGECACHE *pagecache,
PAGECACHE_FILE *file, PAGECACHE_FILE *file,
pgcache_page_no_t pageno, pgcache_page_no_t pageno,
enum pagecache_page_lock lock, enum pagecache_page_lock lock,
my_bool flush); my_bool flush);
extern void end_pagecache(PAGECACHE *keycache, my_bool cleanup); extern void end_pagecache(PAGECACHE *keycache, my_bool cleanup);
extern my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, extern my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
LEX_STRING *str, LEX_STRING *str,
......
...@@ -773,7 +773,7 @@ int init_pagecache(PAGECACHE *pagecache, my_size_t use_mem, ...@@ -773,7 +773,7 @@ int init_pagecache(PAGECACHE *pagecache, my_size_t use_mem,
} }
pagecache->blocks= pagecache->disk_blocks > 0 ? pagecache->disk_blocks : 0; pagecache->blocks= pagecache->disk_blocks > 0 ? pagecache->disk_blocks : 0;
DBUG_RETURN((uint) pagecache->blocks); DBUG_RETURN((int) pagecache->disk_blocks);
err: err:
error= my_errno; error= my_errno;
...@@ -1578,7 +1578,10 @@ static PAGECACHE_HASH_LINK *get_present_hash_link(PAGECACHE *pagecache, ...@@ -1578,7 +1578,10 @@ static PAGECACHE_HASH_LINK *get_present_hash_link(PAGECACHE *pagecache,
/* Register the request for the page */ /* Register the request for the page */
hash_link->requests++; hash_link->requests++;
} }
/*
As soon as the caller will release the page cache's lock, "hash_link"
will be potentially obsolete (unusable) information.
*/
DBUG_RETURN(hash_link); DBUG_RETURN(hash_link);
} }
...@@ -2103,7 +2106,8 @@ static void info_change_lock(PAGECACHE_BLOCK_LINK *block, my_bool wl) ...@@ -2103,7 +2106,8 @@ static void info_change_lock(PAGECACHE_BLOCK_LINK *block, my_bool wl)
PAGECACHE_LOCK_INFO *info= PAGECACHE_LOCK_INFO *info=
(PAGECACHE_LOCK_INFO *)info_find((PAGECACHE_PIN_INFO *)block->lock_list, (PAGECACHE_LOCK_INFO *)info_find((PAGECACHE_PIN_INFO *)block->lock_list,
my_thread_var); my_thread_var);
DBUG_ASSERT(info != 0 && info->write_lock != wl); DBUG_ASSERT(info != 0);
DBUG_ASSERT(info->write_lock != wl);
info->write_lock= wl; info->write_lock= wl;
} }
#else #else
...@@ -2228,16 +2232,23 @@ static my_bool make_lock_and_pin(PAGECACHE *pagecache, ...@@ -2228,16 +2232,23 @@ static my_bool make_lock_and_pin(PAGECACHE *pagecache,
enum pagecache_page_pin pin) enum pagecache_page_pin pin)
{ {
DBUG_ENTER("make_lock_and_pin"); DBUG_ENTER("make_lock_and_pin");
DBUG_PRINT("enter", ("block: 0x%lx (%u), wrlock: %c pins: %u, lock %s, pin: %s",
(ulong)block, BLOCK_NUMBER(pagecache, block), DBUG_PRINT("enter", ("block: 0x%lx", (ulong)block));
((block->status & BLOCK_WRLOCK)?'Y':'N'), #ifndef DBUG_OFF
block->pins, if (block)
page_cache_page_lock_str[lock], {
page_cache_page_pin_str[pin])); DBUG_PRINT("enter", ("block %u wrlock: %c pins: %u, lock %s, pin: %s",
BLOCK_INFO(block); BLOCK_NUMBER(pagecache, block),
((block->status & BLOCK_WRLOCK)?'Y':'N'),
block->pins,
page_cache_page_lock_str[lock],
page_cache_page_pin_str[pin]));
BLOCK_INFO(block);
}
#endif
#ifdef PAGECACHE_DEBUG #ifdef PAGECACHE_DEBUG
DBUG_ASSERT(info_check_pin(block, pin) == 0 && DBUG_ASSERT(info_check_pin(block, pin) == 0);
info_check_lock(block, lock, pin) == 0); DBUG_ASSERT(info_check_lock(block, lock, pin) == 0);
#endif #endif
switch (lock) switch (lock)
{ {
...@@ -2291,7 +2302,10 @@ static my_bool make_lock_and_pin(PAGECACHE *pagecache, ...@@ -2291,7 +2302,10 @@ static my_bool make_lock_and_pin(PAGECACHE *pagecache,
DBUG_ASSERT(0); /* Never should happened */ DBUG_ASSERT(0); /* Never should happened */
} }
BLOCK_INFO(block); #ifndef DBUG_OFF
if (block)
BLOCK_INFO(block);
#endif
DBUG_RETURN(0); DBUG_RETURN(0);
retry: retry:
DBUG_PRINT("INFO", ("Retry block 0x%lx", (ulong)block)); DBUG_PRINT("INFO", ("Retry block 0x%lx", (ulong)block));
...@@ -2413,7 +2427,7 @@ static void read_block(PAGECACHE *pagecache, ...@@ -2413,7 +2427,7 @@ static void read_block(PAGECACHE *pagecache,
Unlock/unpin page and put LSN stamp if it need Unlock/unpin page and put LSN stamp if it need
SYNOPSIS SYNOPSIS
pagecache_unlock_page() pagecache_unlock()
pagecache pointer to a page cache data structure pagecache pointer to a page cache data structure
file handler for the file for the block of data to be read file handler for the file for the block of data to be read
pageno number of the block of data in the file pageno number of the block of data in the file
...@@ -2434,24 +2448,24 @@ static void read_block(PAGECACHE *pagecache, ...@@ -2434,24 +2448,24 @@ static void read_block(PAGECACHE *pagecache,
*/ */
void pagecache_unlock_page(PAGECACHE *pagecache, void pagecache_unlock(PAGECACHE *pagecache,
PAGECACHE_FILE *file, PAGECACHE_FILE *file,
pgcache_page_no_t pageno, pgcache_page_no_t pageno,
enum pagecache_page_lock lock, enum pagecache_page_lock lock,
enum pagecache_page_pin pin, enum pagecache_page_pin pin,
LSN first_REDO_LSN_for_page) LSN first_REDO_LSN_for_page)
{ {
PAGECACHE_BLOCK_LINK *block; PAGECACHE_BLOCK_LINK *block;
int page_st; int page_st;
DBUG_ENTER("pagecache_unlock_page"); DBUG_ENTER("pagecache_unlock");
DBUG_PRINT("enter", ("fd: %u page: %lu l%s p%s", DBUG_PRINT("enter", ("fd: %u page: %lu l%s p%s",
(uint) file->file, (ulong) pageno, (uint) file->file, (ulong) pageno,
page_cache_page_lock_str[lock], page_cache_page_lock_str[lock],
page_cache_page_pin_str[pin])); page_cache_page_pin_str[pin]));
/* we do not allow any lock/pin increasing here */ /* we do not allow any lock/pin increasing here */
DBUG_ASSERT(pin != PAGECACHE_PIN && DBUG_ASSERT(pin != PAGECACHE_PIN);
lock != PAGECACHE_LOCK_READ && DBUG_ASSERT(lock != PAGECACHE_LOCK_READ);
lock != PAGECACHE_LOCK_WRITE); DBUG_ASSERT(lock != PAGECACHE_LOCK_WRITE);
pagecache_pthread_mutex_lock(&pagecache->cache_lock); pagecache_pthread_mutex_lock(&pagecache->cache_lock);
/* /*
...@@ -2461,15 +2475,15 @@ void pagecache_unlock_page(PAGECACHE *pagecache, ...@@ -2461,15 +2475,15 @@ void pagecache_unlock_page(PAGECACHE *pagecache,
DBUG_ASSERT(pagecache->can_be_used); DBUG_ASSERT(pagecache->can_be_used);
inc_counter_for_resize_op(pagecache); inc_counter_for_resize_op(pagecache);
/* See NOTE for pagecache_unlock_page about registering requests */ /* See NOTE for pagecache_unlock about registering requests */
block= find_block(pagecache, file, pageno, 0, 0, block= find_block(pagecache, file, pageno, 0, 0,
test(pin == PAGECACHE_PIN_LEFT_UNPINNED), &page_st); test(pin == PAGECACHE_PIN_LEFT_UNPINNED), &page_st);
BLOCK_INFO(block); BLOCK_INFO(block);
DBUG_ASSERT(block != 0 && page_st == PAGE_READ); DBUG_ASSERT(block != 0 && page_st == PAGE_READ);
if (first_REDO_LSN_for_page) if (first_REDO_LSN_for_page)
{ {
DBUG_ASSERT(lock == PAGECACHE_LOCK_WRITE_UNLOCK && DBUG_ASSERT(lock == PAGECACHE_LOCK_WRITE_UNLOCK);
pin == PAGECACHE_UNPIN); DBUG_ASSERT(pin == PAGECACHE_UNPIN);
set_if_bigger(block->rec_lsn, first_REDO_LSN_for_page); set_if_bigger(block->rec_lsn, first_REDO_LSN_for_page);
} }
...@@ -2490,7 +2504,7 @@ void pagecache_unlock_page(PAGECACHE *pagecache, ...@@ -2490,7 +2504,7 @@ void pagecache_unlock_page(PAGECACHE *pagecache,
/* /*
Link the block into the LRU chain if it's the last submitted request Link the block into the LRU chain if it's the last submitted request
for the block and block will not be pinned. for the block and block will not be pinned.
See NOTE for pagecache_unlock_page about registering requests. See NOTE for pagecache_unlock about registering requests.
*/ */
if (pin != PAGECACHE_PIN_LEFT_PINNED) if (pin != PAGECACHE_PIN_LEFT_PINNED)
unreg_request(pagecache, block, 1); unreg_request(pagecache, block, 1);
...@@ -2507,19 +2521,19 @@ void pagecache_unlock_page(PAGECACHE *pagecache, ...@@ -2507,19 +2521,19 @@ void pagecache_unlock_page(PAGECACHE *pagecache,
Unpin page Unpin page
SYNOPSIS SYNOPSIS
pagecache_unpin_page() pagecache_unpin()
pagecache pointer to a page cache data structure pagecache pointer to a page cache data structure
file handler for the file for the block of data to be read file handler for the file for the block of data to be read
pageno number of the block of data in the file pageno number of the block of data in the file
*/ */
void pagecache_unpin_page(PAGECACHE *pagecache, void pagecache_unpin(PAGECACHE *pagecache,
PAGECACHE_FILE *file, PAGECACHE_FILE *file,
pgcache_page_no_t pageno) pgcache_page_no_t pageno)
{ {
PAGECACHE_BLOCK_LINK *block; PAGECACHE_BLOCK_LINK *block;
int page_st; int page_st;
DBUG_ENTER("pagecache_unpin_page"); DBUG_ENTER("pagecache_unpin");
DBUG_PRINT("enter", ("fd: %u page: %lu", DBUG_PRINT("enter", ("fd: %u page: %lu",
(uint) file->file, (ulong) pageno)); (uint) file->file, (ulong) pageno));
pagecache_pthread_mutex_lock(&pagecache->cache_lock); pagecache_pthread_mutex_lock(&pagecache->cache_lock);
...@@ -2530,9 +2544,10 @@ void pagecache_unpin_page(PAGECACHE *pagecache, ...@@ -2530,9 +2544,10 @@ void pagecache_unpin_page(PAGECACHE *pagecache,
DBUG_ASSERT(pagecache->can_be_used); DBUG_ASSERT(pagecache->can_be_used);
inc_counter_for_resize_op(pagecache); inc_counter_for_resize_op(pagecache);
/* See NOTE for pagecache_unlock_page about registering requests */ /* See NOTE for pagecache_unlock about registering requests */
block= find_block(pagecache, file, pageno, 0, 0, 0, &page_st); block= find_block(pagecache, file, pageno, 0, 0, 0, &page_st);
DBUG_ASSERT(block != 0 && page_st == PAGE_READ); DBUG_ASSERT(block != 0);
DBUG_ASSERT(page_st == PAGE_READ);
#ifndef DBUG_OFF #ifndef DBUG_OFF
if ( if (
...@@ -2558,7 +2573,7 @@ void pagecache_unpin_page(PAGECACHE *pagecache, ...@@ -2558,7 +2573,7 @@ void pagecache_unpin_page(PAGECACHE *pagecache,
/* /*
Link the block into the LRU chain if it's the last submitted request Link the block into the LRU chain if it's the last submitted request
for the block and block will not be pinned. for the block and block will not be pinned.
See NOTE for pagecache_unlock_page about registering requests See NOTE for pagecache_unlock about registering requests
*/ */
unreg_request(pagecache, block, 1); unreg_request(pagecache, block, 1);
...@@ -2575,7 +2590,7 @@ void pagecache_unpin_page(PAGECACHE *pagecache, ...@@ -2575,7 +2590,7 @@ void pagecache_unpin_page(PAGECACHE *pagecache,
(uses direct block/page pointer) (uses direct block/page pointer)
SYNOPSIS SYNOPSIS
pagecache_unlock() pagecache_unlock_by_link()
pagecache pointer to a page cache data structure pagecache pointer to a page cache data structure
link direct link to page (returned by read or write) link direct link to page (returned by read or write)
lock lock change lock lock change
...@@ -2583,14 +2598,14 @@ void pagecache_unpin_page(PAGECACHE *pagecache, ...@@ -2583,14 +2598,14 @@ void pagecache_unpin_page(PAGECACHE *pagecache,
first_REDO_LSN_for_page do not set it if it is zero first_REDO_LSN_for_page do not set it if it is zero
*/ */
void pagecache_unlock(PAGECACHE *pagecache, void pagecache_unlock_by_link(PAGECACHE *pagecache,
PAGECACHE_PAGE_LINK *link, PAGECACHE_PAGE_LINK *link,
enum pagecache_page_lock lock, enum pagecache_page_lock lock,
enum pagecache_page_pin pin, enum pagecache_page_pin pin,
LSN first_REDO_LSN_for_page) LSN first_REDO_LSN_for_page)
{ {
PAGECACHE_BLOCK_LINK *block= (PAGECACHE_BLOCK_LINK *)link; PAGECACHE_BLOCK_LINK *block= (PAGECACHE_BLOCK_LINK *)link;
DBUG_ENTER("pagecache_unlock"); DBUG_ENTER("pagecache_unlock_by_link");
DBUG_PRINT("enter", ("block: 0x%lx fd: %u page: %lu l%s p%s", DBUG_PRINT("enter", ("block: 0x%lx fd: %u page: %lu l%s p%s",
(ulong) block, (ulong) block,
(uint) block->hash_link->file.file, (uint) block->hash_link->file.file,
...@@ -2601,10 +2616,10 @@ void pagecache_unlock(PAGECACHE *pagecache, ...@@ -2601,10 +2616,10 @@ void pagecache_unlock(PAGECACHE *pagecache,
We do not allow any lock/pin increasing here and page can't be We do not allow any lock/pin increasing here and page can't be
unpinned because we use direct link. unpinned because we use direct link.
*/ */
DBUG_ASSERT(pin != PAGECACHE_PIN && DBUG_ASSERT(pin != PAGECACHE_PIN);
pin != PAGECACHE_PIN_LEFT_UNPINNED && DBUG_ASSERT(pin != PAGECACHE_PIN_LEFT_UNPINNED);
lock != PAGECACHE_LOCK_READ && DBUG_ASSERT(lock != PAGECACHE_LOCK_READ);
lock != PAGECACHE_LOCK_WRITE); DBUG_ASSERT(lock != PAGECACHE_LOCK_WRITE);
if (pin == PAGECACHE_PIN_LEFT_UNPINNED && if (pin == PAGECACHE_PIN_LEFT_UNPINNED &&
lock == PAGECACHE_LOCK_READ_UNLOCK) lock == PAGECACHE_LOCK_READ_UNLOCK)
{ {
...@@ -2626,16 +2641,16 @@ void pagecache_unlock(PAGECACHE *pagecache, ...@@ -2626,16 +2641,16 @@ void pagecache_unlock(PAGECACHE *pagecache,
pagecache_pthread_mutex_lock(&pagecache->cache_lock); pagecache_pthread_mutex_lock(&pagecache->cache_lock);
/* /*
As soon as we keep lock cache can be used, and we have lock bacause want As soon as we keep lock cache can be used, and we have lock because want
aunlock. unlock.
*/ */
DBUG_ASSERT(pagecache->can_be_used); DBUG_ASSERT(pagecache->can_be_used);
inc_counter_for_resize_op(pagecache); inc_counter_for_resize_op(pagecache);
if (first_REDO_LSN_for_page) if (first_REDO_LSN_for_page)
{ {
DBUG_ASSERT(lock == PAGECACHE_LOCK_WRITE_UNLOCK && DBUG_ASSERT(lock == PAGECACHE_LOCK_WRITE_UNLOCK);
pin == PAGECACHE_UNPIN); DBUG_ASSERT(pin == PAGECACHE_UNPIN);
set_if_bigger(block->rec_lsn, first_REDO_LSN_for_page); set_if_bigger(block->rec_lsn, first_REDO_LSN_for_page);
} }
...@@ -2646,7 +2661,7 @@ void pagecache_unlock(PAGECACHE *pagecache, ...@@ -2646,7 +2661,7 @@ void pagecache_unlock(PAGECACHE *pagecache,
#ifndef DBUG_OFF #ifndef DBUG_OFF
) )
{ {
DBUG_ASSERT(0); /* should not happend */ DBUG_ASSERT(0); /* should not happened */
} }
#else #else
; ;
...@@ -2656,7 +2671,7 @@ void pagecache_unlock(PAGECACHE *pagecache, ...@@ -2656,7 +2671,7 @@ void pagecache_unlock(PAGECACHE *pagecache,
/* /*
Link the block into the LRU chain if it's the last submitted request Link the block into the LRU chain if it's the last submitted request
for the block and block will not be pinned. for the block and block will not be pinned.
See NOTE for pagecache_unlock_page about registering requests. See NOTE for pagecache_unlock about registering requests.
*/ */
if (pin != PAGECACHE_PIN_LEFT_PINNED) if (pin != PAGECACHE_PIN_LEFT_PINNED)
unreg_request(pagecache, block, 1); unreg_request(pagecache, block, 1);
...@@ -2674,16 +2689,16 @@ void pagecache_unlock(PAGECACHE *pagecache, ...@@ -2674,16 +2689,16 @@ void pagecache_unlock(PAGECACHE *pagecache,
(uses direct block/page pointer) (uses direct block/page pointer)
SYNOPSIS SYNOPSIS
pagecache_unpin_page() pagecache_unpin_by_link()
pagecache pointer to a page cache data structure pagecache pointer to a page cache data structure
link direct link to page (returned by read or write) link direct link to page (returned by read or write)
*/ */
void pagecache_unpin(PAGECACHE *pagecache, void pagecache_unpin_by_link(PAGECACHE *pagecache,
PAGECACHE_PAGE_LINK *link) PAGECACHE_PAGE_LINK *link)
{ {
PAGECACHE_BLOCK_LINK *block= (PAGECACHE_BLOCK_LINK *)link; PAGECACHE_BLOCK_LINK *block= (PAGECACHE_BLOCK_LINK *)link;
DBUG_ENTER("pagecache_unpin"); DBUG_ENTER("pagecache_unpin_by_link");
DBUG_PRINT("enter", ("block: 0x%lx fd: %u page: %lu", DBUG_PRINT("enter", ("block: 0x%lx fd: %u page: %lu",
(ulong) block, (ulong) block,
(uint) block->hash_link->file.file, (uint) block->hash_link->file.file,
...@@ -2691,8 +2706,8 @@ void pagecache_unpin(PAGECACHE *pagecache, ...@@ -2691,8 +2706,8 @@ void pagecache_unpin(PAGECACHE *pagecache,
pagecache_pthread_mutex_lock(&pagecache->cache_lock); pagecache_pthread_mutex_lock(&pagecache->cache_lock);
/* /*
As soon as we keep lock cache can be used, and we have lock bacause want As soon as we keep lock cache can be used, and we have lock because want
aunlock. unlock.
*/ */
DBUG_ASSERT(pagecache->can_be_used); DBUG_ASSERT(pagecache->can_be_used);
...@@ -2712,7 +2727,7 @@ void pagecache_unpin(PAGECACHE *pagecache, ...@@ -2712,7 +2727,7 @@ void pagecache_unpin(PAGECACHE *pagecache,
#ifndef DBUG_OFF #ifndef DBUG_OFF
) )
{ {
DBUG_ASSERT(0); /* should not happend */ DBUG_ASSERT(0); /* should not happened */
} }
#else #else
; ;
...@@ -2722,7 +2737,7 @@ void pagecache_unpin(PAGECACHE *pagecache, ...@@ -2722,7 +2737,7 @@ void pagecache_unpin(PAGECACHE *pagecache,
/* /*
Link the block into the LRU chain if it's the last submitted request Link the block into the LRU chain if it's the last submitted request
for the block and block will not be pinned. for the block and block will not be pinned.
See NOTE for pagecache_unlock_page about registering requests. See NOTE for pagecache_unlock about registering requests.
*/ */
unreg_request(pagecache, block, 1); unreg_request(pagecache, block, 1);
...@@ -2751,9 +2766,9 @@ void pagecache_unpin(PAGECACHE *pagecache, ...@@ -2751,9 +2766,9 @@ void pagecache_unpin(PAGECACHE *pagecache,
validator_data pointer to the data need by the validator validator_data pointer to the data need by the validator
RETURN VALUE RETURN VALUE
Returns address from where the data is placed if sucessful, 0 - otherwise. Returns address from where the data is placed if successful, 0 - otherwise.
Pin will be choosen according to lock parameter (see lock_to_pin) Pin will be chosen according to lock parameter (see lock_to_pin)
*/ */
static enum pagecache_page_pin lock_to_pin[]= static enum pagecache_page_pin lock_to_pin[]=
{ {
...@@ -2811,7 +2826,7 @@ restart: ...@@ -2811,7 +2826,7 @@ restart:
inc_counter_for_resize_op(pagecache); inc_counter_for_resize_op(pagecache);
pagecache->global_cache_r_requests++; pagecache->global_cache_r_requests++;
/* See NOTE for pagecache_unlock_page about registering requests. */ /* See NOTE for pagecache_unlock about registering requests. */
block= find_block(pagecache, file, pageno, level, block= find_block(pagecache, file, pageno, level,
test(lock == PAGECACHE_LOCK_WRITE), test(lock == PAGECACHE_LOCK_WRITE),
test((pin == PAGECACHE_PIN_LEFT_UNPINNED) || test((pin == PAGECACHE_PIN_LEFT_UNPINNED) ||
...@@ -2820,7 +2835,7 @@ restart: ...@@ -2820,7 +2835,7 @@ restart:
DBUG_ASSERT(block->type == PAGECACHE_EMPTY_PAGE || DBUG_ASSERT(block->type == PAGECACHE_EMPTY_PAGE ||
block->type == type); block->type == type);
block->type= type; block->type= type;
if (block->status != BLOCK_ERROR && page_st != PAGE_READ) if (((block->status & BLOCK_ERROR) == 0) && (page_st != PAGE_READ))
{ {
DBUG_PRINT("info", ("read block 0x%lx", (ulong)block)); DBUG_PRINT("info", ("read block 0x%lx", (ulong)block));
/* The requested page is to be read into the block buffer */ /* The requested page is to be read into the block buffer */
...@@ -2859,7 +2874,7 @@ restart: ...@@ -2859,7 +2874,7 @@ restart:
/* /*
Link the block into the LRU chain if it's the last submitted request Link the block into the LRU chain if it's the last submitted request
for the block and block will not be pinned. for the block and block will not be pinned.
See NOTE for pagecache_unlock_page about registering requests. See NOTE for pagecache_unlock about registering requests.
*/ */
if (pin == PAGECACHE_PIN_LEFT_UNPINNED || pin == PAGECACHE_UNPIN) if (pin == PAGECACHE_PIN_LEFT_UNPINNED || pin == PAGECACHE_UNPIN)
unreg_request(pagecache, block, 1); unreg_request(pagecache, block, 1);
...@@ -2891,7 +2906,7 @@ no_key_cache: /* Key cache is not used */ ...@@ -2891,7 +2906,7 @@ no_key_cache: /* Key cache is not used */
Delete page from the buffer Delete page from the buffer
SYNOPSIS SYNOPSIS
pagecache_delete_page() pagecache_delete()
pagecache pointer to a page cache data structure pagecache pointer to a page cache data structure
file handler for the file for the block of data to be read file handler for the file for the block of data to be read
pageno number of the block of data in the file pageno number of the block of data in the file
...@@ -2906,15 +2921,15 @@ no_key_cache: /* Key cache is not used */ ...@@ -2906,15 +2921,15 @@ no_key_cache: /* Key cache is not used */
lock can be only PAGECACHE_LOCK_LEFT_WRITELOCKED (page was write locked lock can be only PAGECACHE_LOCK_LEFT_WRITELOCKED (page was write locked
before) or PAGECACHE_LOCK_WRITE (delete will write lock page before delete) before) or PAGECACHE_LOCK_WRITE (delete will write lock page before delete)
*/ */
my_bool pagecache_delete_page(PAGECACHE *pagecache, my_bool pagecache_delete(PAGECACHE *pagecache,
PAGECACHE_FILE *file, PAGECACHE_FILE *file,
pgcache_page_no_t pageno, pgcache_page_no_t pageno,
enum pagecache_page_lock lock, enum pagecache_page_lock lock,
my_bool flush) my_bool flush)
{ {
int error= 0; int error= 0;
enum pagecache_page_pin pin= lock_to_pin[lock]; enum pagecache_page_pin pin= lock_to_pin[lock];
DBUG_ENTER("pagecache_delete_page"); DBUG_ENTER("pagecache_delete");
DBUG_PRINT("enter", ("fd: %u page: %lu l%s p%s", DBUG_PRINT("enter", ("fd: %u page: %lu l%s p%s",
(uint) file->file, (ulong) pageno, (uint) file->file, (ulong) pageno,
page_cache_page_lock_str[lock], page_cache_page_lock_str[lock],
...@@ -2945,7 +2960,7 @@ restart: ...@@ -2945,7 +2960,7 @@ restart:
DBUG_RETURN(0); DBUG_RETURN(0);
} }
block= link->block; block= link->block;
/* See NOTE for pagecache_unlock_page about registering requests. */ /* See NOTE for pagecache_unlock about registering requests. */
if (pin == PAGECACHE_PIN) if (pin == PAGECACHE_PIN)
reg_requests(pagecache, block, 1); reg_requests(pagecache, block, 1);
DBUG_ASSERT(block != 0); DBUG_ASSERT(block != 0);
...@@ -3002,7 +3017,7 @@ restart: ...@@ -3002,7 +3017,7 @@ restart:
PAGECACHE_UNPIN); PAGECACHE_UNPIN);
DBUG_ASSERT(link->requests > 0); DBUG_ASSERT(link->requests > 0);
link->requests--; link->requests--;
/* See NOTE for pagecache_unlock_page about registering requests. */ /* See NOTE for pagecache_unlock about registering requests. */
free_block(pagecache, block); free_block(pagecache, block);
err: err:
...@@ -3025,7 +3040,7 @@ end: ...@@ -3025,7 +3040,7 @@ end:
file handler for the file to write data to file handler for the file to write data to
pageno number of the block of data in the file pageno number of the block of data in the file
level determines the weight of the data level determines the weight of the data
buff buffer to where the data must be placed buff buffer with the data
type type of the page type type of the page
lock lock change lock lock change
pin pin page pin pin page
...@@ -3049,7 +3064,7 @@ static struct write_lock_change write_lock_change_table[]= ...@@ -3049,7 +3064,7 @@ static struct write_lock_change write_lock_change_table[]=
{1, {1,
PAGECACHE_LOCK_WRITE, PAGECACHE_LOCK_WRITE,
PAGECACHE_LOCK_WRITE_UNLOCK} /*PAGECACHE_LOCK_LEFT_UNLOCKED*/, PAGECACHE_LOCK_WRITE_UNLOCK} /*PAGECACHE_LOCK_LEFT_UNLOCKED*/,
{0, /*unsupported*/ {0, /*unsupported (we can't write having the block read locked) */
PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_LOCK_LEFT_UNLOCKED,
PAGECACHE_LOCK_LEFT_UNLOCKED} /*PAGECACHE_LOCK_LEFT_READLOCKED*/, PAGECACHE_LOCK_LEFT_UNLOCKED} /*PAGECACHE_LOCK_LEFT_READLOCKED*/,
{0, PAGECACHE_LOCK_LEFT_WRITELOCKED, 0} /*PAGECACHE_LOCK_LEFT_WRITELOCKED*/, {0, PAGECACHE_LOCK_LEFT_WRITELOCKED, 0} /*PAGECACHE_LOCK_LEFT_WRITELOCKED*/,
...@@ -3057,7 +3072,7 @@ static struct write_lock_change write_lock_change_table[]= ...@@ -3057,7 +3072,7 @@ static struct write_lock_change write_lock_change_table[]=
PAGECACHE_LOCK_WRITE, PAGECACHE_LOCK_WRITE,
PAGECACHE_LOCK_WRITE_TO_READ} /*PAGECACHE_LOCK_READ*/, PAGECACHE_LOCK_WRITE_TO_READ} /*PAGECACHE_LOCK_READ*/,
{0, PAGECACHE_LOCK_WRITE, 0} /*PAGECACHE_LOCK_WRITE*/, {0, PAGECACHE_LOCK_WRITE, 0} /*PAGECACHE_LOCK_WRITE*/,
{0, /*unsupported*/ {0, /*unsupported (we can't write having the block read locked) */
PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_LOCK_LEFT_UNLOCKED,
PAGECACHE_LOCK_LEFT_UNLOCKED} /*PAGECACHE_LOCK_READ_UNLOCK*/, PAGECACHE_LOCK_LEFT_UNLOCKED} /*PAGECACHE_LOCK_READ_UNLOCK*/,
{1, {1,
...@@ -3065,7 +3080,7 @@ static struct write_lock_change write_lock_change_table[]= ...@@ -3065,7 +3080,7 @@ static struct write_lock_change write_lock_change_table[]=
PAGECACHE_LOCK_WRITE_UNLOCK } /*PAGECACHE_LOCK_WRITE_UNLOCK*/, PAGECACHE_LOCK_WRITE_UNLOCK } /*PAGECACHE_LOCK_WRITE_UNLOCK*/,
{1, {1,
PAGECACHE_LOCK_LEFT_WRITELOCKED, PAGECACHE_LOCK_LEFT_WRITELOCKED,
PAGECACHE_LOCK_WRITE_TO_READ}/*PAGECACHE_LOCK_WRITE_TO_READ*/ PAGECACHE_LOCK_WRITE_TO_READ} /*PAGECACHE_LOCK_WRITE_TO_READ*/
}; };
/* description of how to change pin before and after write */ /* description of how to change pin before and after write */
...@@ -3109,8 +3124,8 @@ my_bool pagecache_write(PAGECACHE *pagecache, ...@@ -3109,8 +3124,8 @@ my_bool pagecache_write(PAGECACHE *pagecache,
page_cache_page_lock_str[lock], page_cache_page_lock_str[lock],
page_cache_page_pin_str[pin], page_cache_page_pin_str[pin],
page_cache_page_write_mode_str[write_mode])); page_cache_page_write_mode_str[write_mode]));
DBUG_ASSERT(lock != PAGECACHE_LOCK_LEFT_READLOCKED && DBUG_ASSERT(lock != PAGECACHE_LOCK_LEFT_READLOCKED);
lock != PAGECACHE_LOCK_READ_UNLOCK); DBUG_ASSERT(lock != PAGECACHE_LOCK_READ_UNLOCK);
if (!link) if (!link)
link= &fake_link; link= &fake_link;
else else
...@@ -3147,7 +3162,7 @@ restart: ...@@ -3147,7 +3162,7 @@ restart:
inc_counter_for_resize_op(pagecache); inc_counter_for_resize_op(pagecache);
pagecache->global_cache_w_requests++; pagecache->global_cache_w_requests++;
/* See NOTE for pagecache_unlock_page about registering requests. */ /* See NOTE for pagecache_unlock about registering requests. */
block= find_block(pagecache, file, pageno, level, block= find_block(pagecache, file, pageno, level,
test(write_mode != PAGECACHE_WRITE_DONE && test(write_mode != PAGECACHE_WRITE_DONE &&
lock != PAGECACHE_LOCK_LEFT_WRITELOCKED && lock != PAGECACHE_LOCK_LEFT_WRITELOCKED &&
...@@ -3242,7 +3257,7 @@ restart: ...@@ -3242,7 +3257,7 @@ restart:
/* Unregister the request */ /* Unregister the request */
DBUG_ASSERT(block->hash_link->requests > 0); DBUG_ASSERT(block->hash_link->requests > 0);
block->hash_link->requests--; block->hash_link->requests--;
/* See NOTE for pagecache_unlock_page about registering requests. */ /* See NOTE for pagecache_unlock about registering requests. */
if (pin == PAGECACHE_PIN_LEFT_UNPINNED || pin == PAGECACHE_UNPIN) if (pin == PAGECACHE_PIN_LEFT_UNPINNED || pin == PAGECACHE_UNPIN)
unreg_request(pagecache, block, 1); unreg_request(pagecache, block, 1);
else else
...@@ -3851,8 +3866,8 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, ...@@ -3851,8 +3866,8 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
{ {
if (block->type != PAGECACHE_LSN_PAGE) if (block->type != PAGECACHE_LSN_PAGE)
continue; /* no need to store it in the checkpoint record */ continue; /* no need to store it in the checkpoint record */
DBUG_ASSERT((4 == sizeof(block->hash_link->file.file)) && DBUG_ASSERT((4 == sizeof(block->hash_link->file.file)));
(4 == sizeof(block->hash_link->pageno))); DBUG_ASSERT((4 == sizeof(block->hash_link->pageno)));
int4store(ptr, block->hash_link->file.file); int4store(ptr, block->hash_link->file.file);
ptr+= 4; ptr+= 4;
int4store(ptr, block->hash_link->pageno); int4store(ptr, block->hash_link->pageno);
......
...@@ -135,8 +135,8 @@ err: ...@@ -135,8 +135,8 @@ err:
DBUG_PRINT("err", ("try to flush")); DBUG_PRINT("err", ("try to flush"));
if (page_locked) if (page_locked)
{ {
pagecache_delete_page(&pagecache, &file1, page_no, pagecache_delete(&pagecache, &file1, page_no,
PAGECACHE_LOCK_LEFT_WRITELOCKED, 1); PAGECACHE_LOCK_LEFT_WRITELOCKED, 1);
} }
else else
{ {
......
...@@ -231,12 +231,12 @@ int simple_pin_test() ...@@ -231,12 +231,12 @@ int simple_pin_test()
ok((res= test(test_file(file1, file1_name, PAGE_SIZE*2, PAGE_SIZE*2, ok((res= test(test_file(file1, file1_name, PAGE_SIZE*2, PAGE_SIZE*2,
simple_pin_test_file1))), simple_pin_test_file1))),
"Simple pin page file with pin"); "Simple pin page file with pin");
pagecache_unlock_page(&pagecache, pagecache_unlock(&pagecache,
&file1, &file1,
0, 0,
PAGECACHE_LOCK_READ_UNLOCK, PAGECACHE_LOCK_READ_UNLOCK,
PAGECACHE_UNPIN, PAGECACHE_UNPIN,
0); 0);
if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE)) if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
{ {
diag("Got error in flush_pagecache_blocks\n"); diag("Got error in flush_pagecache_blocks\n");
...@@ -282,8 +282,8 @@ int simple_delete_forget_test() ...@@ -282,8 +282,8 @@ int simple_delete_forget_test()
PAGECACHE_PIN_LEFT_UNPINNED, PAGECACHE_PIN_LEFT_UNPINNED,
PAGECACHE_WRITE_DELAY, PAGECACHE_WRITE_DELAY,
0); 0);
pagecache_delete_page(&pagecache, &file1, 0, pagecache_delete(&pagecache, &file1, 0,
PAGECACHE_LOCK_WRITE, 0); PAGECACHE_LOCK_WRITE, 0);
flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE); flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE);
ok((res= test(test_file(file1, file1_name, PAGE_SIZE, PAGE_SIZE, ok((res= test(test_file(file1, file1_name, PAGE_SIZE, PAGE_SIZE,
simple_delete_forget_test_file))), simple_delete_forget_test_file))),
...@@ -324,8 +324,8 @@ int simple_delete_flush_test() ...@@ -324,8 +324,8 @@ int simple_delete_flush_test()
PAGECACHE_PIN_LEFT_PINNED, PAGECACHE_PIN_LEFT_PINNED,
PAGECACHE_WRITE_DELAY, PAGECACHE_WRITE_DELAY,
0); 0);
pagecache_delete_page(&pagecache, &file1, 0, pagecache_delete(&pagecache, &file1, 0,
PAGECACHE_LOCK_LEFT_WRITELOCKED, 1); PAGECACHE_LOCK_LEFT_WRITELOCKED, 1);
flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE); flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE);
ok((res= test(test_file(file1, file1_name, PAGE_SIZE, PAGE_SIZE, ok((res= test(test_file(file1, file1_name, PAGE_SIZE, PAGE_SIZE,
simple_delete_flush_test_file))), simple_delete_flush_test_file))),
......
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