CUBRID Engine  latest
double_write_buffer.c File Reference
#include <assert.h>
#include <math.h>
#include "double_write_buffer.h"
#include "system_parameter.h"
#include "thread_daemon.hpp"
#include "thread_entry_task.hpp"
#include "thread_lockfree_hash_map.hpp"
#include "thread_manager.hpp"
#include "log_append.hpp"
#include "log_impl.h"
#include "log_volids.hpp"
#include "boot_sr.h"
#include "perf_monitor.h"
#include "porting_inline.hpp"
Include dependency graph for double_write_buffer.c:

Go to the source code of this file.

Classes

struct  double_write_wait_queue_entry
 
struct  double_write_wait_queue
 
struct  flush_volume_info
 
struct  double_write_block
 
struct  dwb_slots_hash_entry
 
struct  double_write_buffer
 

Macros

#define DWB_SLOTS_HASH_SIZE   1000
 
#define DWB_SLOTS_FREE_LIST_SIZE   100
 
#define DWB_MIN_SIZE   (512 * 1024)
 
#define DWB_MAX_SIZE   (32 * 1024 * 1024)
 
#define DWB_MIN_BLOCKS   1
 
#define DWB_MAX_BLOCKS   32
 
#define DWB_NUM_TOTAL_BLOCKS   (dwb_Global.num_blocks)
 
#define DWB_NUM_TOTAL_PAGES   (dwb_Global.num_pages)
 
#define DWB_BLOCK_NUM_PAGES   (dwb_Global.num_block_pages)
 
#define DWB_LOG2_BLOCK_NUM_PAGES   (dwb_Global.log2_num_block_pages)
 
#define DWB_POSITION_MASK   0x000000003fffffff
 
#define DWB_BLOCKS_STATUS_MASK   0xffffffff00000000
 
#define DWB_MODIFY_STRUCTURE   0x0000000080000000
 
#define DWB_CREATE   0x0000000040000000
 
#define DWB_CREATE_OR_MODIFY_MASK   (DWB_CREATE | DWB_MODIFY_STRUCTURE)
 
#define DWB_FLAG_MASK   (DWB_BLOCKS_STATUS_MASK | DWB_MODIFY_STRUCTURE | DWB_CREATE)
 
#define DWB_GET_POSITION(position_with_flags)   ((position_with_flags) & DWB_POSITION_MASK)
 
#define DWB_RESET_POSITION(position_with_flags)   ((position_with_flags) & DWB_FLAG_MASK)
 
#define DWB_GET_BLOCK_STATUS(position_with_flags)   ((position_with_flags) & DWB_BLOCKS_STATUS_MASK)
 
#define DWB_GET_BLOCK_NO_FROM_POSITION(position_with_flags)   ((unsigned int) DWB_GET_POSITION (position_with_flags) >> (DWB_LOG2_BLOCK_NUM_PAGES))
 
#define DWB_IS_BLOCK_WRITE_STARTED(position_with_flags, block_no)   (assert (block_no < DWB_MAX_BLOCKS), ((position_with_flags) & (1ULL << (63 - (block_no)))) != 0)
 
#define DWB_IS_ANY_BLOCK_WRITE_STARTED(position_with_flags)   (((position_with_flags) & DWB_BLOCKS_STATUS_MASK) != 0)
 
#define DWB_STARTS_BLOCK_WRITING(position_with_flags, block_no)   (assert (block_no < DWB_MAX_BLOCKS), (position_with_flags) | (1ULL << (63 - (block_no))))
 
#define DWB_ENDS_BLOCK_WRITING(position_with_flags, block_no)
 
#define DWB_STARTS_MODIFYING_STRUCTURE(position_with_flags)   ((position_with_flags) | DWB_MODIFY_STRUCTURE)
 
#define DWB_ENDS_MODIFYING_STRUCTURE(position_with_flags)   (assert (DWB_IS_MODIFYING_STRUCTURE (position_with_flags)), (position_with_flags) & ~DWB_MODIFY_STRUCTURE)
 
#define DWB_IS_MODIFYING_STRUCTURE(position_with_flags)   (((position_with_flags) & DWB_MODIFY_STRUCTURE) != 0)
 
#define DWB_STARTS_CREATION(position_with_flags)   ((position_with_flags) | DWB_CREATE)
 
#define DWB_ENDS_CREATION(position_with_flags)   (assert (DWB_IS_CREATED (position_with_flags)), (position_with_flags) & ~DWB_CREATE)
 
#define DWB_IS_CREATED(position_with_flags)   (((position_with_flags) & DWB_CREATE) != 0)
 
#define DWB_NOT_CREATED_OR_MODIFYING(position_with_flags)   (((position_with_flags) & DWB_CREATE_OR_MODIFY_MASK) != DWB_CREATE)
 
#define DWB_GET_NEXT_POSITION_WITH_FLAGS(position_with_flags)
 
#define DWB_GET_POSITION_IN_BLOCK(position_with_flags)   ((DWB_GET_POSITION (position_with_flags)) & (DWB_BLOCK_NUM_PAGES - 1))
 
#define DWB_GET_PREV_BLOCK_NO(block_no)   ((block_no) > 0 ? ((block_no) - 1) : (DWB_NUM_TOTAL_BLOCKS - 1))
 
#define DWB_GET_PREV_BLOCK(block_no)   (&(dwb_Global.blocks[DWB_GET_PREV_BLOCK_NO(block_no)]))
 
#define DWB_GET_NEXT_BLOCK_NO(block_no)   ((block_no) == (DWB_NUM_TOTAL_BLOCKS - 1) ? 0 : ((block_no) + 1))
 
#define DWB_GET_BLOCK_VERSION(block)   (ATOMIC_INC_64 (&block->version, 0ULL))
 
#define DWB_WAIT_QUEUE_INITIALIZER   {NULL, NULL, NULL, 0, 0}
 
#define dwb_Log   dwb_Global.logging_enabled
 
#define dwb_check_logging()   (dwb_Log = prm_get_bool_value (PRM_ID_DWB_LOGGING))
 
#define dwb_log(...)   if (dwb_Log) _er_log_debug (ARG_FILE_LINE, "DWB: " __VA_ARGS__)
 
#define dwb_log_error(...)   if (dwb_Log) _er_log_debug (ARG_FILE_LINE, "DWB ERROR: " __VA_ARGS__)
 
#define pthread_mutex_init(a, b)
 
#define pthread_mutex_destroy(a)
 
#define pthread_mutex_lock(a)   0
 
#define pthread_mutex_unlock(a)
 

Typedefs

typedef struct double_write_wait_queue_entry DWB_WAIT_QUEUE_ENTRY
 
typedef struct double_write_wait_queue DWB_WAIT_QUEUE
 
typedef struct flush_volume_info FLUSH_VOLUME_INFO
 
typedef struct double_write_block DWB_BLOCK
 
typedef struct dwb_slots_hash_entry DWB_SLOTS_HASH_ENTRY
 
using dwb_hashmap_type = cubthread::lockfree_hashmap< VPID, dwb_slots_hash_entry >
 
typedef struct double_write_buffer DOUBLE_WRITE_BUFFER
 

Enumerations

enum  FLUSH_VOLUME_STATUS { VOLUME_NOT_FLUSHED, VOLUME_FLUSHED_BY_DWB_FILE_SYNC_HELPER_THREAD, VOLUME_FLUSHED_BY_DWB_FLUSH_THREAD }
 

Functions

STATIC_INLINE void dwb_init_wait_queue (DWB_WAIT_QUEUE *wait_queue) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE DWB_WAIT_QUEUE_ENTRYdwb_make_wait_queue_entry (DWB_WAIT_QUEUE *wait_queue, void *data) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE DWB_WAIT_QUEUE_ENTRYdwb_block_add_wait_queue_entry (DWB_WAIT_QUEUE *wait_queue, void *data) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE DWB_WAIT_QUEUE_ENTRYdwb_block_disconnect_wait_queue_entry (DWB_WAIT_QUEUE *wait_queue, void *data) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE void dwb_block_free_wait_queue_entry (DWB_WAIT_QUEUE *wait_queue, DWB_WAIT_QUEUE_ENTRY *wait_queue_entry, int(*func)(void *)) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE void dwb_remove_wait_queue_entry (DWB_WAIT_QUEUE *wait_queue, pthread_mutex_t *mutex, void *data, int(*func)(void *)) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE void dwb_signal_waiting_threads (DWB_WAIT_QUEUE *wait_queue, pthread_mutex_t *mutex) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE void dwb_destroy_wait_queue (DWB_WAIT_QUEUE *wait_queue, pthread_mutex_t *mutex)
 
STATIC_INLINE void dwb_adjust_write_buffer_values (unsigned int *p_double_write_buffer_size, unsigned int *p_num_blocks) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE int dwb_wait_for_block_completion (THREAD_ENTRY *thread_p, unsigned int block_no) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE int dwb_signal_waiting_thread (void *data) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE int dwb_set_status_resumed (void *data) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE void dwb_signal_block_completion (THREAD_ENTRY *thread_p, DWB_BLOCK *dwb_block) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE int dwb_block_create_ordered_slots (DWB_BLOCK *block, DWB_SLOT **p_dwb_ordered_slots, unsigned int *p_ordered_slots_length) __attribute__((ALWAYS_INLINE))
 
static int dwb_compare_vol_fd (const void *v1, const void *v2)
 
STATIC_INLINE FLUSH_VOLUME_INFOdwb_add_volume_to_block_flush_area (THREAD_ENTRY *thread_p, DWB_BLOCK *block, int vol_fd) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE int dwb_write_block (THREAD_ENTRY *thread_p, DWB_BLOCK *block, DWB_SLOT *p_dwb_slots, unsigned int ordered_slots_length, bool file_sync_helper_can_flush, bool remove_from_hash) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE int dwb_flush_block (THREAD_ENTRY *thread_p, DWB_BLOCK *block, bool file_sync_helper_can_flush, UINT64 *current_position_with_flags) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE void dwb_init_slot (DWB_SLOT *slot) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE int dwb_acquire_next_slot (THREAD_ENTRY *thread_p, bool can_wait, DWB_SLOT **p_dwb_slot) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE void dwb_set_slot_data (THREAD_ENTRY *thread_p, DWB_SLOT *dwb_slot, FILEIO_PAGE *io_page_p) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE int dwb_wait_for_strucure_modification (THREAD_ENTRY *thread_p) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE void dwb_signal_structure_modificated (THREAD_ENTRY *thread_p) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE int dwb_starts_structure_modification (THREAD_ENTRY *thread_p, UINT64 *current_position_with_flags) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE void dwb_ends_structure_modification (THREAD_ENTRY *thread_p, UINT64 current_position_with_flags) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE void dwb_destroy_internal (THREAD_ENTRY *thread_p, UINT64 *current_position_with_flags) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE void dwb_initialize_slot (DWB_SLOT *slot, FILEIO_PAGE *io_page, unsigned int position_in_block, unsigned int block_no) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE void dwb_initialize_block (DWB_BLOCK *block, unsigned int block_no, unsigned int count_wb_pages, char *write_buffer, DWB_SLOT *slots, FLUSH_VOLUME_INFO *flush_volumes_info, unsigned int count_flush_volumes_info, unsigned int max_to_flush_vdes) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE int dwb_create_blocks (THREAD_ENTRY *thread_p, unsigned int num_blocks, unsigned int num_block_pages, DWB_BLOCK **p_blocks) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE void dwb_finalize_block (DWB_BLOCK *block) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE int dwb_create_internal (THREAD_ENTRY *thread_p, const char *dwb_volume_name, UINT64 *current_position_with_flags) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE void dwb_get_next_block_for_flush (THREAD_ENTRY *thread_p, unsigned int *block_no) __attribute__((ALWAYS_INLINE))
 
static void * dwb_slots_hash_entry_alloc (void)
 
static int dwb_slots_hash_entry_free (void *entry)
 
static int dwb_slots_hash_entry_init (void *entry)
 
static int dwb_slots_hash_key_copy (void *src, void *dest)
 
static int dwb_slots_hash_compare_key (void *key1, void *key2)
 
static unsigned int dwb_slots_hash_key (void *key, int hash_table_size)
 
STATIC_INLINE int dwb_slots_hash_insert (THREAD_ENTRY *thread_p, VPID *vpid, DWB_SLOT *slot, bool *inserted) __attribute__((ALWAYS_INLINE))
 
STATIC_INLINE int dwb_slots_hash_delete (THREAD_ENTRY *thread_p, DWB_SLOT *slot)
 
static bool dwb_is_flush_block_daemon_available (void)
 
static bool dwb_is_file_sync_helper_daemon_available (void)
 
static bool dwb_flush_block_daemon_is_running (void)
 
static bool dwb_file_sync_helper_daemon_is_running (void)
 
static int dwb_file_sync_helper (THREAD_ENTRY *thread_p)
 
static int dwb_flush_next_block (THREAD_ENTRY *thread_p)
 
static int dwb_debug_check_dwb (THREAD_ENTRY *thread_p, DWB_SLOT *p_dwb_ordered_slots, unsigned int num_pages)
 
static int dwb_check_data_page_is_sane (THREAD_ENTRY *thread_p, DWB_BLOCK *rcv_block, DWB_SLOT *p_dwb_ordered_slots, int *p_num_recoverable_pages)
 
static int dwb_compare_slots (const void *arg1, const void *arg2)
 
int dwb_set_data_on_next_slot (THREAD_ENTRY *thread_p, FILEIO_PAGE *io_page_p, bool can_wait, DWB_SLOT **p_dwb_slot)
 
int dwb_add_page (THREAD_ENTRY *thread_p, FILEIO_PAGE *io_page_p, VPID *vpid, DWB_SLOT **p_dwb_slot)
 
bool dwb_is_created (void)
 
int dwb_create (THREAD_ENTRY *thread_p, const char *dwb_path_p, const char *db_name_p)
 
int dwb_recreate (THREAD_ENTRY *thread_p)
 
int dwb_load_and_recover_pages (THREAD_ENTRY *thread_p, const char *dwb_path_p, const char *db_name_p)
 
int dwb_destroy (THREAD_ENTRY *thread_p)
 
char * dwb_get_volume_name (void)
 
int dwb_flush_force (THREAD_ENTRY *thread_p, bool *all_sync)
 
int dwb_read_page (THREAD_ENTRY *thread_p, const VPID *vpid, void *io_page, bool *success)
 

Variables

char dwb_Volume_name [PATH_MAX]
 
static DOUBLE_WRITE_BUFFER dwb_Global
 
static LF_ENTRY_DESCRIPTOR slots_entry_Descriptor
 

Macro Definition Documentation

#define DWB_BLOCK_NUM_PAGES   (dwb_Global.num_block_pages)
#define DWB_BLOCKS_STATUS_MASK   0xffffffff00000000

Definition at line 68 of file double_write_buffer.c.

#define dwb_check_logging ( )    (dwb_Log = prm_get_bool_value (PRM_ID_DWB_LOGGING))

Definition at line 310 of file double_write_buffer.c.

Referenced by dwb_load_and_recover_pages().

#define DWB_CREATE   0x0000000040000000

Definition at line 74 of file double_write_buffer.c.

#define DWB_CREATE_OR_MODIFY_MASK   (DWB_CREATE | DWB_MODIFY_STRUCTURE)

Definition at line 77 of file double_write_buffer.c.

#define DWB_ENDS_BLOCK_WRITING (   position_with_flags,
  block_no 
)
Value:
(assert (DWB_IS_BLOCK_WRITE_STARTED (position_with_flags, block_no)), \
(position_with_flags) & ~(1ULL << (63 - (block_no))))
#define assert(x)
#define DWB_IS_BLOCK_WRITE_STARTED(position_with_flags, block_no)

Definition at line 112 of file double_write_buffer.c.

Referenced by dwb_flush_block().

#define DWB_ENDS_CREATION (   position_with_flags)    (assert (DWB_IS_CREATED (position_with_flags)), (position_with_flags) & ~DWB_CREATE)

Definition at line 133 of file double_write_buffer.c.

Referenced by dwb_destroy_internal().

#define DWB_ENDS_MODIFYING_STRUCTURE (   position_with_flags)    (assert (DWB_IS_MODIFYING_STRUCTURE (position_with_flags)), (position_with_flags) & ~DWB_MODIFY_STRUCTURE)

Definition at line 121 of file double_write_buffer.c.

Referenced by dwb_ends_structure_modification().

#define DWB_FLAG_MASK   (DWB_BLOCKS_STATUS_MASK | DWB_MODIFY_STRUCTURE | DWB_CREATE)

Definition at line 80 of file double_write_buffer.c.

#define DWB_GET_BLOCK_NO_FROM_POSITION (   position_with_flags)    ((unsigned int) DWB_GET_POSITION (position_with_flags) >> (DWB_LOG2_BLOCK_NUM_PAGES))

Definition at line 96 of file double_write_buffer.c.

Referenced by dwb_acquire_next_slot(), and dwb_flush_force().

#define DWB_GET_BLOCK_STATUS (   position_with_flags)    ((position_with_flags) & DWB_BLOCKS_STATUS_MASK)

Definition at line 92 of file double_write_buffer.c.

Referenced by dwb_flush_force(), and dwb_starts_structure_modification().

#define DWB_GET_BLOCK_VERSION (   block)    (ATOMIC_INC_64 (&block->version, 0ULL))

Definition at line 166 of file double_write_buffer.c.

#define DWB_GET_NEXT_BLOCK_NO (   block_no)    ((block_no) == (DWB_NUM_TOTAL_BLOCKS - 1) ? 0 : ((block_no) + 1))

Definition at line 162 of file double_write_buffer.c.

Referenced by dwb_flush_block().

#define DWB_GET_NEXT_POSITION_WITH_FLAGS (   position_with_flags)
Value:
((DWB_GET_POSITION (position_with_flags)) == (DWB_NUM_TOTAL_PAGES - 1) \
? ((position_with_flags) & DWB_FLAG_MASK) : ((position_with_flags) + 1))
#define DWB_FLAG_MASK
#define DWB_GET_POSITION(position_with_flags)
#define DWB_NUM_TOTAL_PAGES

Definition at line 145 of file double_write_buffer.c.

Referenced by dwb_acquire_next_slot().

#define DWB_GET_POSITION (   position_with_flags)    ((position_with_flags) & DWB_POSITION_MASK)

Definition at line 84 of file double_write_buffer.c.

#define DWB_GET_POSITION_IN_BLOCK (   position_with_flags)    ((DWB_GET_POSITION (position_with_flags)) & (DWB_BLOCK_NUM_PAGES - 1))

Definition at line 150 of file double_write_buffer.c.

Referenced by dwb_acquire_next_slot().

#define DWB_GET_PREV_BLOCK (   block_no)    (&(dwb_Global.blocks[DWB_GET_PREV_BLOCK_NO(block_no)]))

Definition at line 158 of file double_write_buffer.c.

Referenced by dwb_flush_next_block().

#define DWB_GET_PREV_BLOCK_NO (   block_no)    ((block_no) > 0 ? ((block_no) - 1) : (DWB_NUM_TOTAL_BLOCKS - 1))

Definition at line 154 of file double_write_buffer.c.

Referenced by dwb_flush_next_block().

#define DWB_IS_ANY_BLOCK_WRITE_STARTED (   position_with_flags)    (((position_with_flags) & DWB_BLOCKS_STATUS_MASK) != 0)

Definition at line 104 of file double_write_buffer.c.

Referenced by dwb_acquire_next_slot().

#define DWB_IS_BLOCK_WRITE_STARTED (   position_with_flags,
  block_no 
)    (assert (block_no < DWB_MAX_BLOCKS), ((position_with_flags) & (1ULL << (63 - (block_no)))) != 0)
#define DWB_IS_CREATED (   position_with_flags)    (((position_with_flags) & DWB_CREATE) != 0)
#define DWB_IS_MODIFYING_STRUCTURE (   position_with_flags)    (((position_with_flags) & DWB_MODIFY_STRUCTURE) != 0)
#define dwb_Log   dwb_Global.logging_enabled

Definition at line 308 of file double_write_buffer.c.

#define DWB_LOG2_BLOCK_NUM_PAGES   (dwb_Global.log2_num_block_pages)

Definition at line 61 of file double_write_buffer.c.

#define DWB_MAX_BLOCKS   32
#define DWB_MAX_SIZE   (32 * 1024 * 1024)

Definition at line 47 of file double_write_buffer.c.

Referenced by dwb_adjust_write_buffer_values().

#define DWB_MIN_BLOCKS   1

Definition at line 48 of file double_write_buffer.c.

Referenced by dwb_adjust_write_buffer_values().

#define DWB_MIN_SIZE   (512 * 1024)

Definition at line 46 of file double_write_buffer.c.

Referenced by dwb_adjust_write_buffer_values().

#define DWB_MODIFY_STRUCTURE   0x0000000080000000

Definition at line 71 of file double_write_buffer.c.

#define DWB_NOT_CREATED_OR_MODIFYING (   position_with_flags)    (((position_with_flags) & DWB_CREATE_OR_MODIFY_MASK) != DWB_CREATE)

Definition at line 141 of file double_write_buffer.c.

Referenced by dwb_acquire_next_slot(), and dwb_flush_force().

#define DWB_NUM_TOTAL_PAGES   (dwb_Global.num_pages)

Definition at line 55 of file double_write_buffer.c.

#define DWB_POSITION_MASK   0x000000003fffffff

Definition at line 65 of file double_write_buffer.c.

#define DWB_RESET_POSITION (   position_with_flags)    ((position_with_flags) & DWB_FLAG_MASK)

Definition at line 88 of file double_write_buffer.c.

Referenced by dwb_create_internal(), and dwb_destroy_internal().

#define DWB_SLOTS_FREE_LIST_SIZE   100

Definition at line 44 of file double_write_buffer.c.

Referenced by dwb_create_internal().

#define DWB_SLOTS_HASH_SIZE   1000

Definition at line 43 of file double_write_buffer.c.

Referenced by dwb_create_internal().

#define DWB_STARTS_BLOCK_WRITING (   position_with_flags,
  block_no 
)    (assert (block_no < DWB_MAX_BLOCKS), (position_with_flags) | (1ULL << (63 - (block_no))))

Definition at line 108 of file double_write_buffer.c.

Referenced by dwb_acquire_next_slot().

#define DWB_STARTS_CREATION (   position_with_flags)    ((position_with_flags) | DWB_CREATE)

Definition at line 129 of file double_write_buffer.c.

Referenced by dwb_create_internal().

#define DWB_STARTS_MODIFYING_STRUCTURE (   position_with_flags)    ((position_with_flags) | DWB_MODIFY_STRUCTURE)

Definition at line 117 of file double_write_buffer.c.

Referenced by dwb_starts_structure_modification().

#define DWB_WAIT_QUEUE_INITIALIZER   {NULL, NULL, NULL, 0, 0}

Definition at line 188 of file double_write_buffer.c.

#define pthread_mutex_destroy (   a)
#define pthread_mutex_init (   a,
 
)

Typedef Documentation

Definition at line 258 of file double_write_buffer.c.

typedef struct double_write_block DWB_BLOCK

Definition at line 208 of file double_write_buffer.c.

Definition at line 228 of file double_write_buffer.c.

Definition at line 178 of file double_write_buffer.c.

Definition at line 198 of file double_write_buffer.c.

Enumeration Type Documentation

Enumerator
VOLUME_NOT_FLUSHED 
VOLUME_FLUSHED_BY_DWB_FILE_SYNC_HELPER_THREAD 
VOLUME_FLUSHED_BY_DWB_FLUSH_THREAD 

Definition at line 191 of file double_write_buffer.c.

Function Documentation

STATIC_INLINE void dwb_adjust_write_buffer_values ( unsigned int *  p_double_write_buffer_size,
unsigned int *  p_num_blocks 
)

Definition at line 729 of file double_write_buffer.c.

References assert, DWB_MAX_BLOCKS, DWB_MAX_SIZE, DWB_MIN_BLOCKS, DWB_MIN_SIZE, IS_POWER_OF_2, and STATIC_INLINE.

Referenced by dwb_create_internal().

Here is the caller graph for this function:

STATIC_INLINE int dwb_block_create_ordered_slots ( DWB_BLOCK block,
DWB_SLOT **  p_dwb_ordered_slots,
unsigned int *  p_ordered_slots_length 
)
STATIC_INLINE DWB_WAIT_QUEUE_ENTRY * dwb_block_disconnect_wait_queue_entry ( DWB_WAIT_QUEUE wait_queue,
void *  data 
)
STATIC_INLINE void dwb_block_free_wait_queue_entry ( DWB_WAIT_QUEUE wait_queue,
DWB_WAIT_QUEUE_ENTRY wait_queue_entry,
int(*)(void *)  func 
)

Definition at line 601 of file double_write_buffer.c.

References double_write_wait_queue::free_count, double_write_wait_queue::free_list, double_write_wait_queue_entry::next, and STATIC_INLINE.

Referenced by dwb_remove_wait_queue_entry().

Here is the caller graph for this function:

static int dwb_compare_slots ( const void *  arg1,
const void *  arg2 
)
static

Definition at line 1767 of file double_write_buffer.c.

References assert, diff, double_write_slot::lsa, log_lsa::offset, log_lsa::pageid, vpid::pageid, STATIC_INLINE, vpid::volid, and double_write_slot::vpid.

Referenced by dwb_block_create_ordered_slots().

Here is the caller graph for this function:

static int dwb_compare_vol_fd ( const void *  v1,
const void *  v2 
)
static

Definition at line 1924 of file double_write_buffer.c.

References assert, and STATIC_INLINE.

int dwb_create ( THREAD_ENTRY thread_p,
const char *  dwb_path_p,
const char *  db_name_p 
)
STATIC_INLINE int dwb_create_blocks ( THREAD_ENTRY thread_p,
unsigned int  num_blocks,
unsigned int  num_block_pages,
DWB_BLOCK **  p_blocks 
)
static int dwb_debug_check_dwb ( THREAD_ENTRY thread_p,
DWB_SLOT p_dwb_ordered_slots,
unsigned int  num_pages 
)
static

Definition at line 2909 of file double_write_buffer.c.

References assert, fileio_page_check_corruption(), i, IO_MAX_PAGE_SIZE, IO_PAGESIZE, MAX_ALIGNMENT, NO_ERROR, PTR_ALIGN, VPID_EQ, and VPID_ISNULL.

Referenced by dwb_load_and_recover_pages().

Here is the caller graph for this function:

int dwb_destroy ( THREAD_ENTRY thread_p)

Definition at line 3299 of file double_write_buffer.c.

References dwb_destroy_internal(), dwb_ends_structure_modification(), DWB_IS_CREATED, dwb_starts_structure_modification(), and NO_ERROR.

Referenced by logpb_copy_database(), and xboot_shutdown_server().

Here is the caller graph for this function:

STATIC_INLINE void dwb_destroy_wait_queue ( DWB_WAIT_QUEUE wait_queue,
pthread_mutex_t *  mutex 
)
STATIC_INLINE void dwb_ends_structure_modification ( THREAD_ENTRY thread_p,
UINT64  current_position_with_flags 
)

Definition at line 909 of file double_write_buffer.c.

References assert, DWB_ENDS_MODIFYING_STRUCTURE, dwb_signal_structure_modificated(), double_write_buffer::position_with_flags, and STATIC_INLINE.

Referenced by dwb_create(), dwb_destroy(), and dwb_recreate().

Here is the caller graph for this function:

static bool dwb_file_sync_helper_daemon_is_running ( void  )
static

Definition at line 4066 of file double_write_buffer.c.

References cubthread::daemon::is_running(), prm_get_bool_value(), and PRM_ID_ENABLE_DWB_FLUSH_THREAD.

Referenced by dwb_starts_structure_modification().

Here is the caller graph for this function:

STATIC_INLINE int dwb_flush_block ( THREAD_ENTRY thread_p,
DWB_BLOCK block,
bool  file_sync_helper_can_flush,
UINT64 *  current_position_with_flags 
)

Definition at line 2170 of file double_write_buffer.c.

References flush_volume_info::all_pages_written, double_write_block::all_pages_written, log_global::append, assert, assert_release, double_write_block::block_no, double_write_buffer::blocks_flush_counter, double_write_block::count_flush_volumes_info, double_write_block::count_wb_pages, dwb_block_create_ordered_slots(), DWB_BLOCK_NUM_PAGES, DWB_ENDS_BLOCK_WRITING, DWB_GET_NEXT_BLOCK_NO, dwb_is_created(), dwb_is_file_sync_helper_daemon_available(), DWB_IS_MODIFYING_STRUCTURE, dwb_log, dwb_signal_block_completion(), dwb_Volume_name, dwb_write_block(), ER_FAILED, double_write_buffer::file_sync_helper_block, fileio_initialize_res(), FILEIO_SYNC_ONLY, fileio_synchronize(), FILEIO_WRITE_NO_COMPENSATE_WRITE, fileio_write_pages(), double_write_block::flush_volumes_info, flush_volume_info::flushed_status, free_and_init, log_append_info::get_nxio_lsa(), i, double_write_slot::io_page, IO_PAGESIZE, log_Gl, logpb_need_wal(), double_write_slot::lsa, fileio_page_reserved::lsa, LSA_ISNULL(), LSA_LE(), double_write_buffer::next_block_to_flush, NO_ERROR, NULL, NULL_PAGEID, NULL_VOLDES, flush_volume_info::num_pages, fileio_page_reserved::p_reserve_2, fileio_page_reserved::pageid, PERFMON_ACTIVATION_FLAG_FLUSHED_BLOCK_VOLUMES, perfmon_add_stat(), perfmon_is_perf_tracking_and_active(), double_write_slot::position_in_block, double_write_buffer::position_with_flags, prm_get_integer_value(), PRM_ID_PB_SYNC_ON_NFLUSH, fileio_page::prv, PSTAT_DWB_FLUSH_BLOCK_SORT_TIME_COUNTERS, PSTAT_DWB_FLUSH_BLOCK_TIME_COUNTERS, PSTAT_DWB_WAIT_FILE_SYNC_HELPER_TIME_COUNTERS, PSTAT_PB_NUM_IOWRITES, SERVER_MODE, double_write_block::slots, STATIC_INLINE, thread_sleep(), flush_volume_info::vdes, double_write_buffer::vdes, double_write_block::version, VOLUME_FLUSHED_BY_DWB_FLUSH_THREAD, VOLUME_NOT_FLUSHED, double_write_slot::vpid, VPID_EQ, VPID_ISNULL, VPID_SET_NULL, and double_write_block::write_buffer.

Referenced by dwb_add_page(), dwb_flush_next_block(), and dwb_starts_structure_modification().

Here is the caller graph for this function:

static bool dwb_flush_block_daemon_is_running ( void  )
static

Definition at line 4050 of file double_write_buffer.c.

References prm_get_bool_value(), and PRM_ID_ENABLE_DWB_FLUSH_THREAD.

Referenced by dwb_starts_structure_modification().

Here is the caller graph for this function:

STATIC_INLINE void dwb_get_next_block_for_flush ( THREAD_ENTRY thread_p,
unsigned int *  block_no 
)
char* dwb_get_volume_name ( void  )

Definition at line 3336 of file double_write_buffer.c.

References dwb_is_created(), dwb_Volume_name, and NULL.

STATIC_INLINE void dwb_init_slot ( DWB_SLOT slot)

Definition at line 2614 of file double_write_buffer.c.

References assert, double_write_slot::io_page, double_write_slot::lsa, LSA_SET_NULL(), NULL, STATIC_INLINE, double_write_slot::vpid, and VPID_SET_NULL.

Referenced by dwb_block_create_ordered_slots().

Here is the caller graph for this function:

STATIC_INLINE void dwb_initialize_block ( DWB_BLOCK block,
unsigned int  block_no,
unsigned int  count_wb_pages,
char *  write_buffer,
DWB_SLOT slots,
FLUSH_VOLUME_INFO flush_volumes_info,
unsigned int  count_flush_volumes_info,
unsigned int  max_to_flush_vdes 
)
STATIC_INLINE void dwb_initialize_slot ( DWB_SLOT slot,
FILEIO_PAGE io_page,
unsigned int  position_in_block,
unsigned int  block_no 
)
static bool dwb_is_file_sync_helper_daemon_available ( void  )
static

Definition at line 4035 of file double_write_buffer.c.

References NULL, prm_get_bool_value(), and PRM_ID_ENABLE_DWB_FLUSH_THREAD.

Referenced by dwb_flush_block(), and dwb_write_block().

Here is the caller graph for this function:

static bool dwb_is_flush_block_daemon_available ( void  )
static

Definition at line 4021 of file double_write_buffer.c.

References NULL, prm_get_bool_value(), and PRM_ID_ENABLE_DWB_FLUSH_THREAD.

Referenced by dwb_add_page().

Here is the caller graph for this function:

STATIC_INLINE void dwb_remove_wait_queue_entry ( DWB_WAIT_QUEUE wait_queue,
pthread_mutex_t *  mutex,
void *  data,
int(*)(void *)  func 
)
int dwb_set_data_on_next_slot ( THREAD_ENTRY thread_p,
FILEIO_PAGE io_page_p,
bool  can_wait,
DWB_SLOT **  p_dwb_slot 
)

Definition at line 2657 of file double_write_buffer.c.

References assert, dwb_acquire_next_slot(), dwb_set_slot_data(), and NO_ERROR.

Referenced by dwb_add_page(), and pgbuf_bcb_flush_with_wal().

Here is the caller graph for this function:

STATIC_INLINE int dwb_set_status_resumed ( void *  data)

Definition at line 1507 of file double_write_buffer.c.

References double_write_wait_queue_entry::data, if(), NO_ERROR, STATIC_INLINE, THREAD_DWB_QUEUE_RESUMED, thread_lock_entry(), and thread_unlock_entry().

Referenced by dwb_wait_for_block_completion().

Here is the caller graph for this function:

STATIC_INLINE void dwb_signal_block_completion ( THREAD_ENTRY thread_p,
DWB_BLOCK dwb_block 
)

Definition at line 1662 of file double_write_buffer.c.

References assert, dwb_signal_waiting_threads(), double_write_block::mutex, STATIC_INLINE, and double_write_block::wait_queue.

Referenced by dwb_flush_block().

Here is the caller graph for this function:

STATIC_INLINE void dwb_signal_structure_modificated ( THREAD_ENTRY thread_p)

Definition at line 1677 of file double_write_buffer.c.

References dwb_signal_waiting_threads(), double_write_buffer::mutex, STATIC_INLINE, and double_write_buffer::wait_queue.

Referenced by dwb_ends_structure_modification().

Here is the caller graph for this function:

STATIC_INLINE int dwb_signal_waiting_thread ( void *  data)
STATIC_INLINE void dwb_signal_waiting_threads ( DWB_WAIT_QUEUE wait_queue,
pthread_mutex_t *  mutex 
)
static int dwb_slots_hash_compare_key ( void *  key1,
void *  key2 
)
static

Definition at line 1334 of file double_write_buffer.c.

References VPID_EQ.

static void * dwb_slots_hash_entry_alloc ( void  )
static
static int dwb_slots_hash_entry_free ( void *  entry)
static
static int dwb_slots_hash_entry_init ( void *  entry)
static
static unsigned int dwb_slots_hash_key ( void *  key,
int  hash_table_size 
)
static

Definition at line 1352 of file double_write_buffer.c.

References vpid::pageid, STATIC_INLINE, and vpid::volid.

static int dwb_slots_hash_key_copy ( void *  src,
void *  dest 
)
static

Definition at line 1315 of file double_write_buffer.c.

References ER_FAILED, NO_ERROR, and VPID_COPY.

Variable Documentation

DOUBLE_WRITE_BUFFER dwb_Global
static

Definition at line 306 of file double_write_buffer.c.

char dwb_Volume_name[PATH_MAX]
LF_ENTRY_DESCRIPTOR slots_entry_Descriptor
static
Initial value:
= {
offsetof (DWB_SLOTS_HASH_ENTRY, stack),
offsetof (DWB_SLOTS_HASH_ENTRY, next),
offsetof (DWB_SLOTS_HASH_ENTRY, del_id),
NULL
}
static int dwb_slots_hash_key_copy(void *src, void *dest)
static API_MUTEX mutex
Definition: api_util.c:72
static void * dwb_slots_hash_entry_alloc(void)
static int dwb_slots_hash_compare_key(void *key1, void *key2)
#define NULL
Definition: freelistheap.h:34
static int dwb_slots_hash_entry_init(void *entry)
static unsigned int dwb_slots_hash_key(void *key, int hash_table_size)
#define LF_EM_USING_MUTEX
Definition: lock_free.h:60
static int dwb_slots_hash_entry_free(void *entry)

Definition at line 421 of file double_write_buffer.c.