Commit fce0e6a0 authored by unknown's avatar unknown

Pagecache callbacks support added.

Page CRC check based on pagecache support added.
Loghandler pagecache callbacks support added.
Loghandler filecache rewritten.
Support of deletting all logs added.


storage/maria/Makefile.am:
  New file with functions for CRC calculation.
storage/maria/ma_bitmap.c:
  Page CRC support.
storage/maria/ma_blockrec.c:
  Removed code replaced by pagecache callbacks.
storage/maria/ma_check.c:
  Page CRC support.
storage/maria/ma_create.c:
  Page CRC support.
storage/maria/ma_loghandler.c:
  Pagecache callbacks support.
  New file cache support.
  Removing log files support.
storage/maria/ma_loghandler.h:
  CRC_LENGTH replaced with CRC_SIZE
storage/maria/ma_open.c:
  Page CRC support.
storage/maria/ma_page.c:
  Page CRC support.
storage/maria/ma_pagecache.c:
  Pagecache callbacks support.
storage/maria/ma_pagecache.h:
  Pagecache callbacks support.
storage/maria/ma_panic.c:
  Page CRC support.
storage/maria/maria_chk.c:
  Page CRC support.
storage/maria/maria_def.h:
  Page CRC support.
storage/maria/unittest/Makefile.am:
  New test of removing logs.
storage/maria/unittest/ma_maria_log_cleanup.c:
  Memory leack fixed.
storage/maria/unittest/ma_pagecache_consist.c:
  Pagecache callbacks support.
storage/maria/unittest/ma_pagecache_single.c:
  Pagecache callbacks support.
storage/maria/unittest/ma_test_loghandler-t.c:
  Fixed the test error processing.
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
  Fixed the test error processing.
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
  Fixed the test error processing.
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  Fixed the test error processing.
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  Fixed the test error processing.
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
  Fixed the test error processing.
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
  Pagecache callbacks support.
storage/maria/unittest/ma_test_loghandler_purge-t.c:
  Fixed the test error processing.
storage/maria/unittest/test_file.c:
  Removed unneeded sync.
parent eb14b3b0
...@@ -122,7 +122,8 @@ libmaria_a_SOURCES = ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c \ ...@@ -122,7 +122,8 @@ libmaria_a_SOURCES = ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c \
ma_rt_index.c ma_rt_key.c ma_rt_mbr.c ma_rt_split.c \ ma_rt_index.c ma_rt_key.c ma_rt_mbr.c ma_rt_split.c \
ma_sp_key.c ma_control_file.c ma_loghandler.c \ ma_sp_key.c ma_control_file.c ma_loghandler.c \
ma_pagecache.c ma_pagecaches.c \ ma_pagecache.c ma_pagecaches.c \
ma_checkpoint.c ma_recovery.c ma_commit.c ma_checkpoint.c ma_recovery.c ma_commit.c \
ma_pagecrc.c
CLEANFILES = test?.MA? FT?.MA? isam.log ma_test_all ma_rt_test.MA? sp_test.MA? CLEANFILES = test?.MA? FT?.MA? isam.log ma_test_all ma_rt_test.MA? sp_test.MA?
SUFFIXES = .sh SUFFIXES = .sh
......
...@@ -127,12 +127,6 @@ ...@@ -127,12 +127,6 @@
#define FULL_HEAD_PAGE 4 #define FULL_HEAD_PAGE 4
#define FULL_TAIL_PAGE 7 #define FULL_TAIL_PAGE 7
/* If we don't have page checksum enabled, the bitmap page ends with this */
uchar maria_bitmap_marker[4]=
{(uchar) 255, (uchar) 255, (uchar) 255, (uchar) 254};
uchar maria_normal_page_marker[4]=
{(uchar) 255, (uchar) 255, (uchar) 255, (uchar) 255};
static my_bool _ma_read_bitmap_page(MARIA_SHARE *share, static my_bool _ma_read_bitmap_page(MARIA_SHARE *share,
MARIA_FILE_BITMAP *bitmap, MARIA_FILE_BITMAP *bitmap,
ulonglong page); ulonglong page);
...@@ -144,6 +138,7 @@ static inline my_bool write_changed_bitmap(MARIA_SHARE *share, ...@@ -144,6 +138,7 @@ static inline my_bool write_changed_bitmap(MARIA_SHARE *share,
MARIA_FILE_BITMAP *bitmap) MARIA_FILE_BITMAP *bitmap)
{ {
DBUG_ASSERT(share->pagecache->block_size == bitmap->block_size); DBUG_ASSERT(share->pagecache->block_size == bitmap->block_size);
DBUG_ASSERT(bitmap->file.write_callback != 0);
return (pagecache_write(share->pagecache, return (pagecache_write(share->pagecache,
&bitmap->file, bitmap->page, 0, &bitmap->file, bitmap->page, 0,
(uchar*) bitmap->map, PAGECACHE_PLAIN_PAGE, (uchar*) bitmap->map, PAGECACHE_PLAIN_PAGE,
...@@ -185,7 +180,11 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file) ...@@ -185,7 +180,11 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file)
bitmap->file.file= file; bitmap->file.file= file;
bitmap->block_size= share->block_size; bitmap->block_size= share->block_size;
/* Size needs to be alligned on 6 */ pagecache_file_init(bitmap->file, &maria_page_crc_check_bitmap,
(share->options & HA_OPTION_PAGE_CHECKSUM ?
&maria_page_crc_set_normal :
&maria_page_filler_set_bitmap), share);
/* Size needs to be aligned on 6 */
aligned_bit_blocks= (share->block_size - PAGE_SUFFIX_SIZE) / 6; aligned_bit_blocks= (share->block_size - PAGE_SUFFIX_SIZE) / 6;
bitmap->total_size= aligned_bit_blocks * 6; bitmap->total_size= aligned_bit_blocks * 6;
/* /*
...@@ -290,8 +289,6 @@ void _ma_bitmap_delete_all(MARIA_SHARE *share) ...@@ -290,8 +289,6 @@ void _ma_bitmap_delete_all(MARIA_SHARE *share)
if (bitmap->map) /* Not in create */ if (bitmap->map) /* Not in create */
{ {
bzero(bitmap->map, bitmap->block_size); bzero(bitmap->map, bitmap->block_size);
memcpy(bitmap->map + bitmap->block_size - sizeof(maria_bitmap_marker),
maria_bitmap_marker, sizeof(maria_bitmap_marker));
bitmap->changed= 1; bitmap->changed= 1;
bitmap->page= 0; bitmap->page= 0;
bitmap->used_size= bitmap->total_size; bitmap->used_size= bitmap->total_size;
...@@ -616,8 +613,6 @@ static my_bool _ma_read_bitmap_page(MARIA_SHARE *share, ...@@ -616,8 +613,6 @@ static my_bool _ma_read_bitmap_page(MARIA_SHARE *share,
*/ */
share->state.state.data_file_length= end_of_page; share->state.state.data_file_length= end_of_page;
bzero(bitmap->map, bitmap->block_size); bzero(bitmap->map, bitmap->block_size);
memcpy(bitmap->map + bitmap->block_size - sizeof(maria_bitmap_marker),
maria_bitmap_marker, sizeof(maria_bitmap_marker));
bitmap->used_size= 0; bitmap->used_size= 0;
#ifndef DBUG_OFF #ifndef DBUG_OFF
memcpy(bitmap->map + bitmap->block_size, bitmap->map, bitmap->block_size); memcpy(bitmap->map + bitmap->block_size, bitmap->map, bitmap->block_size);
...@@ -627,9 +622,9 @@ static my_bool _ma_read_bitmap_page(MARIA_SHARE *share, ...@@ -627,9 +622,9 @@ static my_bool _ma_read_bitmap_page(MARIA_SHARE *share,
bitmap->used_size= bitmap->total_size; bitmap->used_size= bitmap->total_size;
DBUG_ASSERT(share->pagecache->block_size == bitmap->block_size); DBUG_ASSERT(share->pagecache->block_size == bitmap->block_size);
res= pagecache_read(share->pagecache, res= pagecache_read(share->pagecache,
(PAGECACHE_FILE*)&bitmap->file, page, 0, &bitmap->file, page, 0,
(uchar*) bitmap->map, (uchar*) bitmap->map,
PAGECACHE_PLAIN_PAGE, PAGECACHE_PLAIN_PAGE,
PAGECACHE_LOCK_LEFT_UNLOCKED, 0) == NULL; PAGECACHE_LOCK_LEFT_UNLOCKED, 0) == NULL;
/* /*
...@@ -641,15 +636,6 @@ static my_bool _ma_read_bitmap_page(MARIA_SHARE *share, ...@@ -641,15 +636,6 @@ static my_bool _ma_read_bitmap_page(MARIA_SHARE *share,
when running without any checksums. when running without any checksums.
*/ */
if (!res && !(share->options & HA_OPTION_PAGE_CHECKSUM) &&
!memcmp(bitmap->map + bitmap->block_size -
sizeof(maria_normal_page_marker),
maria_normal_page_marker,
sizeof(maria_normal_page_marker)))
{
res= 1;
my_errno= HA_ERR_WRONG_IN_RECORD; /* File crashed */
}
#ifndef DBUG_OFF #ifndef DBUG_OFF
if (!res) if (!res)
memcpy(bitmap->map + bitmap->block_size, bitmap->map, bitmap->block_size); memcpy(bitmap->map + bitmap->block_size, bitmap->map, bitmap->block_size);
...@@ -2257,17 +2243,18 @@ int _ma_bitmap_create_first(MARIA_SHARE *share) ...@@ -2257,17 +2243,18 @@ int _ma_bitmap_create_first(MARIA_SHARE *share)
{ {
uint block_size= share->bitmap.block_size; uint block_size= share->bitmap.block_size;
File file= share->bitmap.file.file; File file= share->bitmap.file.file;
char marker[sizeof(maria_bitmap_marker)]; char marker[CRC_SIZE];
if (share->options & HA_OPTION_PAGE_CHECKSUM) /*
bzero(marker, sizeof(marker)); Next write operation of the page will write correct CRC
else if it is needed
bmove(marker, maria_bitmap_marker, sizeof(marker)); */
int4store(marker, MARIA_NO_CRC_BITMAP_PAGE);
if (my_chsize(file, block_size - sizeof(maria_bitmap_marker), if (my_chsize(file, block_size - sizeof(marker),
0, MYF(MY_WME)) || 0, MYF(MY_WME)) ||
my_pwrite(file, marker, sizeof(maria_bitmap_marker), my_pwrite(file, marker, sizeof(marker),
block_size - sizeof(maria_bitmap_marker), block_size - sizeof(marker),
MYF(MY_NABP | MY_WME))) MYF(MY_NABP | MY_WME)))
return 1; return 1;
share->state.state.data_file_length= block_size; share->state.state.data_file_length= block_size;
......
...@@ -1242,9 +1242,7 @@ static void make_empty_page(MARIA_HA *info, uchar *buff, uint page_type) ...@@ -1242,9 +1242,7 @@ static void make_empty_page(MARIA_HA *info, uchar *buff, uint page_type)
buff[DIR_FREE_OFFSET]= END_OF_DIR_FREE_LIST; buff[DIR_FREE_OFFSET]= END_OF_DIR_FREE_LIST;
int2store(buff + block_size - PAGE_SUFFIX_SIZE - DIR_ENTRY_SIZE, int2store(buff + block_size - PAGE_SUFFIX_SIZE - DIR_ENTRY_SIZE,
PAGE_HEADER_SIZE); PAGE_HEADER_SIZE);
if (!(info->s->options & HA_OPTION_PAGE_CHECKSUM))
bfill(buff + block_size - KEYPAGE_CHECKSUM_SIZE,
KEYPAGE_CHECKSUM_SIZE, (uchar) 255);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -1555,10 +1553,6 @@ static my_bool write_full_pages(MARIA_HA *info, ...@@ -1555,10 +1553,6 @@ static my_bool write_full_pages(MARIA_HA *info,
(data_size - copy_length) + PAGE_SUFFIX_SIZE); (data_size - copy_length) + PAGE_SUFFIX_SIZE);
#endif #endif
if (!(info->s->options & HA_OPTION_PAGE_CHECKSUM))
bfill(buff + block_size - KEYPAGE_CHECKSUM_SIZE,
KEYPAGE_CHECKSUM_SIZE, (uchar) 255);
DBUG_ASSERT(share->pagecache->block_size == block_size); DBUG_ASSERT(share->pagecache->block_size == block_size);
if (pagecache_write(share->pagecache, if (pagecache_write(share->pagecache,
&info->dfile, page, 0, &info->dfile, page, 0,
......
...@@ -2704,6 +2704,20 @@ int maria_sort_index(HA_CHECK *param, register MARIA_HA *info, char *name) ...@@ -2704,6 +2704,20 @@ int maria_sort_index(HA_CHECK *param, register MARIA_HA *info, char *name)
} /* maria_sort_index */ } /* maria_sort_index */
/**
@brief put CRC on the page
@param buff reference on the page buffer.
@param pos position of the page in the file.
@param length length of the page
*/
static void put_crc(char *buff, my_off_t pos, MARIA_SHARE *share)
{
maria_page_crc_set_index(buff, pos / share->block_size, (uchar*) share);
}
/* Sort records recursive using one index */ /* Sort records recursive using one index */
static int sort_one_index(HA_CHECK *param, MARIA_HA *info, static int sort_one_index(HA_CHECK *param, MARIA_HA *info,
...@@ -2781,6 +2795,7 @@ static int sort_one_index(HA_CHECK *param, MARIA_HA *info, ...@@ -2781,6 +2795,7 @@ static int sort_one_index(HA_CHECK *param, MARIA_HA *info,
/* Fill block with zero and write it to the new index file */ /* Fill block with zero and write it to the new index file */
length= _ma_get_page_used(share, buff); length= _ma_get_page_used(share, buff);
bzero((uchar*) buff+length,keyinfo->block_length-length); bzero((uchar*) buff+length,keyinfo->block_length-length);
put_crc(buff, new_page_pos, share);
if (my_pwrite(new_file,(uchar*) buff,(uint) keyinfo->block_length, if (my_pwrite(new_file,(uchar*) buff,(uint) keyinfo->block_length,
new_page_pos,MYF(MY_NABP | MY_WAIT_IF_FULL))) new_page_pos,MYF(MY_NABP | MY_WAIT_IF_FULL)))
{ {
...@@ -4869,9 +4884,13 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param, ...@@ -4869,9 +4884,13 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param,
DFLT_INIT_HITS, anc_buff)) DFLT_INIT_HITS, anc_buff))
DBUG_RETURN(1); DBUG_RETURN(1);
} }
else if (my_pwrite(share->kfile.file, anc_buff, else
(uint) keyinfo->block_length,filepos, param->myf_rw)) {
DBUG_RETURN(1); put_crc(anc_buff, filepos, share);
if (my_pwrite(share->kfile.file, anc_buff,
(uint) keyinfo->block_length, filepos, param->myf_rw))
DBUG_RETURN(1);
}
DBUG_DUMP("buff", anc_buff, _ma_get_page_used(share, anc_buff)); DBUG_DUMP("buff", anc_buff, _ma_get_page_used(share, anc_buff));
/* Write separator-key to block in next level */ /* Write separator-key to block in next level */
...@@ -4989,9 +5008,13 @@ int _ma_flush_pending_blocks(MARIA_SORT_PARAM *sort_param) ...@@ -4989,9 +5008,13 @@ int _ma_flush_pending_blocks(MARIA_SORT_PARAM *sort_param)
DFLT_INIT_HITS, key_block->buff)) DFLT_INIT_HITS, key_block->buff))
DBUG_RETURN(1); DBUG_RETURN(1);
} }
else if (my_pwrite(info->s->kfile.file, key_block->buff, else
(uint) keyinfo->block_length,filepos, myf_rw)) {
put_crc(key_block->buff, filepos, info->s);
if (my_pwrite(info->s->kfile.file, key_block->buff,
(uint) keyinfo->block_length,filepos, myf_rw))
DBUG_RETURN(1); DBUG_RETURN(1);
}
DBUG_DUMP("buff",key_block->buff,length); DBUG_DUMP("buff",key_block->buff,length);
nod_flag=1; nod_flag=1;
} }
...@@ -5576,6 +5599,14 @@ my_bool create_new_data_handle(MARIA_SORT_PARAM *param, File new_file) ...@@ -5576,6 +5599,14 @@ my_bool create_new_data_handle(MARIA_SORT_PARAM *param, File new_file)
DBUG_RETURN(1); DBUG_RETURN(1);
new_info= sort_info->new_info; new_info= sort_info->new_info;
pagecache_file_init(new_info->s->bitmap.file, &maria_page_crc_check_bitmap,
(new_info->s->options & HA_OPTION_PAGE_CHECKSUM ?
&maria_page_crc_set_normal :
&maria_page_filler_set_bitmap), new_info->s);
pagecache_file_init(new_info->dfile, &maria_page_crc_check_data,
(new_info->s->options & HA_OPTION_PAGE_CHECKSUM ?
&maria_page_crc_set_normal :
&maria_page_filler_set_normal), new_info->s);
change_data_file_descriptor(new_info, new_file); change_data_file_descriptor(new_info, new_file);
maria_lock_database(new_info, F_EXTRA_LCK); maria_lock_database(new_info, F_EXTRA_LCK);
if ((sort_info->param->testflag & T_UNPACK) && if ((sort_info->param->testflag & T_UNPACK) &&
......
...@@ -1042,6 +1042,10 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -1042,6 +1042,10 @@ int maria_create(const char *name, enum data_file_type datafile_type,
DROP+CREATE happened (applying REDOs to the wrong table). DROP+CREATE happened (applying REDOs to the wrong table).
*/ */
share.kfile.file= file; share.kfile.file= file;
pagecache_file_init(share.kfile, &maria_page_crc_check_index,
(share.options & HA_OPTION_PAGE_CHECKSUM ?
&maria_page_crc_set_index :
&maria_page_filler_set_normal), &share);
if (_ma_update_create_rename_lsn_sub(&share, lsn, FALSE)) if (_ma_update_create_rename_lsn_sub(&share, lsn, FALSE))
goto err; goto err;
my_free(log_data, MYF(0)); my_free(log_data, MYF(0));
...@@ -1234,6 +1238,10 @@ int _ma_initialize_data_file(MARIA_SHARE *share, File dfile) ...@@ -1234,6 +1238,10 @@ int _ma_initialize_data_file(MARIA_SHARE *share, File dfile)
{ {
share->bitmap.block_size= share->base.block_size; share->bitmap.block_size= share->base.block_size;
share->bitmap.file.file = dfile; share->bitmap.file.file = dfile;
pagecache_file_init(share->bitmap.file, &maria_page_crc_check_bitmap,
(share->options & HA_OPTION_PAGE_CHECKSUM ?
&maria_page_crc_set_normal :
&maria_page_filler_set_bitmap), share);
return _ma_bitmap_create_first(share); return _ma_bitmap_create_first(share);
} }
/* /*
......
This diff is collapsed.
...@@ -54,7 +54,6 @@ struct st_maria_handler; ...@@ -54,7 +54,6 @@ struct st_maria_handler;
/* Length of CRC at end of pages */ /* Length of CRC at end of pages */
#define ROW_EXTENT_PAGE_SIZE 5 #define ROW_EXTENT_PAGE_SIZE 5
#define ROW_EXTENT_COUNT_SIZE 2 #define ROW_EXTENT_COUNT_SIZE 2
#define CRC_LENGTH 4
/* Size of file id in logs */ /* Size of file id in logs */
#define FILEID_STORE_SIZE 2 #define FILEID_STORE_SIZE 2
/* Size of page reference in log */ /* Size of page reference in log */
......
...@@ -151,6 +151,10 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, int mode, ...@@ -151,6 +151,10 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, int mode,
info.errkey= -1; info.errkey= -1;
info.page_changed=1; info.page_changed=1;
info.keyread_buff= info.buff + share->base.max_key_block_length; info.keyread_buff= info.buff + share->base.max_key_block_length;
pagecache_file_init(info.dfile, &maria_page_crc_check_data,
(share->options & HA_OPTION_PAGE_CHECKSUM ?
&maria_page_crc_set_normal :
&maria_page_filler_set_normal), share);
bitmap_init(&info.changed_fields, changed_fields_bitmap, bitmap_init(&info.changed_fields, changed_fields_bitmap,
share->base.fields, 0); share->base.fields, 0);
if ((*share->init)(&info)) if ((*share->init)(&info))
...@@ -714,6 +718,10 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -714,6 +718,10 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
errpos= 5; errpos= 5;
share->kfile.file= kfile; share->kfile.file= kfile;
pagecache_file_init(share->kfile, &maria_page_crc_check_index,
(share->options & HA_OPTION_PAGE_CHECKSUM ?
&maria_page_crc_set_index :
&maria_page_filler_set_normal), share);
share->this_process=(ulong) getpid(); share->this_process=(ulong) getpid();
share->last_process= share->state.process; share->last_process= share->state.process;
share->base.key_parts=key_parts; share->base.key_parts=key_parts;
...@@ -1535,6 +1543,14 @@ int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share, ...@@ -1535,6 +1543,14 @@ int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share,
info->dfile.file= share->bitmap.file.file= info->dfile.file= share->bitmap.file.file=
my_open(share->data_file_name, share->mode | O_SHARE, my_open(share->data_file_name, share->mode | O_SHARE,
MYF(MY_WME)); MYF(MY_WME));
pagecache_file_init(share->bitmap.file, &maria_page_crc_check_bitmap,
(share->options & HA_OPTION_PAGE_CHECKSUM ?
&maria_page_crc_set_normal :
&maria_page_filler_set_bitmap), share);
pagecache_file_init(info->dfile, &maria_page_crc_check_data,
(share->options & HA_OPTION_PAGE_CHECKSUM ?
&maria_page_crc_set_normal :
&maria_page_filler_set_normal), share);
return info->dfile.file >= 0 ? 0 : 1; return info->dfile.file >= 0 ? 0 : 1;
} }
...@@ -1549,6 +1565,10 @@ int _ma_open_keyfile(MARIA_SHARE *share) ...@@ -1549,6 +1565,10 @@ int _ma_open_keyfile(MARIA_SHARE *share)
share->kfile.file= my_open(share->unique_file_name, share->kfile.file= my_open(share->unique_file_name,
share->mode | O_SHARE, share->mode | O_SHARE,
MYF(MY_WME)); MYF(MY_WME));
pagecache_file_init(share->kfile, &maria_page_crc_check_index,
(share->options & HA_OPTION_PAGE_CHECKSUM ?
&maria_page_crc_set_index :
&maria_page_filler_set_normal), share);
pthread_mutex_unlock(&share->intern_lock); pthread_mutex_unlock(&share->intern_lock);
return (share->kfile.file < 0); return (share->kfile.file < 0);
} }
......
...@@ -136,9 +136,6 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -136,9 +136,6 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
} }
#endif #endif
DBUG_ASSERT(share->pagecache->block_size == block_size); DBUG_ASSERT(share->pagecache->block_size == block_size);
if (!(share->options & HA_OPTION_PAGE_CHECKSUM))
bfill(buff + block_size - KEYPAGE_CHECKSUM_SIZE,
KEYPAGE_CHECKSUM_SIZE, (uchar) 255);
res= pagecache_write(share->pagecache, res= pagecache_write(share->pagecache,
&share->kfile, page / block_size, &share->kfile, page / block_size,
...@@ -247,7 +244,7 @@ int _ma_dispose(register MARIA_HA *info, my_off_t pos, my_bool page_not_read) ...@@ -247,7 +244,7 @@ int _ma_dispose(register MARIA_HA *info, my_off_t pos, my_bool page_not_read)
lock_method, pin_method, lock_method, pin_method,
PAGECACHE_WRITE_DELAY, &page_link.link, PAGECACHE_WRITE_DELAY, &page_link.link,
LSN_IMPOSSIBLE, LSN_IMPOSSIBLE,
0, share->keypage_header+8, 0, 0)) 0, share->keypage_header + 8))
result= 1; result= 1;
#ifdef IDENTICAL_PAGES_AFTER_RECOVERY #ifdef IDENTICAL_PAGES_AFTER_RECOVERY
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* /*
These functions handle page cacheing for Maria tables. These functions handle page caching for Maria tables.
One cache can handle many files. One cache can handle many files.
It must contain buffers of the same blocksize. It must contain buffers of the same blocksize.
...@@ -608,8 +608,18 @@ static uint pagecache_fwrite(PAGECACHE *pagecache, ...@@ -608,8 +608,18 @@ static uint pagecache_fwrite(PAGECACHE *pagecache,
/* TODO: integrate with page format */ /* TODO: integrate with page format */
lsn= lsn_korr(buffer + PAGE_LSN_OFFSET); lsn= lsn_korr(buffer + PAGE_LSN_OFFSET);
DBUG_ASSERT(LSN_VALID(lsn)); DBUG_ASSERT(LSN_VALID(lsn));
translog_flush(lsn); if (translog_flush(lsn))
DBUG_RETURN(1);
}
DBUG_PRINT("info", ("write_callback: 0x%lx data: 0x%lx",
(ulong) filedesc->write_callback,
(ulong) filedesc->callback_data));
if ((filedesc->write_callback)(buffer, pageno, filedesc->callback_data))
{
DBUG_PRINT("error", ("write callback problem"));
DBUG_RETURN(1);
} }
DBUG_RETURN(my_pwrite(filedesc->file, buffer, pagecache->block_size, DBUG_RETURN(my_pwrite(filedesc->file, buffer, pagecache->block_size,
(pageno)<<(pagecache->shift), flags)); (pageno)<<(pagecache->shift), flags));
} }
...@@ -2398,8 +2408,6 @@ static my_bool make_lock_and_pin(PAGECACHE *pagecache, ...@@ -2398,8 +2408,6 @@ static my_bool make_lock_and_pin(PAGECACHE *pagecache,
pagecache pointer to a page cache data structure pagecache pointer to a page cache data structure
block block to which buffer the data is to be read block block to which buffer the data is to be read
primary <-> the current thread will read the data primary <-> the current thread will read the data
validator validator of read from the disk data
validator_data pointer to the data need by the validator
RETURN VALUE RETURN VALUE
None None
...@@ -2413,9 +2421,7 @@ static my_bool make_lock_and_pin(PAGECACHE *pagecache, ...@@ -2413,9 +2421,7 @@ static my_bool make_lock_and_pin(PAGECACHE *pagecache,
static void read_block(PAGECACHE *pagecache, static void read_block(PAGECACHE *pagecache,
PAGECACHE_BLOCK_LINK *block, PAGECACHE_BLOCK_LINK *block,
my_bool primary, my_bool primary)
pagecache_disk_read_validator validator,
uchar* validator_data)
{ {
/* On entry cache_lock is locked */ /* On entry cache_lock is locked */
...@@ -2448,9 +2454,18 @@ static void read_block(PAGECACHE *pagecache, ...@@ -2448,9 +2454,18 @@ static void read_block(PAGECACHE *pagecache,
else else
block->status= PCBLOCK_READ; block->status= PCBLOCK_READ;
if (validator != NULL && DBUG_PRINT("info", ("read_callback: 0x%lx data: 0x%lx",
(*validator)(block->buffer, validator_data)) (ulong) block->hash_link->file.read_callback,
(ulong) block->hash_link->file.callback_data));
if ((*block->hash_link->file.read_callback)(block->buffer,
block->hash_link->pageno,
block->hash_link->
file.callback_data))
{
DBUG_PRINT("error", ("read callback problem"));
block->status|= PCBLOCK_ERROR; block->status|= PCBLOCK_ERROR;
}
DBUG_PRINT("read_block", DBUG_PRINT("read_block",
("primary request: new page in cache")); ("primary request: new page in cache"));
...@@ -2881,25 +2896,20 @@ void pagecache_unpin_by_link(PAGECACHE *pagecache, ...@@ -2881,25 +2896,20 @@ void pagecache_unpin_by_link(PAGECACHE *pagecache,
/* /*
Read a block of data from a cached file into a buffer; @brief Read a block of data from a cached file into a buffer;
SYNOPSIS @param pagecache pointer to a page cache data structure
pagecache_valid_read() @param file handler for the file for the block of data to be read
pagecache pointer to a page cache data structure @param pageno number of the block of data in the file
file handler for the file for the block of data to be read @param level determines the weight of the data
pageno number of the block of data in the file @param buff buffer to where the data must be placed
level determines the weight of the data @param type type of the page
buff buffer to where the data must be placed @param lock lock change
type type of the page @param link link to the page if we pin it
lock lock change
link link to the page if we pin it
validator validator of read from the disk data
validator_data pointer to the data need by the validator
RETURN VALUE @return address from where the data is placed if successful, 0 - otherwise.
Returns address from where the data is placed if successful, 0 - otherwise.
Pin will be chosen according to lock parameter (see lock_to_pin) @note Pin will be chosen according to lock parameter (see lock_to_pin)
*/ */
static enum pagecache_page_pin lock_to_pin[2][8]= static enum pagecache_page_pin lock_to_pin[2][8]=
{ {
...@@ -2925,16 +2935,14 @@ static enum pagecache_page_pin lock_to_pin[2][8]= ...@@ -2925,16 +2935,14 @@ static enum pagecache_page_pin lock_to_pin[2][8]=
} }
}; };
uchar *pagecache_valid_read(PAGECACHE *pagecache, uchar *pagecache_read(PAGECACHE *pagecache,
PAGECACHE_FILE *file, PAGECACHE_FILE *file,
pgcache_page_no_t pageno, pgcache_page_no_t pageno,
uint level, uint level,
uchar *buff, uchar *buff,
enum pagecache_page_type type, enum pagecache_page_type type,
enum pagecache_page_lock lock, enum pagecache_page_lock lock,
PAGECACHE_BLOCK_LINK **page_link, PAGECACHE_BLOCK_LINK **page_link)
pagecache_disk_read_validator validator,
uchar* validator_data)
{ {
int error= 0; int error= 0;
enum pagecache_page_pin pin= lock_to_pin[test(buff==0)][lock]; enum pagecache_page_pin pin= lock_to_pin[test(buff==0)][lock];
...@@ -2991,8 +2999,7 @@ uchar *pagecache_valid_read(PAGECACHE *pagecache, ...@@ -2991,8 +2999,7 @@ uchar *pagecache_valid_read(PAGECACHE *pagecache,
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 */
read_block(pagecache, block, read_block(pagecache, block,
(my_bool)(page_st == PAGE_TO_BE_READ), (my_bool)(page_st == PAGE_TO_BE_READ));
validator, validator_data);
DBUG_PRINT("info", ("read is done")); DBUG_PRINT("info", ("read is done"));
} }
...@@ -3309,9 +3316,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -3309,9 +3316,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
enum pagecache_write_mode write_mode, enum pagecache_write_mode write_mode,
PAGECACHE_BLOCK_LINK **page_link, PAGECACHE_BLOCK_LINK **page_link,
LSN first_REDO_LSN_for_page, LSN first_REDO_LSN_for_page,
uint offset, uint size, uint offset, uint size)
pagecache_disk_read_validator validator,
uchar* validator_data)
{ {
PAGECACHE_BLOCK_LINK *block= NULL; PAGECACHE_BLOCK_LINK *block= NULL;
PAGECACHE_BLOCK_LINK *fake_link; PAGECACHE_BLOCK_LINK *fake_link;
...@@ -3412,12 +3417,20 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -3412,12 +3417,20 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
memcpy(block->buffer + offset, buff, size); memcpy(block->buffer + offset, buff, size);
block->status= PCBLOCK_READ; block->status= PCBLOCK_READ;
/* /*
The validator can change the page content (removing page The read_callback can change the page content (removing page
protection) so it have to be called protection) so it have to be called
*/ */
if (validator != NULL && DBUG_PRINT("info", ("read_callback: 0x%lx data: 0x%lx",
(*validator)(block->buffer, validator_data)) (ulong) block->hash_link->file.read_callback,
(ulong) block->hash_link->file.callback_data));
if ((*block->hash_link->file.read_callback)(block->buffer,
block->hash_link->pageno,
block->hash_link->
file.callback_data))
{
DBUG_PRINT("error", ("read callback problem"));
block->status|= PCBLOCK_ERROR; block->status|= PCBLOCK_ERROR;
}
KEYCACHE_DBUG_PRINT("key_cache_insert", KEYCACHE_DBUG_PRINT("key_cache_insert",
("Page injection")); ("Page injection"));
#ifdef THREAD #ifdef THREAD
...@@ -3429,7 +3442,6 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -3429,7 +3442,6 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
} }
else else
{ {
DBUG_ASSERT(validator == 0 && validator_data == 0);
if (! (block->status & PCBLOCK_CHANGED)) if (! (block->status & PCBLOCK_CHANGED))
link_to_changed_list(pagecache, block); link_to_changed_list(pagecache, block);
......
...@@ -74,15 +74,20 @@ enum pagecache_write_mode ...@@ -74,15 +74,20 @@ enum pagecache_write_mode
PAGECACHE_WRITE_DONE PAGECACHE_WRITE_DONE
}; };
/* page number for maria */
typedef uint32 pgcache_page_no_t;
/* file descriptor for Maria */ /* file descriptor for Maria */
typedef struct st_pagecache_file typedef struct st_pagecache_file
{ {
File file; File file;
my_bool (*read_callback)(uchar *page, pgcache_page_no_t offset,
uchar *data);
my_bool (*write_callback)(uchar *page, pgcache_page_no_t offset,
uchar *data);
uchar *callback_data;
} PAGECACHE_FILE; } PAGECACHE_FILE;
/* page number for maria */
typedef uint32 pgcache_page_no_t;
/* declare structures that is used by st_pagecache */ /* declare structures that is used by st_pagecache */
struct st_pagecache_block_link; struct st_pagecache_block_link;
...@@ -94,8 +99,6 @@ typedef struct st_pagecache_hash_link PAGECACHE_HASH_LINK; ...@@ -94,8 +99,6 @@ typedef struct st_pagecache_hash_link PAGECACHE_HASH_LINK;
#include <wqueue.h> #include <wqueue.h>
typedef my_bool (*pagecache_disk_read_validator)(uchar *page, uchar *data);
#define PAGECACHE_CHANGED_BLOCKS_HASH 128 /* must be power of 2 */ #define PAGECACHE_CHANGED_BLOCKS_HASH 128 /* must be power of 2 */
#define PAGECACHE_PRIORITY_LOW 0 #define PAGECACHE_PRIORITY_LOW 0
#define PAGECACHE_PRIORITY_DEFAULT 3 #define PAGECACHE_PRIORITY_DEFAULT 3
...@@ -192,26 +195,21 @@ extern ulong resize_pagecache(PAGECACHE *pagecache, ...@@ -192,26 +195,21 @@ extern ulong resize_pagecache(PAGECACHE *pagecache,
extern void change_pagecache_param(PAGECACHE *pagecache, uint division_limit, extern void change_pagecache_param(PAGECACHE *pagecache, uint division_limit,
uint age_threshold); uint age_threshold);
#define pagecache_read(P,F,N,L,B,T,K,I) \ extern uchar *pagecache_read(PAGECACHE *pagecache,
pagecache_valid_read(P,F,N,L,B,T,K,I,0,0) PAGECACHE_FILE *file,
pgcache_page_no_t pageno,
extern uchar *pagecache_valid_read(PAGECACHE *pagecache, uint level,
PAGECACHE_FILE *file, uchar *buff,
pgcache_page_no_t pageno, enum pagecache_page_type type,
uint level, enum pagecache_page_lock lock,
uchar *buff, PAGECACHE_BLOCK_LINK **link);
enum pagecache_page_type type,
enum pagecache_page_lock lock,
PAGECACHE_BLOCK_LINK **link,
pagecache_disk_read_validator validator,
uchar* validator_data);
#define pagecache_write(P,F,N,L,B,T,O,I,M,K,R) \ #define pagecache_write(P,F,N,L,B,T,O,I,M,K,R) \
pagecache_write_part(P,F,N,L,B,T,O,I,M,K,R,0,(P)->block_size,0,0) pagecache_write_part(P,F,N,L,B,T,O,I,M,K,R,0,(P)->block_size)
#define pagecache_inject(P,F,N,L,B,T,O,I,K,R,V,D) \ #define pagecache_inject(P,F,N,L,B,T,O,I,K,R) \
pagecache_write_part(P,F,N,L,B,T,O,I,PAGECACHE_WRITE_DONE, \ pagecache_write_part(P,F,N,L,B,T,O,I,PAGECACHE_WRITE_DONE, \
K,R,0,(P)->block_size,V,D) K,R,0,(P)->block_size)
extern my_bool pagecache_write_part(PAGECACHE *pagecache, extern my_bool pagecache_write_part(PAGECACHE *pagecache,
PAGECACHE_FILE *file, PAGECACHE_FILE *file,
...@@ -225,9 +223,7 @@ extern my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -225,9 +223,7 @@ extern my_bool pagecache_write_part(PAGECACHE *pagecache,
PAGECACHE_BLOCK_LINK **link, PAGECACHE_BLOCK_LINK **link,
LSN first_REDO_LSN_for_page, LSN first_REDO_LSN_for_page,
uint offset, uint offset,
uint size, uint size);
pagecache_disk_read_validator validator,
uchar* validator_data);
extern void pagecache_unlock(PAGECACHE *pagecache, extern void pagecache_unlock(PAGECACHE *pagecache,
PAGECACHE_FILE *file, PAGECACHE_FILE *file,
pgcache_page_no_t pageno, pgcache_page_no_t pageno,
...@@ -261,6 +257,11 @@ extern void pagecache_unpin_by_link(PAGECACHE *pagecache, ...@@ -261,6 +257,11 @@ extern void pagecache_unpin_by_link(PAGECACHE *pagecache,
/* PCFLUSH_ERROR and PCFLUSH_PINNED. */ /* PCFLUSH_ERROR and PCFLUSH_PINNED. */
#define PCFLUSH_PINNED_AND_ERROR (PCFLUSH_ERROR|PCFLUSH_PINNED) #define PCFLUSH_PINNED_AND_ERROR (PCFLUSH_ERROR|PCFLUSH_PINNED)
#define pagecache_file_init(F,RC,WC,D) \
do{ \
(F).read_callback= (RC); (F).write_callback= (WC); \
(F).callback_data= (uchar*)(D); \
} while(0)
#define flush_pagecache_blocks(A,B,C) \ #define flush_pagecache_blocks(A,B,C) \
flush_pagecache_blocks_with_filter(A,B,C,NULL,NULL) flush_pagecache_blocks_with_filter(A,B,C,NULL,NULL)
......
...@@ -99,12 +99,19 @@ int maria_panic(enum ha_panic_function flag) ...@@ -99,12 +99,19 @@ int maria_panic(enum ha_panic_function flag)
{ /* Open closed files */ { /* Open closed files */
char name_buff[FN_REFLEN]; char name_buff[FN_REFLEN];
if (info->s->kfile.file < 0) if (info->s->kfile.file < 0)
{
if ((info->s->kfile.file= my_open(fn_format(name_buff, if ((info->s->kfile.file= my_open(fn_format(name_buff,
info->filename, "", info->filename, "",
N_NAME_IEXT,4), N_NAME_IEXT,4),
info->mode, info->mode,
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
error = my_errno; error = my_errno;
pagecache_file_init(info->s->kfile, &maria_page_crc_check_index,
(info->s->options & HA_OPTION_PAGE_CHECKSUM ?
&maria_page_crc_set_index :
&maria_page_filler_set_normal), info->s);
}
if (info->dfile.file < 0) if (info->dfile.file < 0)
{ {
if ((info->dfile.file= my_open(fn_format(name_buff, info->filename, if ((info->dfile.file= my_open(fn_format(name_buff, info->filename,
...@@ -112,6 +119,10 @@ int maria_panic(enum ha_panic_function flag) ...@@ -112,6 +119,10 @@ int maria_panic(enum ha_panic_function flag)
info->mode, info->mode,
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
error = my_errno; error = my_errno;
pagecache_file_init(info->dfile, &maria_page_crc_check_data,
(share->options & HA_OPTION_PAGE_CHECKSUM ?
&maria_page_crc_set_normal:
&maria_page_filler_set_normal), share);
info->rec_cache.file= info->dfile.file; info->rec_cache.file= info->dfile.file;
} }
} }
......
...@@ -1670,6 +1670,10 @@ static int maria_sort_records(HA_CHECK *param, ...@@ -1670,6 +1670,10 @@ static int maria_sort_records(HA_CHECK *param,
VOID(my_close(info->dfile.file, MYF(MY_WME))); VOID(my_close(info->dfile.file, MYF(MY_WME)));
param->out_flag|=O_NEW_DATA; /* Data in new file */ param->out_flag|=O_NEW_DATA; /* Data in new file */
info->dfile.file= new_file; /* Use new datafile */ info->dfile.file= new_file; /* Use new datafile */
pagecache_file_init(info->dfile, &maria_page_crc_check_data,
(share->options & HA_OPTION_PAGE_CHECKSUM ?
&maria_page_crc_set_normal :
&maria_page_filler_set_normal), share);
info->state->del=0; info->state->del=0;
info->state->empty=0; info->state->empty=0;
share->state.dellink= HA_OFFSET_ERROR; share->state.dellink= HA_OFFSET_ERROR;
......
...@@ -44,7 +44,9 @@ ...@@ -44,7 +44,9 @@
struct st_transaction; struct st_transaction;
/* undef map from my_nosys; We need test-if-disk full */ /* undef map from my_nosys; We need test-if-disk full */
#undef my_write #undef my_write
#define CRC_SIZE 4
typedef struct st_maria_status_info typedef struct st_maria_status_info
{ {
...@@ -572,9 +574,19 @@ struct st_maria_handler ...@@ -572,9 +574,19 @@ struct st_maria_handler
#define _ma_store_keypage_flag(share,x,flag) x[(share)->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]= (flag) #define _ma_store_keypage_flag(share,x,flag) x[(share)->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]= (flag)
/*
TODO: write int4store_aligned as *((uint32 *) (T))= (uint32) (A) for
architectures where it is possible
*/
#define int4store_aligned(A,B) int4store((A),(B))
#define maria_mark_crashed(x) do{(x)->s->state.changed|= STATE_CRASHED; \ #define maria_mark_crashed(x) do{(x)->s->state.changed|= STATE_CRASHED; \
DBUG_PRINT("error", ("Marked table crashed")); \ DBUG_PRINT("error", ("Marked table crashed")); \
}while(0) }while(0)
#define maria_mark_crashed_share(x) \
do{(x)->state.changed|= STATE_CRASHED; \
DBUG_PRINT("error", ("Marked table crashed")); \
}while(0)
#define maria_mark_crashed_on_repair(x) do{(x)->s->state.changed|= \ #define maria_mark_crashed_on_repair(x) do{(x)->s->state.changed|= \
STATE_CRASHED|STATE_CRASHED_ON_REPAIR; \ STATE_CRASHED|STATE_CRASHED_ON_REPAIR; \
(x)->update|= HA_STATE_CHANGED; \ (x)->update|= HA_STATE_CHANGED; \
...@@ -1039,4 +1051,27 @@ void _ma_tmp_disable_logging_for_table(MARIA_HA *info, ...@@ -1039,4 +1051,27 @@ void _ma_tmp_disable_logging_for_table(MARIA_HA *info,
{ if (((S)->now_transactional= (S)->base.born_transactional)) \ { if (((S)->now_transactional= (S)->base.born_transactional)) \
(S)->page_type= PAGECACHE_LSN_PAGE; } (S)->page_type= PAGECACHE_LSN_PAGE; }
#define MARIA_NO_CRC_NORMAL_PAGE 0xffffffff
#define MARIA_NO_CRC_BITMAP_PAGE 0xfffffffe
extern my_bool maria_page_crc_set_index(uchar *page,
pgcache_page_no_t page_no,
uchar* data_ptr);
extern my_bool maria_page_crc_set_normal(uchar *page,
pgcache_page_no_t page_no,
uchar* data_ptr);
extern my_bool maria_page_crc_check_bitmap(uchar *page,
pgcache_page_no_t page_no,
uchar* data_ptr);
extern my_bool maria_page_crc_check_data(uchar *page,
pgcache_page_no_t page_no,
uchar* data_ptr);
extern my_bool maria_page_crc_check_index(uchar *page,
pgcache_page_no_t page_no,
uchar* data_ptr);
extern my_bool maria_page_filler_set_bitmap(uchar *page,
pgcache_page_no_t page_no,
uchar* data_ptr);
extern my_bool maria_page_filler_set_normal(uchar *page,
pgcache_page_no_t page_no,
uchar* data_ptr);
extern PAGECACHE *maria_log_pagecache; extern PAGECACHE *maria_log_pagecache;
...@@ -46,7 +46,8 @@ noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t \ ...@@ -46,7 +46,8 @@ noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t \
ma_test_loghandler_noflush-t \ ma_test_loghandler_noflush-t \
ma_test_loghandler_first_lsn-t \ ma_test_loghandler_first_lsn-t \
ma_test_loghandler_max_lsn-t \ ma_test_loghandler_max_lsn-t \
ma_test_loghandler_purge-t ma_test_loghandler_purge-t \
ma_test_loghandler_nologs-t
ma_test_loghandler_t_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c ma_test_loghandler_t_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
ma_test_loghandler_multigroup_t_SOURCES = ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c ma_test_loghandler_multigroup_t_SOURCES = ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
...@@ -58,6 +59,7 @@ ma_test_loghandler_noflush_t_SOURCES = ma_test_loghandler_noflush-t.c ma_maria_l ...@@ -58,6 +59,7 @@ ma_test_loghandler_noflush_t_SOURCES = ma_test_loghandler_noflush-t.c ma_maria_l
ma_test_loghandler_first_lsn_t_SOURCES = ma_test_loghandler_first_lsn-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c ma_test_loghandler_first_lsn_t_SOURCES = ma_test_loghandler_first_lsn-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
ma_test_loghandler_max_lsn_t_SOURCES = ma_test_loghandler_max_lsn-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c ma_test_loghandler_max_lsn_t_SOURCES = ma_test_loghandler_max_lsn-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
ma_test_loghandler_purge_t_SOURCES = ma_test_loghandler_purge-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c ma_test_loghandler_purge_t_SOURCES = ma_test_loghandler_purge-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
ma_test_loghandler_nologs_t_SOURCES = ma_test_loghandler_nologs-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
ma_pagecache_single_src = ma_pagecache_single.c test_file.c test_file.h ma_pagecache_single_src = ma_pagecache_single.c test_file.c test_file.h
ma_pagecache_consist_src = ma_pagecache_consist.c test_file.c test_file.h ma_pagecache_consist_src = ma_pagecache_consist.c test_file.c test_file.h
......
...@@ -37,9 +37,13 @@ my_bool maria_log_remove() ...@@ -37,9 +37,13 @@ my_bool maria_log_remove()
if (fn_format(file_name, file, if (fn_format(file_name, file,
maria_data_root, "", MYF(MY_WME)) == NullS || maria_data_root, "", MYF(MY_WME)) == NullS ||
my_delete(file_name, MYF(MY_WME)) != 0) my_delete(file_name, MYF(MY_WME)) != 0)
{
my_dirend(dirp);
return 1; return 1;
}
} }
} }
my_dirend(dirp);
return 0; return 0;
} }
...@@ -57,6 +57,18 @@ static uint flush_divider= 1000; ...@@ -57,6 +57,18 @@ static uint flush_divider= 1000;
#endif /*TEST_READERS*/ #endif /*TEST_READERS*/
#endif /*TEST_HIGH_CONCURENCY*/ #endif /*TEST_HIGH_CONCURENCY*/
/**
@brief Dummy pagecache callback.
*/
static my_bool
dummy_callback(__attribute__((unused)) uchar *page,
__attribute__((unused)) pgcache_page_no_t page_no,
__attribute__((unused)) uchar* data_ptr)
{
return 0;
}
/* /*
Get pseudo-random length of the field in (0;limit) Get pseudo-random length of the field in (0;limit)
...@@ -321,6 +333,7 @@ int main(int argc __attribute__((unused)), ...@@ -321,6 +333,7 @@ int main(int argc __attribute__((unused)),
errno); errno);
exit(1); exit(1);
} }
pagecache_file_init(file1, &dummy_callback, &dummy_callback, NULL);
DBUG_PRINT("info", ("file1: %d", file1.file)); DBUG_PRINT("info", ("file1: %d", file1.file));
if (chmod(file1_name, S_IRWXU | S_IRWXG | S_IRWXO) != 0) if (chmod(file1_name, S_IRWXU | S_IRWXG | S_IRWXO) != 0)
{ {
......
...@@ -60,6 +60,19 @@ static struct file_desc simple_delete_flush_test_file[]= ...@@ -60,6 +60,19 @@ static struct file_desc simple_delete_flush_test_file[]=
{ 0, 0} { 0, 0}
}; };
/**
@brief Dummy pagecache callback.
*/
static my_bool
dummy_callback(__attribute__((unused)) uchar *page,
__attribute__((unused)) pgcache_page_no_t page_no,
__attribute__((unused)) uchar* data_ptr)
{
return 0;
}
/* /*
Recreate and reopen a file for test Recreate and reopen a file for test
...@@ -496,7 +509,6 @@ int main(int argc __attribute__((unused)), ...@@ -496,7 +509,6 @@ int main(int argc __attribute__((unused)),
#endif #endif
DBUG_ENTER("main"); DBUG_ENTER("main");
DBUG_PRINT("info", ("Main thread: %s\n", my_thread_name())); DBUG_PRINT("info", ("Main thread: %s\n", my_thread_name()));
if ((tmp_file= my_open(file2_name, O_CREAT | O_TRUNC | O_RDWR, if ((tmp_file= my_open(file2_name, O_CREAT | O_TRUNC | O_RDWR,
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
exit(1); exit(1);
...@@ -508,6 +520,7 @@ int main(int argc __attribute__((unused)), ...@@ -508,6 +520,7 @@ int main(int argc __attribute__((unused)),
errno); errno);
exit(1); exit(1);
} }
pagecache_file_init(file1, &dummy_callback, &dummy_callback, NULL);
my_close(tmp_file, MYF(0)); my_close(tmp_file, MYF(0));
my_delete(file2_name, MYF(0)); my_delete(file2_name, MYF(0));
......
...@@ -179,7 +179,6 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -179,7 +179,6 @@ int main(int argc __attribute__((unused)), char *argv[])
if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS)) if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS))
{ {
fprintf(stderr, "Can't init loghandler (%d)\n", errno); fprintf(stderr, "Can't init loghandler (%d)\n", errno);
translog_destroy();
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
......
...@@ -69,7 +69,6 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -69,7 +69,6 @@ int main(int argc __attribute__((unused)), char *argv[])
if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS)) if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS))
{ {
fprintf(stderr, "Can't init loghandler (%d)\n", errno); fprintf(stderr, "Can't init loghandler (%d)\n", errno);
translog_destroy();
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
......
...@@ -63,7 +63,6 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -63,7 +63,6 @@ int main(int argc __attribute__((unused)), char *argv[])
if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS)) if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS))
{ {
fprintf(stderr, "Can't init loghandler (%d)\n", errno); fprintf(stderr, "Can't init loghandler (%d)\n", errno);
translog_destroy();
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
......
...@@ -176,7 +176,6 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -176,7 +176,6 @@ int main(int argc __attribute__((unused)), char *argv[])
if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, 0)) if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, 0))
{ {
fprintf(stderr, "Can't init loghandler (%d)\n", errno); fprintf(stderr, "Can't init loghandler (%d)\n", errno);
translog_destroy();
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
...@@ -341,7 +340,6 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -341,7 +340,6 @@ int main(int argc __attribute__((unused)), char *argv[])
if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, 0)) if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, 0))
{ {
fprintf(stderr, "pass2: Can't init loghandler (%d)\n", errno); fprintf(stderr, "pass2: Can't init loghandler (%d)\n", errno);
translog_destroy();
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
......
...@@ -286,7 +286,6 @@ int main(int argc __attribute__((unused)), ...@@ -286,7 +286,6 @@ int main(int argc __attribute__((unused)),
if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS)) if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS))
{ {
fprintf(stderr, "Can't init loghandler (%d)\n", errno); fprintf(stderr, "Can't init loghandler (%d)\n", errno);
translog_destroy();
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
......
...@@ -71,7 +71,6 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -71,7 +71,6 @@ int main(int argc __attribute__((unused)), char *argv[])
if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS)) if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS))
{ {
fprintf(stderr, "Can't init loghandler (%d)\n", errno); fprintf(stderr, "Can't init loghandler (%d)\n", errno);
translog_destroy();
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
......
...@@ -20,6 +20,19 @@ static char *first_translog_file= (char*)"maria_log.00000001"; ...@@ -20,6 +20,19 @@ static char *first_translog_file= (char*)"maria_log.00000001";
static char *file1_name= (char*)"page_cache_test_file_1"; static char *file1_name= (char*)"page_cache_test_file_1";
static PAGECACHE_FILE file1; static PAGECACHE_FILE file1;
/**
@brief Dummy pagecache callback.
*/
static my_bool
dummy_callback(__attribute__((unused)) uchar *page,
__attribute__((unused)) pgcache_page_no_t page_no,
__attribute__((unused)) uchar* data_ptr)
{
return 0;
}
int main(int argc __attribute__((unused)), char *argv[]) int main(int argc __attribute__((unused)), char *argv[])
{ {
uint pagen; uint pagen;
...@@ -71,7 +84,6 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -71,7 +84,6 @@ int main(int argc __attribute__((unused)), char *argv[])
if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS)) if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS))
{ {
fprintf(stderr, "Can't init loghandler (%d)\n", errno); fprintf(stderr, "Can't init loghandler (%d)\n", errno);
translog_destroy();
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
...@@ -112,6 +124,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -112,6 +124,7 @@ int main(int argc __attribute__((unused)), char *argv[])
errno); errno);
exit(1); exit(1);
} }
pagecache_file_init(file1, &dummy_callback, &dummy_callback, NULL);
if (chmod(file1_name, S_IRWXU | S_IRWXG | S_IRWXO) != 0) if (chmod(file1_name, S_IRWXU | S_IRWXG | S_IRWXO) != 0)
{ {
fprintf(stderr, "Got error during file1 chmod() (errno: %d)\n", fprintf(stderr, "Got error during file1 chmod() (errno: %d)\n",
......
...@@ -66,7 +66,6 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -66,7 +66,6 @@ int main(int argc __attribute__((unused)), char *argv[])
if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS)) if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS))
{ {
fprintf(stderr, "Can't init loghandler (%d)\n", errno); fprintf(stderr, "Can't init loghandler (%d)\n", errno);
translog_destroy();
exit(1); exit(1);
} }
example_loghandler_init(); example_loghandler_init();
......
...@@ -30,11 +30,6 @@ int test_file(PAGECACHE_FILE file, char *file_name, ...@@ -30,11 +30,6 @@ int test_file(PAGECACHE_FILE file, char *file_name,
int step= 0; int step= 0;
int res= 1; /* ok */ int res= 1; /* ok */
if (my_sync(file.file, MYF(MY_WME | MY_IGNORE_BADFD)))
{
diag("Got error during syncing file\n");
exit(1);
}
if ((stat= my_stat(file_name, &stat_buff, MYF(0))) == NULL) if ((stat= my_stat(file_name, &stat_buff, MYF(0))) == NULL)
{ {
diag("Can't stat() %s (errno: %d)\n", file_name, errno); diag("Can't stat() %s (errno: %d)\n", file_name, errno);
......
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