Commit 80c1bba3 authored by unknown's avatar unknown

Many files:

  Added multiple key cache


myisam/mi_page.c:
  Added multiple key cache
myisam/mi_delete_all.c:
  Added multiple key cache
myisam/mi_extra.c:
  Added multiple key cache
myisam/mi_locking.c:
  Added multiple key cache
myisam/mi_panic.c:
  Added multiple key cache
myisam/mi_preload.c:
  Added multiple key cache
myisam/mi_check.c:
  Added multiple key cache
myisam/myisamchk.c:
  Added multiple key cache
myisam/myisamlog.c:
  Added multiple key cache
myisam/mi_close.c:
  Added multiple key cache
myisam/mi_test1.c:
  Added multiple key cache
myisam/mi_test2.c:
  Added multiple key cache
myisam/mi_test3.c:
  Added multiple key cache
isam/_page.c:
  Added multiple key cache
isam/_locking.c:
  Added multiple key cache
isam/panic.c:
  Added multiple key cache
isam/close.c:
  Added multiple key cache
isam/isamchk.c:
  Added multiple key cache
isam/test2.c:
  Added multiple key cache
isam/test3.c:
  Added multiple key cache
mysys/mf_keycache.c:
  Added multiple key cache
include/my_sys.h:
  Added multiple key cache
parent 0912871d
...@@ -248,6 +248,8 @@ extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io, ...@@ -248,6 +248,8 @@ extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
extern char wild_many,wild_one,wild_prefix; extern char wild_many,wild_one,wild_prefix;
extern const char *charsets_dir; extern const char *charsets_dir;
extern char *defaults_extra_file; extern char *defaults_extra_file;
extern void *dflt_keycache;
#define dflt_key_block_size DEFAULT_KEYCACHE_BLOCK_SIZE
typedef struct wild_file_pack /* Struct to hold info when selecting files */ typedef struct wild_file_pack /* Struct to hold info when selecting files */
{ {
...@@ -639,16 +641,21 @@ extern int flush_write_cache(RECORD_CACHE *info); ...@@ -639,16 +641,21 @@ extern int flush_write_cache(RECORD_CACHE *info);
extern long my_clock(void); extern long my_clock(void);
extern sig_handler sigtstp_handler(int signal_number); extern sig_handler sigtstp_handler(int signal_number);
extern void handle_recived_signals(void); extern void handle_recived_signals(void);
extern int init_key_cache(ulong use_mem); extern int init_key_cache(void **pkeycache,uint key_cache_block_size,
extern int resize_key_cache(ulong use_mem); ulong use_mem);
extern byte *key_cache_read(File file,my_off_t filepos,byte* buff,uint length, extern int resize_key_cache(void **pkeycache,ulong use_mem);
extern byte *key_cache_read(void *pkeycache,
File file,my_off_t filepos,byte* buff,uint length,
uint block_length,int return_buffer); uint block_length,int return_buffer);
extern int key_cache_insert(File file, my_off_t filepos, extern int key_cache_insert(void *pkeycache,
File file, my_off_t filepos,
byte *buff, uint length); byte *buff, uint length);
extern int key_cache_write(File file,my_off_t filepos,byte* buff,uint length, extern int key_cache_write(void *pkeycache,
File file,my_off_t filepos,byte* buff,uint length,
uint block_length,int force_write); uint block_length,int force_write);
extern int flush_key_blocks(int file, enum flush_type type); extern int flush_key_blocks(void *pkeycache,
extern void end_key_cache(void); int file, enum flush_type type);
extern void end_key_cache(void **pkeycache,my_bool cleanup);
extern sig_handler my_set_alarm_variable(int signo); extern sig_handler my_set_alarm_variable(int signo);
extern void my_string_ptr_sort(void *base,uint items,size_s size); extern void my_string_ptr_sort(void *base,uint items,size_s size);
extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements, extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
......
...@@ -50,7 +50,7 @@ int nisam_lock_database(N_INFO *info, int lock_type) ...@@ -50,7 +50,7 @@ int nisam_lock_database(N_INFO *info, int lock_type)
else else
count= --share->w_locks; count= --share->w_locks;
if (info->lock_type == F_WRLCK && !share->w_locks && if (info->lock_type == F_WRLCK && !share->w_locks &&
flush_key_blocks(share->kfile,FLUSH_KEEP)) flush_key_blocks(dflt_keycache,share->kfile,FLUSH_KEEP))
error=my_errno; error=my_errno;
if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
if (end_io_cache(&info->rec_cache)) if (end_io_cache(&info->rec_cache))
...@@ -329,7 +329,7 @@ int _nisam_test_if_changed(register N_INFO *info) ...@@ -329,7 +329,7 @@ int _nisam_test_if_changed(register N_INFO *info)
share->state.uniq != info->last_uniq) share->state.uniq != info->last_uniq)
{ /* Keyfile has changed */ { /* Keyfile has changed */
if (share->state.process != share->this_process) if (share->state.process != share->this_process)
VOID(flush_key_blocks(share->kfile,FLUSH_RELEASE)); VOID(flush_key_blocks(dflt_keycache,share->kfile,FLUSH_RELEASE));
share->last_process=share->state.process; share->last_process=share->state.process;
info->last_loop= share->state.loop; info->last_loop= share->state.loop;
info->last_uniq= share->state.uniq; info->last_uniq= share->state.uniq;
......
...@@ -27,7 +27,8 @@ uchar *_nisam_fetch_keypage(register N_INFO *info, N_KEYDEF *keyinfo, ...@@ -27,7 +27,8 @@ uchar *_nisam_fetch_keypage(register N_INFO *info, N_KEYDEF *keyinfo,
my_off_t page, uchar *buff, int return_buffer) my_off_t page, uchar *buff, int return_buffer)
{ {
uchar *tmp; uchar *tmp;
tmp=(uchar*) key_cache_read(info->s->kfile,page,(byte*) buff, tmp=(uchar*) key_cache_read(dflt_keycache,
info->s->kfile,page,(byte*) buff,
(uint) keyinfo->base.block_length, (uint) keyinfo->base.block_length,
(uint) keyinfo->base.block_length, (uint) keyinfo->base.block_length,
return_buffer); return_buffer);
...@@ -83,7 +84,8 @@ int _nisam_write_keypage(register N_INFO *info, register N_KEYDEF *keyinfo, ...@@ -83,7 +84,8 @@ int _nisam_write_keypage(register N_INFO *info, register N_KEYDEF *keyinfo,
length=keyinfo->base.block_length; length=keyinfo->base.block_length;
} }
#endif #endif
return (key_cache_write(info->s->kfile,page,(byte*) buff,length, return (key_cache_write(dflt_keycache,
info->s->kfile,page,(byte*) buff,length,
(uint) keyinfo->base.block_length, (uint) keyinfo->base.block_length,
(int) (info->lock_type != F_UNLCK))); (int) (info->lock_type != F_UNLCK)));
} /* nisam_write_keypage */ } /* nisam_write_keypage */
...@@ -99,7 +101,8 @@ int _nisam_dispose(register N_INFO *info, N_KEYDEF *keyinfo, my_off_t pos) ...@@ -99,7 +101,8 @@ int _nisam_dispose(register N_INFO *info, N_KEYDEF *keyinfo, my_off_t pos)
old_link=info->s->state.key_del[keynr]; old_link=info->s->state.key_del[keynr];
info->s->state.key_del[keynr]=(ulong) pos; info->s->state.key_del[keynr]=(ulong) pos;
DBUG_RETURN(key_cache_write(info->s->kfile,pos,(byte*) &old_link, DBUG_RETURN(key_cache_write(dflt_keycache,
info->s->kfile,pos,(byte*) &old_link,
sizeof(long), sizeof(long),
(uint) keyinfo->base.block_length, (uint) keyinfo->base.block_length,
(int) (info->lock_type != F_UNLCK))); (int) (info->lock_type != F_UNLCK)));
...@@ -126,7 +129,8 @@ ulong _nisam_new(register N_INFO *info, N_KEYDEF *keyinfo) ...@@ -126,7 +129,8 @@ ulong _nisam_new(register N_INFO *info, N_KEYDEF *keyinfo)
} }
else else
{ {
if (!key_cache_read(info->s->kfile,pos, if (!key_cache_read(dflt_keycache,
info->s->kfile,pos,
(byte*) &info->s->state.key_del[keynr], (byte*) &info->s->state.key_del[keynr],
(uint) sizeof(long), (uint) sizeof(long),
(uint) keyinfo->base.block_length,0)) (uint) keyinfo->base.block_length,0))
......
...@@ -56,7 +56,8 @@ int nisam_close(register N_INFO *info) ...@@ -56,7 +56,8 @@ int nisam_close(register N_INFO *info)
if (flag) if (flag)
{ {
if (share->kfile >= 0 && flush_key_blocks(share->kfile,FLUSH_RELEASE)) if (share->kfile >= 0 &&
flush_key_blocks(dflt_keycache,share->kfile,FLUSH_RELEASE))
error=my_errno; error=my_errno;
if (share->kfile >= 0 && my_close(share->kfile,MYF(0))) if (share->kfile >= 0 && my_close(share->kfile,MYF(0)))
error = my_errno; error = my_errno;
......
...@@ -516,7 +516,8 @@ static int nisamchk(my_string filename) ...@@ -516,7 +516,8 @@ static int nisamchk(my_string filename)
if (!rep_quick) if (!rep_quick)
{ {
if (testflag & T_EXTEND) if (testflag & T_EXTEND)
VOID(init_key_cache(use_buffers)); VOID(init_key_cache(&dflt_keycache,dflt_key_block_size,
use_buffers));
VOID(init_io_cache(&read_cache,datafile,(uint) read_buffer_length, VOID(init_io_cache(&read_cache,datafile,(uint) read_buffer_length,
READ_CACHE,share->pack.header_length,1, READ_CACHE,share->pack.header_length,1,
MYF(MY_WME))); MYF(MY_WME)));
...@@ -1459,7 +1460,7 @@ my_string name; ...@@ -1459,7 +1460,7 @@ my_string name;
printf("Data records: %lu\n",(ulong) share->state.records); printf("Data records: %lu\n",(ulong) share->state.records);
} }
VOID(init_key_cache(use_buffers)); VOID(init_key_cache(&dflt_keycache,dflt_key_block_size,use_buffers));
if (init_io_cache(&read_cache,info->dfile,(uint) read_buffer_length, if (init_io_cache(&read_cache,info->dfile,(uint) read_buffer_length,
READ_CACHE,share->pack.header_length,1,MYF(MY_WME))) READ_CACHE,share->pack.header_length,1,MYF(MY_WME)))
goto err; goto err;
...@@ -1887,12 +1888,12 @@ static void lock_memory(void) ...@@ -1887,12 +1888,12 @@ static void lock_memory(void)
static int flush_blocks(file) static int flush_blocks(file)
File file; File file;
{ {
if (flush_key_blocks(file,FLUSH_RELEASE)) if (flush_key_blocks(dflt_keycache,file,FLUSH_RELEASE))
{ {
print_error("%d when trying to write bufferts",my_errno); print_error("%d when trying to write bufferts",my_errno);
return(1); return(1);
} }
end_key_cache(); end_key_cache(&dflt_keycache,1);
return 0; return 0;
} /* flush_blocks */ } /* flush_blocks */
...@@ -1936,7 +1937,7 @@ int write_info; ...@@ -1936,7 +1937,7 @@ int write_info;
if (share->state.key_root[sort_key] == NI_POS_ERROR) if (share->state.key_root[sort_key] == NI_POS_ERROR)
DBUG_RETURN(0); /* Nothing to do */ DBUG_RETURN(0); /* Nothing to do */
init_key_cache(use_buffers); init_key_cache(&dflt_keycache,dflt_key_block_size,use_buffers);
if (init_io_cache(&info->rec_cache,-1,(uint) write_buffer_length, if (init_io_cache(&info->rec_cache,-1,(uint) write_buffer_length,
WRITE_CACHE,share->pack.header_length,1, WRITE_CACHE,share->pack.header_length,1,
MYF(MY_WME | MY_WAIT_IF_FULL))) MYF(MY_WME | MY_WAIT_IF_FULL)))
......
...@@ -48,7 +48,7 @@ int nisam_panic(enum ha_panic_function flag) ...@@ -48,7 +48,7 @@ int nisam_panic(enum ha_panic_function flag)
if (info->s->base.options & HA_OPTION_READ_ONLY_DATA) if (info->s->base.options & HA_OPTION_READ_ONLY_DATA)
break; break;
#endif #endif
if (flush_key_blocks(info->s->kfile,FLUSH_RELEASE)) if (flush_key_blocks(dflt_keycache,info->s->kfile,FLUSH_RELEASE))
error=my_errno; error=my_errno;
if (info->opt_flag & WRITE_CACHE_USED) if (info->opt_flag & WRITE_CACHE_USED)
if (flush_io_cache(&info->rec_cache)) if (flush_io_cache(&info->rec_cache))
......
...@@ -156,7 +156,7 @@ int main(int argc, char *argv[]) ...@@ -156,7 +156,7 @@ int main(int argc, char *argv[])
goto err; goto err;
printf("- Writing key:s\n"); printf("- Writing key:s\n");
if (key_cacheing) if (key_cacheing)
init_key_cache(IO_SIZE*16); /* Use a small cache */ init_key_cache(&dflt_keycache,dflt_key_block_size,IO_SIZE*16); /* Use a small cache */
if (locking) if (locking)
nisam_lock_database(file,F_WRLCK); nisam_lock_database(file,F_WRLCK);
if (write_cacheing) if (write_cacheing)
...@@ -674,7 +674,7 @@ int main(int argc, char *argv[]) ...@@ -674,7 +674,7 @@ int main(int argc, char *argv[])
puts("Locking used"); puts("Locking used");
if (use_blob) if (use_blob)
puts("blobs used"); puts("blobs used");
end_key_cache(); end_key_cache(&dflt_keycache,1);
if (blob_buffer) if (blob_buffer)
my_free(blob_buffer,MYF(0)); my_free(blob_buffer,MYF(0));
my_end(MY_CHECK_ERROR | MY_GIVE_INFO); my_end(MY_CHECK_ERROR | MY_GIVE_INFO);
......
...@@ -173,7 +173,7 @@ void start_test(int id) ...@@ -173,7 +173,7 @@ void start_test(int id)
exit(1); exit(1);
} }
if (key_cacheing && rnd(2) == 0) if (key_cacheing && rnd(2) == 0)
init_key_cache(65536L); init_key_cache(&dflt_keycache,dflt_key_block_size,65536L);
printf("Process %d, pid: %d\n",id,(int) getpid()); fflush(stdout); printf("Process %d, pid: %d\n",id,(int) getpid()); fflush(stdout);
for (error=i=0 ; i < tests && !error; i++) for (error=i=0 ; i < tests && !error; i++)
......
...@@ -230,7 +230,8 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) ...@@ -230,7 +230,8 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr)
if (next_link > info->state->key_file_length || if (next_link > info->state->key_file_length ||
next_link & (info->s->blocksize-1)) next_link & (info->s->blocksize-1))
DBUG_RETURN(1); DBUG_RETURN(1);
if (!(buff=key_cache_read(info->s->kfile, next_link, (byte*) info->buff, if (!(buff=key_cache_read(dflt_keycache,
info->s->kfile, next_link, (byte*) info->buff,
myisam_block_size, block_size, 1))) myisam_block_size, block_size, 1)))
DBUG_RETURN(1); DBUG_RETURN(1);
next_link=mi_sizekorr(buff); next_link=mi_sizekorr(buff);
...@@ -259,7 +260,8 @@ int chk_size(MI_CHECK *param, register MI_INFO *info) ...@@ -259,7 +260,8 @@ int chk_size(MI_CHECK *param, register MI_INFO *info)
if (!(param->testflag & T_SILENT)) puts("- check file-size"); if (!(param->testflag & T_SILENT)) puts("- check file-size");
flush_key_blocks(info->s->kfile, FLUSH_FORCE_WRITE); /* If called externally */ flush_key_blocks(dflt_keycache,
info->s->kfile, FLUSH_FORCE_WRITE); /* If called externally */
size=my_seek(info->s->kfile,0L,MY_SEEK_END,MYF(0)); size=my_seek(info->s->kfile,0L,MY_SEEK_END,MYF(0));
if ((skr=(my_off_t) info->state->key_file_length) != size) if ((skr=(my_off_t) info->state->key_file_length) != size)
...@@ -1119,7 +1121,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, ...@@ -1119,7 +1121,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
param->testflag|=T_REP; /* for easy checking */ param->testflag|=T_REP; /* for easy checking */
if (!param->using_global_keycache) if (!param->using_global_keycache)
VOID(init_key_cache(param->use_buffers)); VOID(init_key_cache(&dflt_keycache,dflt_key_block_size,
param->use_buffers));
if (init_io_cache(&param->read_cache,info->dfile, if (init_io_cache(&param->read_cache,info->dfile,
(uint) param->read_buffer_length, (uint) param->read_buffer_length,
...@@ -1477,13 +1480,13 @@ void lock_memory(MI_CHECK *param __attribute__((unused))) ...@@ -1477,13 +1480,13 @@ void lock_memory(MI_CHECK *param __attribute__((unused)))
int flush_blocks(MI_CHECK *param, File file) int flush_blocks(MI_CHECK *param, File file)
{ {
if (flush_key_blocks(file,FLUSH_RELEASE)) if (flush_key_blocks(dflt_keycache,file,FLUSH_RELEASE))
{ {
mi_check_print_error(param,"%d when trying to write bufferts",my_errno); mi_check_print_error(param,"%d when trying to write bufferts",my_errno);
return(1); return(1);
} }
if (!param->using_global_keycache) if (!param->using_global_keycache)
end_key_cache(); end_key_cache(&dflt_keycache,1);
return 0; return 0;
} /* flush_blocks */ } /* flush_blocks */
...@@ -1537,7 +1540,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) ...@@ -1537,7 +1540,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name)
} }
/* Flush key cache for this file if we are calling this outside myisamchk */ /* Flush key cache for this file if we are calling this outside myisamchk */
flush_key_blocks(share->kfile, FLUSH_IGNORE_CHANGED); flush_key_blocks(dflt_keycache,share->kfile, FLUSH_IGNORE_CHANGED);
share->state.version=(ulong) time((time_t*) 0); share->state.version=(ulong) time((time_t*) 0);
old_state=share->state; /* save state if not stored */ old_state=share->state; /* save state if not stored */
...@@ -1843,7 +1846,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, ...@@ -1843,7 +1846,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
Flush key cache for this file if we are calling this outside Flush key cache for this file if we are calling this outside
myisamchk myisamchk
*/ */
flush_key_blocks(share->kfile, FLUSH_IGNORE_CHANGED); flush_key_blocks(dflt_keycache,share->kfile, FLUSH_IGNORE_CHANGED);
/* Clear the pointers to the given rows */ /* Clear the pointers to the given rows */
for (i=0 ; i < share->base.keys ; i++) for (i=0 ; i < share->base.keys ; i++)
share->state.key_root[i]= HA_OFFSET_ERROR; share->state.key_root[i]= HA_OFFSET_ERROR;
...@@ -1853,7 +1856,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, ...@@ -1853,7 +1856,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
} }
else else
{ {
if (flush_key_blocks(share->kfile, FLUSH_FORCE_WRITE)) if (flush_key_blocks(dflt_keycache,share->kfile, FLUSH_FORCE_WRITE))
goto err; goto err;
key_map= ~key_map; /* Create the missing keys */ key_map= ~key_map; /* Create the missing keys */
} }
...@@ -2206,7 +2209,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, ...@@ -2206,7 +2209,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
Flush key cache for this file if we are calling this outside Flush key cache for this file if we are calling this outside
myisamchk myisamchk
*/ */
flush_key_blocks(share->kfile, FLUSH_IGNORE_CHANGED); flush_key_blocks(dflt_keycache,share->kfile, FLUSH_IGNORE_CHANGED);
/* Clear the pointers to the given rows */ /* Clear the pointers to the given rows */
for (i=0 ; i < share->base.keys ; i++) for (i=0 ; i < share->base.keys ; i++)
share->state.key_root[i]= HA_OFFSET_ERROR; share->state.key_root[i]= HA_OFFSET_ERROR;
...@@ -2216,7 +2219,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, ...@@ -2216,7 +2219,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
} }
else else
{ {
if (flush_key_blocks(share->kfile, FLUSH_FORCE_WRITE)) if (flush_key_blocks(dflt_keycache,share->kfile, FLUSH_FORCE_WRITE))
goto err; goto err;
key_map= ~key_map; /* Create the missing keys */ key_map= ~key_map; /* Create the missing keys */
} }
......
...@@ -64,7 +64,7 @@ int mi_close(register MI_INFO *info) ...@@ -64,7 +64,7 @@ int mi_close(register MI_INFO *info)
if (flag) if (flag)
{ {
if (share->kfile >= 0 && if (share->kfile >= 0 &&
flush_key_blocks(share->kfile, flush_key_blocks(dflt_keycache,share->kfile,
share->temporary ? FLUSH_IGNORE_CHANGED : share->temporary ? FLUSH_IGNORE_CHANGED :
FLUSH_RELEASE)) FLUSH_RELEASE))
error=my_errno; error=my_errno;
......
...@@ -53,7 +53,7 @@ int mi_delete_all_rows(MI_INFO *info) ...@@ -53,7 +53,7 @@ int mi_delete_all_rows(MI_INFO *info)
If we are using delayed keys or if the user has done changes to the tables If we are using delayed keys or if the user has done changes to the tables
since it was locked then there may be key blocks in the key cache since it was locked then there may be key blocks in the key cache
*/ */
flush_key_blocks(share->kfile, FLUSH_IGNORE_CHANGED); flush_key_blocks(dflt_keycache, share->kfile, FLUSH_IGNORE_CHANGED);
if (my_chsize(info->dfile, 0, 0, MYF(MY_WME)) || if (my_chsize(info->dfile, 0, 0, MYF(MY_WME)) ||
my_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME)) ) my_chsize(share->kfile, share->base.keystart, 0, MYF(MY_WME)) )
goto err; goto err;
......
...@@ -279,7 +279,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) ...@@ -279,7 +279,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
#ifdef __WIN__ #ifdef __WIN__
/* Close the isam and data files as Win32 can't drop an open table */ /* Close the isam and data files as Win32 can't drop an open table */
pthread_mutex_lock(&share->intern_lock); pthread_mutex_lock(&share->intern_lock);
if (flush_key_blocks(share->kfile, if (flush_key_blocks(dflt_keycache, share->kfile,
(function == HA_EXTRA_FORCE_REOPEN ? (function == HA_EXTRA_FORCE_REOPEN ?
FLUSH_RELEASE : FLUSH_IGNORE_CHANGED))) FLUSH_RELEASE : FLUSH_IGNORE_CHANGED)))
{ {
...@@ -325,7 +325,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) ...@@ -325,7 +325,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
break; break;
case HA_EXTRA_FLUSH: case HA_EXTRA_FLUSH:
if (!share->temporary) if (!share->temporary)
flush_key_blocks(share->kfile,FLUSH_KEEP); flush_key_blocks(dflt_keycache,share->kfile,FLUSH_KEEP);
#ifdef HAVE_PWRITE #ifdef HAVE_PWRITE
_mi_decrement_open_count(info); _mi_decrement_open_count(info);
#endif #endif
......
...@@ -51,7 +51,8 @@ int mi_lock_database(MI_INFO *info, int lock_type) ...@@ -51,7 +51,8 @@ int mi_lock_database(MI_INFO *info, int lock_type)
count= --share->w_locks; count= --share->w_locks;
--share->tot_locks; --share->tot_locks;
if (info->lock_type == F_WRLCK && !share->w_locks && if (info->lock_type == F_WRLCK && !share->w_locks &&
!share->delay_key_write && flush_key_blocks(share->kfile,FLUSH_KEEP)) !share->delay_key_write &&
flush_key_blocks(dflt_keycache,share->kfile,FLUSH_KEEP))
{ {
error=my_errno; error=my_errno;
mi_mark_crashed(info); /* Mark that table must be checked */ mi_mark_crashed(info); /* Mark that table must be checked */
...@@ -385,7 +386,7 @@ int _mi_test_if_changed(register MI_INFO *info) ...@@ -385,7 +386,7 @@ int _mi_test_if_changed(register MI_INFO *info)
{ /* Keyfile has changed */ { /* Keyfile has changed */
DBUG_PRINT("info",("index file changed")); DBUG_PRINT("info",("index file changed"));
if (share->state.process != share->this_process) if (share->state.process != share->this_process)
VOID(flush_key_blocks(share->kfile,FLUSH_RELEASE)); VOID(flush_key_blocks(dflt_keycache,share->kfile,FLUSH_RELEASE));
share->last_process=share->state.process; share->last_process=share->state.process;
info->last_unique= share->state.unique; info->last_unique= share->state.unique;
info->last_loop= share->state.update_count; info->last_loop= share->state.update_count;
......
...@@ -31,7 +31,8 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, ...@@ -31,7 +31,8 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo,
DBUG_ENTER("_mi_fetch_keypage"); DBUG_ENTER("_mi_fetch_keypage");
DBUG_PRINT("enter",("page: %ld",page)); DBUG_PRINT("enter",("page: %ld",page));
tmp=(uchar*) key_cache_read(info->s->kfile,page,(byte*) buff, tmp=(uchar*) key_cache_read(dflt_keycache,
info->s->kfile,page,(byte*) buff,
(uint) keyinfo->block_length, (uint) keyinfo->block_length,
(uint) keyinfo->block_length, (uint) keyinfo->block_length,
return_buffer); return_buffer);
...@@ -92,7 +93,8 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, ...@@ -92,7 +93,8 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo,
length=keyinfo->block_length; length=keyinfo->block_length;
} }
#endif #endif
DBUG_RETURN((key_cache_write(info->s->kfile,page,(byte*) buff,length, DBUG_RETURN((key_cache_write(dflt_keycache,
info->s->kfile,page,(byte*) buff,length,
(uint) keyinfo->block_length, (uint) keyinfo->block_length,
(int) ((info->lock_type != F_UNLCK) || (int) ((info->lock_type != F_UNLCK) ||
info->s->delay_key_write)))); info->s->delay_key_write))));
...@@ -112,7 +114,8 @@ int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos) ...@@ -112,7 +114,8 @@ int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos)
info->s->state.key_del[keyinfo->block_size]=pos; info->s->state.key_del[keyinfo->block_size]=pos;
mi_sizestore(buff,old_link); mi_sizestore(buff,old_link);
info->s->state.changed|= STATE_NOT_SORTED_PAGES; info->s->state.changed|= STATE_NOT_SORTED_PAGES;
DBUG_RETURN(key_cache_write(info->s->kfile,pos,buff, DBUG_RETURN(key_cache_write(dflt_keycache,
info->s->kfile,pos,buff,
sizeof(buff), sizeof(buff),
(uint) keyinfo->block_length, (uint) keyinfo->block_length,
(int) (info->lock_type != F_UNLCK))); (int) (info->lock_type != F_UNLCK)));
...@@ -140,7 +143,8 @@ my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo) ...@@ -140,7 +143,8 @@ my_off_t _mi_new(register MI_INFO *info, MI_KEYDEF *keyinfo)
} }
else else
{ {
if (!key_cache_read(info->s->kfile,pos, if (!key_cache_read(dflt_keycache,
info->s->kfile,pos,
buff, buff,
(uint) sizeof(buff), (uint) sizeof(buff),
(uint) keyinfo->block_length,0)) (uint) keyinfo->block_length,0))
......
...@@ -48,7 +48,7 @@ int mi_panic(enum ha_panic_function flag) ...@@ -48,7 +48,7 @@ int mi_panic(enum ha_panic_function flag)
if (info->s->options & HA_OPTION_READ_ONLY_DATA) if (info->s->options & HA_OPTION_READ_ONLY_DATA)
break; break;
#endif #endif
if (flush_key_blocks(info->s->kfile,FLUSH_RELEASE)) if (flush_key_blocks(dflt_keycache,info->s->kfile,FLUSH_RELEASE))
error=my_errno; error=my_errno;
if (info->opt_flag & WRITE_CACHE_USED) if (info->opt_flag & WRITE_CACHE_USED)
if (flush_io_cache(&info->rec_cache)) if (flush_io_cache(&info->rec_cache))
......
...@@ -72,7 +72,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) ...@@ -72,7 +72,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves)
if (!(buff= (uchar *) my_malloc(length, MYF(MY_WME)))) if (!(buff= (uchar *) my_malloc(length, MYF(MY_WME))))
return (my_errno= HA_ERR_OUT_OF_MEM); return (my_errno= HA_ERR_OUT_OF_MEM);
if (flush_key_blocks(share->kfile, FLUSH_RELEASE)) if (flush_key_blocks(dflt_keycache,share->kfile, FLUSH_RELEASE))
goto err; goto err;
do do
...@@ -89,7 +89,8 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) ...@@ -89,7 +89,8 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves)
{ {
if (mi_test_if_nod(buff)) if (mi_test_if_nod(buff))
{ {
if (key_cache_insert(share->kfile, pos, (byte*) buff, block_length)) if (key_cache_insert(dflt_keycache,
share->kfile, pos, (byte*) buff, block_length))
goto err; goto err;
} }
pos+= block_length; pos+= block_length;
...@@ -99,7 +100,8 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) ...@@ -99,7 +100,8 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves)
} }
else else
{ {
if (key_cache_insert(share->kfile, pos, (byte*) buff, length)) if (key_cache_insert(dflt_keycache,
share->kfile, pos, (byte*) buff, length))
goto err; goto err;
pos+= length; pos+= length;
} }
......
...@@ -50,7 +50,7 @@ int main(int argc,char *argv[]) ...@@ -50,7 +50,7 @@ int main(int argc,char *argv[])
MY_INIT(argv[0]); MY_INIT(argv[0]);
my_init(); my_init();
if (key_cacheing) if (key_cacheing)
init_key_cache(IO_SIZE*16); init_key_cache(&dflt_keycache,dflt_key_block_size,IO_SIZE*16);
get_options(argc,argv); get_options(argc,argv);
exit(run_test("test1")); exit(run_test("test1"));
......
...@@ -214,7 +214,7 @@ int main(int argc, char *argv[]) ...@@ -214,7 +214,7 @@ int main(int argc, char *argv[])
if (!silent) if (!silent)
printf("- Writing key:s\n"); printf("- Writing key:s\n");
if (key_cacheing) if (key_cacheing)
init_key_cache(key_cache_size); /* Use a small cache */ init_key_cache(&dflt_keycache,dflt_key_block_size,key_cache_size); /* Use a small cache */
if (locking) if (locking)
mi_lock_database(file,F_WRLCK); mi_lock_database(file,F_WRLCK);
if (write_cacheing) if (write_cacheing)
...@@ -274,7 +274,7 @@ int main(int argc, char *argv[]) ...@@ -274,7 +274,7 @@ int main(int argc, char *argv[])
goto end; goto end;
} }
if (key_cacheing) if (key_cacheing)
resize_key_cache(key_cache_size*2); resize_key_cache(&dflt_keycache,key_cache_size*2);
} }
if (!silent) if (!silent)
...@@ -816,16 +816,19 @@ int main(int argc, char *argv[]) ...@@ -816,16 +816,19 @@ int main(int argc, char *argv[])
puts("Locking used"); puts("Locking used");
if (use_blob) if (use_blob)
puts("blobs used"); puts("blobs used");
#if 0
printf("key cache status: \n\ printf("key cache status: \n\
blocks used:%10lu\n\ blocks used:%10lu\n\
w_requests: %10lu\n\ w_requests: %10lu\n\
writes: %10lu\n\ writes: %10lu\n\
r_requests: %10lu\n\ r_requests: %10lu\n\
reads: %10lu\n", reads: %10lu\n",
my_blocks_used, my_cache_w_requests, my_cache_write, my_blocks_used,
my_cache_w_requests, my_cache_write,
my_cache_r_requests, my_cache_read); my_cache_r_requests, my_cache_read);
#endif
} }
end_key_cache(); end_key_cache(&dflt_keycache,1);
if (blob_buffer) if (blob_buffer)
my_free(blob_buffer,MYF(0)); my_free(blob_buffer,MYF(0));
my_end(silent ? MY_CHECK_ERROR : MY_CHECK_ERROR | MY_GIVE_INFO); my_end(silent ? MY_CHECK_ERROR : MY_CHECK_ERROR | MY_GIVE_INFO);
......
...@@ -177,7 +177,7 @@ void start_test(int id) ...@@ -177,7 +177,7 @@ void start_test(int id)
exit(1); exit(1);
} }
if (key_cacheing && rnd(2) == 0) if (key_cacheing && rnd(2) == 0)
init_key_cache(65536L); init_key_cache(&dflt_keycache,dflt_key_block_size,65536L);
printf("Process %d, pid: %d\n",id,getpid()); fflush(stdout); printf("Process %d, pid: %d\n",id,getpid()); fflush(stdout);
for (error=i=0 ; i < tests && !error; i++) for (error=i=0 ; i < tests && !error; i++)
......
...@@ -1020,7 +1020,8 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -1020,7 +1020,8 @@ static int myisamchk(MI_CHECK *param, my_string filename)
!(param->testflag & (T_FAST | T_FORCE_CREATE))) !(param->testflag & (T_FAST | T_FORCE_CREATE)))
{ {
if (param->testflag & (T_EXTEND | T_MEDIUM)) if (param->testflag & (T_EXTEND | T_MEDIUM))
VOID(init_key_cache(param->use_buffers)); VOID(init_key_cache(&dflt_keycache,dflt_key_block_size,
param->use_buffers));
VOID(init_io_cache(&param->read_cache,datafile, VOID(init_io_cache(&param->read_cache,datafile,
(uint) param->read_buffer_length, (uint) param->read_buffer_length,
READ_CACHE, READ_CACHE,
...@@ -1437,7 +1438,7 @@ static int mi_sort_records(MI_CHECK *param, ...@@ -1437,7 +1438,7 @@ static int mi_sort_records(MI_CHECK *param,
if (share->state.key_root[sort_key] == HA_OFFSET_ERROR) if (share->state.key_root[sort_key] == HA_OFFSET_ERROR)
DBUG_RETURN(0); /* Nothing to do */ DBUG_RETURN(0); /* Nothing to do */
init_key_cache(param->use_buffers); init_key_cache(&dflt_keycache,dflt_key_block_size,param->use_buffers);
if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length, if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length,
WRITE_CACHE,share->pack.header_length,1, WRITE_CACHE,share->pack.header_length,1,
MYF(MY_WME | MY_WAIT_IF_FULL))) MYF(MY_WME | MY_WAIT_IF_FULL)))
......
...@@ -333,7 +333,7 @@ static int examine_log(my_string file_name, char **table_names) ...@@ -333,7 +333,7 @@ static int examine_log(my_string file_name, char **table_names)
bzero((gptr) com_count,sizeof(com_count)); bzero((gptr) com_count,sizeof(com_count));
init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1, init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1,
(tree_element_free) file_info_free, NULL); (tree_element_free) file_info_free, NULL);
VOID(init_key_cache(KEY_CACHE_SIZE)); VOID(init_key_cache(&dflt_keycache,dflt_key_block_size,KEY_CACHE_SIZE));
files_open=0; access_time=0; files_open=0; access_time=0;
while (access_time++ != number_of_commands && while (access_time++ != number_of_commands &&
...@@ -639,7 +639,7 @@ static int examine_log(my_string file_name, char **table_names) ...@@ -639,7 +639,7 @@ static int examine_log(my_string file_name, char **table_names)
goto end; goto end;
} }
} }
end_key_cache(); end_key_cache(&dflt_keycache,1);
delete_tree(&tree); delete_tree(&tree);
VOID(end_io_cache(&cache)); VOID(end_io_cache(&cache));
VOID(my_close(file,MYF(0))); VOID(my_close(file,MYF(0)));
...@@ -659,7 +659,7 @@ static int examine_log(my_string file_name, char **table_names) ...@@ -659,7 +659,7 @@ static int examine_log(my_string file_name, char **table_names)
llstr(isamlog_filepos,llbuff))); llstr(isamlog_filepos,llbuff)));
fflush(stderr); fflush(stderr);
end: end:
end_key_cache(); end_key_cache(&dflt_keycache,1);
delete_tree(&tree); delete_tree(&tree);
VOID(end_io_cache(&cache)); VOID(end_io_cache(&cache));
VOID(my_close(file,MYF(0))); VOID(my_close(file,MYF(0)));
......
This diff is collapsed.
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