summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorunknown <bell@desktop.sanja.is.com.ua>2007-02-02 09:41:32 +0200
committerunknown <bell@desktop.sanja.is.com.ua>2007-02-02 09:41:32 +0200
commit025400922118f11a15be54c66455f20e2f72c0b4 (patch)
treef3e73bf1a50802f9f1fd8f4bcee5361654350e32 /include
parent5c7960965c4c178d3a02f9893ea65b2802b38b8f (diff)
downloadmariadb-git-025400922118f11a15be54c66455f20e2f72c0b4.tar.gz
postreview changes for page cache and pre review commit for loghandler
storage/maria/unittest/test_file.c: Rename: unittest/mysys/test_file.c -> storage/maria/unittest/test_file.c storage/maria/unittest/test_file.h: Rename: unittest/mysys/test_file.h -> storage/maria/unittest/test_file.h include/pagecache.h: A waiting queue mechanism moved to separate file wqueue.* Pointer name changed for compatibility mysys/Makefile.am: A waiting queue mechanism moved to separate file wqueue.* mysys/mf_keycache.c: fixed unsigned comparison mysys/mf_pagecache.c: A waiting queue mechanism moved to separate file wqueue.* Fixed bug in unregistering block during write storage/maria/Makefile.am: The loghandler files added storage/maria/ma_control_file.h: Now we have loghandler and can compile control file storage/maria/maria_def.h: Including files need for compilation of maria storage/maria/unittest/Makefile.am: unit tests of loghandler storage/maria/unittest/ma_control_file-t.c: Used maria def storage/maria/unittest/mf_pagecache_consist.c: fixed memory overrun storage/maria/unittest/mf_pagecache_single.c: fixed used uninitialized memory unittest/mysys/Makefile.am: unittests of pagecache moved to maria becase pagecache need loghandler include/wqueue.h: New BitKeeper file ``include/wqueue.h'' mysys/wqueue.c: New BitKeeper file ``mysys/wqueue.c'' storage/maria/ma_loghandler.c: New BitKeeper file ``storage/maria/ma_loghandler.c'' storage/maria/ma_loghandler.h: New BitKeeper file ``storage/maria/ma_loghandler.h'' storage/maria/ma_loghandler_lsn.h: New BitKeeper file ``storage/maria/ma_loghandler_lsn.h'' storage/maria/unittest/ma_test_loghandler-t.c: New BitKeeper file ``storage/maria/unittest/ma_test_loghandler-t.c'' storage/maria/unittest/ma_test_loghandler_multigroup-t.c: New BitKeeper file ``storage/maria/unittest/ma_test_loghandler_multigroup-t.c'' storage/maria/unittest/ma_test_loghandler_multithread-t.c: New BitKeeper file ``storage/maria/unittest/ma_test_loghandler_multithread-t.c'' storage/maria/unittest/ma_test_loghandler_pagecache-t.c: New BitKeeper file ``storage/maria/unittest/ma_test_loghandler_pagecache-t.c''
Diffstat (limited to 'include')
-rw-r--r--include/pagecache.h65
-rw-r--r--include/wqueue.h26
2 files changed, 59 insertions, 32 deletions
diff --git a/include/pagecache.h b/include/pagecache.h
index 4d64070ad62..2f745eae0b3 100644
--- a/include/pagecache.h
+++ b/include/pagecache.h
@@ -20,11 +20,13 @@
#define _pagecache_h
C_MODE_START
+#include "../storage/maria/ma_loghandler_lsn.h"
+
/* Type of the page */
enum pagecache_page_type
{
#ifndef DBUG_OFF
- /* used only for control page type chenging during debugging */
+ /* used only for control page type changing during debugging */
PAGECACHE_EMPTY_PAGE,
#endif
/* the page does not contain LSN */
@@ -34,7 +36,7 @@ enum pagecache_page_type
};
/*
- This enum describe lock status changing. every typr of page cache will
+ This enum describe lock status changing. every type of page cache will
interpret WRITE/READ lock as it need.
*/
enum pagecache_page_lock
@@ -71,9 +73,7 @@ enum pagecache_write_mode
typedef void *PAGECACHE_PAGE_LINK;
-/* TODO: move to loghandler emulator */
-typedef void LOG_HANDLER;
-typedef void *LSN;
+typedef void *LSN_PTR;
/* file descriptor for Maria */
typedef struct st_pagecache_file
@@ -82,7 +82,7 @@ typedef struct st_pagecache_file
} PAGECACHE_FILE;
/* page number for maria */
-typedef uint32 maria_page_no_t;
+typedef uint32 pgcache_page_no_t;
/* declare structures that is used by st_pagecache */
@@ -93,11 +93,9 @@ typedef struct st_pagecache_page PAGECACHE_PAGE;
struct st_pagecache_hash_link;
typedef struct st_pagecache_hash_link PAGECACHE_HASH_LINK;
-/* info about requests in a waiting queue */
-typedef struct st_pagecache_wqueue
-{
- struct st_my_thread_var *last_thread; /* circular list of waiting threads */
-} PAGECACHE_WQUEUE;
+#include <wqueue.h>
+
+typedef my_bool (*pagecache_disk_read_validator)(byte *page, gptr data);
#define PAGECACHE_CHANGED_BLOCKS_HASH 128 /* must be power of 2 */
@@ -136,16 +134,14 @@ typedef struct st_pagecache
PAGECACHE_BLOCK_LINK *used_last;/* ptr to the last block of the LRU chain */
PAGECACHE_BLOCK_LINK *used_ins;/* ptr to the insertion block in LRU chain */
pthread_mutex_t cache_lock; /* to lock access to the cache structure */
- PAGECACHE_WQUEUE resize_queue; /* threads waiting during resize operation */
- PAGECACHE_WQUEUE waiting_for_hash_link;/* waiting for a free hash link */
- PAGECACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */
+ WQUEUE resize_queue; /* threads waiting during resize operation */
+ WQUEUE waiting_for_hash_link;/* waiting for a free hash link */
+ WQUEUE waiting_for_block; /* requests waiting for a free block */
/* hash for dirty file bl.*/
PAGECACHE_BLOCK_LINK *changed_blocks[PAGECACHE_CHANGED_BLOCKS_HASH];
/* hash for other file bl.*/
PAGECACHE_BLOCK_LINK *file_blocks[PAGECACHE_CHANGED_BLOCKS_HASH];
- LOG_HANDLER *loghandler; /* loghandler structure */
-
/*
The following variables are and variables used to hold parameters for
initializing the key cache.
@@ -169,24 +165,29 @@ typedef struct st_pagecache
extern int init_pagecache(PAGECACHE *pagecache, my_size_t use_mem,
uint division_limit, uint age_threshold,
- uint block_size,
- LOG_HANDLER *loghandler);
+ uint block_size);
extern int resize_pagecache(PAGECACHE *pagecache,
my_size_t use_mem, uint division_limit,
uint age_threshold);
extern void change_pagecache_param(PAGECACHE *pagecache, uint division_limit,
uint age_threshold);
-extern byte *pagecache_read(PAGECACHE *pagecache,
- PAGECACHE_FILE *file,
- maria_page_no_t pageno,
- uint level,
- byte *buff,
- enum pagecache_page_type type,
- enum pagecache_page_lock lock,
- PAGECACHE_PAGE_LINK *link);
+
+#define pagecache_read(P,F,N,L,B,T,K,I) \
+ pagecache_valid_read(P,F,N,L,B,T,K,I,0,0)
+
+extern byte *pagecache_valid_read(PAGECACHE *pagecache,
+ PAGECACHE_FILE *file,
+ pgcache_page_no_t pageno,
+ uint level,
+ byte *buff,
+ enum pagecache_page_type type,
+ enum pagecache_page_lock lock,
+ PAGECACHE_PAGE_LINK *link,
+ pagecache_disk_read_validator validator,
+ gptr validator_data);
extern my_bool pagecache_write(PAGECACHE *pagecache,
PAGECACHE_FILE *file,
- maria_page_no_t pageno,
+ pgcache_page_no_t pageno,
uint level,
byte *buff,
enum pagecache_page_type type,
@@ -196,20 +197,20 @@ extern my_bool pagecache_write(PAGECACHE *pagecache,
PAGECACHE_PAGE_LINK *link);
extern void pagecache_unlock_page(PAGECACHE *pagecache,
PAGECACHE_FILE *file,
- maria_page_no_t pageno,
+ pgcache_page_no_t pageno,
enum pagecache_page_lock lock,
enum pagecache_page_pin pin,
my_bool stamp_this_page,
- LSN first_REDO_LSN_for_page);
+ LSN_PTR first_REDO_LSN_for_page);
extern void pagecache_unlock(PAGECACHE *pagecache,
PAGECACHE_PAGE_LINK *link,
enum pagecache_page_lock lock,
enum pagecache_page_pin pin,
my_bool stamp_this_page,
- LSN first_REDO_LSN_for_page);
+ LSN_PTR first_REDO_LSN_for_page);
extern void pagecache_unpin_page(PAGECACHE *pagecache,
PAGECACHE_FILE *file,
- maria_page_no_t pageno);
+ pgcache_page_no_t pageno);
extern void pagecache_unpin(PAGECACHE *pagecache,
PAGECACHE_PAGE_LINK *link);
extern int flush_pagecache_blocks(PAGECACHE *keycache,
@@ -217,7 +218,7 @@ extern int flush_pagecache_blocks(PAGECACHE *keycache,
enum flush_type type);
extern my_bool pagecache_delete_page(PAGECACHE *pagecache,
PAGECACHE_FILE *file,
- maria_page_no_t pageno,
+ pgcache_page_no_t pageno,
enum pagecache_page_lock lock,
my_bool flush);
extern void end_pagecache(PAGECACHE *keycache, my_bool cleanup);
diff --git a/include/wqueue.h b/include/wqueue.h
new file mode 100644
index 00000000000..bacabb8c401
--- /dev/null
+++ b/include/wqueue.h
@@ -0,0 +1,26 @@
+
+#ifndef _wqueue_h
+#define _wqueue_h
+
+#include <my_global.h>
+#include <my_pthread.h>
+
+/* info about requests in a waiting queue */
+typedef struct st_pagecache_wqueue
+{
+ struct st_my_thread_var *last_thread; /* circular list of waiting
+ threads */
+} WQUEUE;
+
+#ifdef THREAD
+void wqueue_link_into_queue(WQUEUE *wqueue, struct st_my_thread_var *thread);
+void wqueue_unlink_from_queue(WQUEUE *wqueue, struct st_my_thread_var *thread);
+void wqueue_add_to_queue(WQUEUE *wqueue, struct st_my_thread_var *thread);
+void wqueue_add_and_wait(WQUEUE *wqueue,
+ struct st_my_thread_var *thread,
+ pthread_mutex_t *lock);
+void wqueue_release_queue(WQUEUE *wqueue);
+
+#endif
+
+#endif