#include "univ.i"#include "ut0lst.h"#include "sync0sync.h"#include "os0sync.h"Include dependency graph for sync0rw.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
| #define rw_lock_create | ( | L, | |||
| level | ) | rw_lock_create_func((L), (level), __FILE__, __LINE__, #L) |
Definition at line 64 of file sync0rw.h.
Referenced by btr_search_sys_create(), buf_block_init(), dict_init(), dict_tree_create(), fil_space_create(), log_init(), and trx_purge_sys_create().
| #define RW_LOCK_MAGIC_N 22643 |
Definition at line 455 of file sync0rw.h.
Referenced by rw_lock_create_func(), rw_lock_free(), and rw_lock_validate().
| #define rw_lock_s_lock | ( | M | ) |
Value:
rw_lock_s_lock_func(\ (M), 0, __FILE__, __LINE__)
Definition at line 102 of file sync0rw.h.
Referenced by btr_cur_search_to_nth_level(), btr_search_build_page_hash_index(), btr_search_drop_page_hash_index(), btr_search_guess_on_hash(), btr_search_move_or_delete_hash_entries(), log_checkpoint(), recv_synchronize_groups(), row_mysql_freeze_data_dictionary(), row_search_for_mysql(), row_sel(), row_vers_build_for_consistent_read(), and row_vers_build_for_semi_consistent_read().
| #define rw_lock_s_lock_gen | ( | M, | |||
| P | ) |
Value:
rw_lock_s_lock_func(\ (M), (P), __FILE__, __LINE__)
Definition at line 108 of file sync0rw.h.
Referenced by buf_flush_try_page().
| #define rw_lock_s_lock_nowait | ( | M | ) |
Value:
rw_lock_s_lock_func_nowait(\ (M), __FILE__, __LINE__)
| #define rw_lock_s_unlock | ( | L | ) | rw_lock_s_unlock_func(L) |
Definition at line 174 of file sync0rw.h.
Referenced by btr_cur_search_to_nth_level(), btr_search_build_page_hash_index(), btr_search_drop_page_hash_index(), btr_search_guess_on_hash(), btr_search_move_or_delete_hash_entries(), buf_page_get_gen(), buf_page_get_known_nowait(), buf_page_optimistic_get_func(), log_checkpoint(), mtr_memo_slot_release(), recv_synchronize_groups(), row_mysql_unfreeze_data_dictionary(), row_search_for_mysql(), row_sel(), row_vers_build_for_consistent_read(), row_vers_build_for_semi_consistent_read(), and trx_search_latch_release_if_reserved().
| #define rw_lock_s_unlock_gen | ( | L, | |||
| P | ) | rw_lock_s_unlock_func(L) |
| #define rw_lock_x_lock | ( | M | ) |
Value:
rw_lock_x_lock_func(\ (M), 0, __FILE__, __LINE__)
Definition at line 188 of file sync0rw.h.
Referenced by btr_cur_del_mark_set_clust_rec(), btr_cur_del_mark_set_sec_rec(), btr_cur_update_in_place(), btr_search_build_page_hash_index(), btr_search_check_free_space_in_heap(), btr_search_drop_page_hash_index(), btr_search_info_update_slow(), btr_search_update_hash_node_on_insert(), btr_search_update_hash_on_delete(), btr_search_update_hash_on_insert(), btr_search_validate(), page_set_max_trx_id(), row_mysql_lock_data_dictionary(), and trx_purge().
| #define rw_lock_x_lock_gen | ( | M, | |||
| P | ) |
Value:
rw_lock_x_lock_func(\ (M), (P), __FILE__, __LINE__)
Definition at line 194 of file sync0rw.h.
Referenced by buf_page_init_for_read(), and log_group_checkpoint().
| #define rw_lock_x_lock_nowait | ( | M | ) |
Value:
rw_lock_x_lock_func_nowait(\ (M), __FILE__, __LINE__)
| #define rw_lock_x_unlock | ( | L | ) | rw_lock_x_unlock_func(L) |
Definition at line 238 of file sync0rw.h.
Referenced by btr_cur_del_mark_set_clust_rec(), btr_cur_del_mark_set_sec_rec(), btr_cur_update_in_place(), btr_search_build_page_hash_index(), btr_search_check_free_space_in_heap(), btr_search_drop_page_hash_index(), btr_search_info_update_slow(), btr_search_update_hash_node_on_insert(), btr_search_update_hash_on_delete(), btr_search_update_hash_on_insert(), btr_search_validate(), buf_page_optimistic_get_func(), mtr_memo_slot_release(), page_set_max_trx_id(), row_mysql_unlock_data_dictionary(), and trx_purge().
| #define rw_lock_x_unlock_gen | ( | L, | |||
| P | ) | rw_lock_x_unlock_func(L) |
Definition at line 246 of file sync0rw.h.
Referenced by buf_page_io_complete(), and log_complete_checkpoint().
| #define RW_NO_LATCH 3 |
Definition at line 25 of file sync0rw.h.
Referenced by btr_cur_open_at_index_side(), btr_cur_open_at_rnd_pos(), btr_cur_search_to_nth_level(), buf_page_get_gen(), and lock_rec_print().
| #define RW_S_LATCH 1 |
Definition at line 23 of file sync0rw.h.
Referenced by btr_copy_externally_stored_field(), btr_cur_latch_leaves(), btr_search_drop_page_hash_when_freed(), buf_page_get_gen(), buf_page_get_known_nowait(), buf_page_optimistic_get_func(), lock_rec_print(), row_mysql_freeze_data_dictionary(), row_mysql_unfreeze_data_dictionary(), row_sel_open_pcur(), row_sel_try_search_shortcut_for_mysql(), srv_suspend_mysql_thread(), trx_purge_choose_next_log(), trx_undo_get_first_rec(), trx_undo_get_next_rec(), and trx_undo_get_next_rec_from_next_page().
| #define RW_X_LATCH 2 |
Definition at line 24 of file sync0rw.h.
Referenced by btr_attach_half_pages(), btr_compress(), btr_create(), btr_cur_latch_leaves(), btr_cur_search_to_nth_level(), btr_discard_page(), btr_free_but_not_root(), btr_free_externally_stored_field(), btr_free_root(), btr_level_list_remove(), btr_node_ptr_get_child(), btr_page_alloc(), btr_page_alloc_for_ibuf(), btr_root_get(), btr_store_big_rec_extern_fields(), btr_validate_level(), buf_page_get_gen(), buf_page_get_known_nowait(), buf_page_optimistic_get_func(), dict_hdr_get(), dict_table_get_on_id(), dict_truncate_index_tree(), flst_add_first(), flst_add_last(), flst_cut_end(), flst_insert_after(), flst_insert_before(), flst_remove(), flst_validate(), fseg_alloc_free_page_low(), fseg_create_general(), fseg_free(), fseg_inode_get(), fsp_alloc_free_page(), fsp_alloc_seg_inode(), fsp_alloc_seg_inode_page(), fsp_fill_free_list(), fsp_get_space_header(), fsp_header_init(), fsp_print(), fsp_validate(), ibuf_add_free_page(), ibuf_bitmap_get_map_page(), ibuf_data_init_for_space(), ibuf_get_volume_buffered(), ibuf_header_page_get(), ibuf_merge_or_delete_for_page(), ibuf_remove_free_page(), ibuf_tree_root_get(), lock_rec_print(), lock_rec_validate_page(), recv_apply_hashed_log_recs(), recv_recover_page(), row_create_table_for_mysql(), row_drop_table_for_mysql(), row_mysql_lock_data_dictionary(), row_mysql_unlock_data_dictionary(), row_purge_upd_exist_or_extern(), trx_sys_create_doublewrite_buf(), trx_sys_mark_upgraded_to_multiple_tablespaces(), trx_undo_get_next_rec_from_next_page(), trx_undo_report_row_operation(), trx_undo_truncate_start(), xdes_get_descriptor(), xdes_get_descriptor_with_space_hdr(), and xdes_lst_get_descriptor().
| typedef struct rw_lock_struct rw_lock_t |
| void rw_lock_create_func | ( | rw_lock_t * | lock, | |
| ulint | level, | |||
| const char * | cfile_name, | |||
| ulint | cline, | |||
| const char * | cmutex_name | |||
| ) |
Definition at line 89 of file sync0rw.c.
References FALSE, list(), lock, mutex_create, mutex_enter, mutex_exit(), rw_lock_list, rw_lock_list_mutex, RW_LOCK_MAGIC_N, RW_LOCK_NOT_LOCKED, SYNC_NO_ORDER_CHECK, ut_a, UT_LIST_ADD_FIRST, UT_LIST_GET_FIRST, UT_LIST_GET_LEN, and UT_LIST_INIT.
00091 : pointer to memory */ 00092 ulint level, /* in: level */ 00093 const char* cfile_name, /* in: file name where created */ 00094 ulint cline, /* in: file line where created */ 00095 const char* cmutex_name) /* in: mutex name */ 00096 { 00097 /* If this is the very first time a synchronization object is 00098 created, then the following call initializes the sync system. */ 00099 00100 mutex_create(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK); 00101 00102 lock->mutex.cfile_name = cfile_name; 00103 lock->mutex.cline = cline; 00104 00105 #ifndef UNIV_HOTBACKUP 00106 lock->mutex.cmutex_name = cmutex_name; 00107 lock->mutex.mutex_type = 1; 00108 #endif /* !UNIV_HOTBACKUP */ 00109 00110 rw_lock_set_waiters(lock, 0); 00111 rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED); 00112 lock->writer_count = 0; 00113 rw_lock_set_reader_count(lock, 0); 00114 00115 lock->writer_is_wait_ex = FALSE; 00116 00117 #ifdef UNIV_SYNC_DEBUG 00118 UT_LIST_INIT(lock->debug_list); 00119 #endif /* UNIV_SYNC_DEBUG */ 00120 00121 lock->level = level; 00122 00123 lock->magic_n = RW_LOCK_MAGIC_N; 00124 00125 lock->cfile_name = cfile_name; 00126 lock->cline = cline; 00127 00128 lock->last_s_file_name = "not yet reserved"; 00129 lock->last_x_file_name = "not yet reserved"; 00130 lock->last_s_line = 0; 00131 lock->last_x_line = 0; 00132 00133 mutex_enter(&rw_lock_list_mutex); 00134 00135 if (UT_LIST_GET_LEN(rw_lock_list) > 0) { 00136 ut_a(UT_LIST_GET_FIRST(rw_lock_list)->magic_n 00137 == RW_LOCK_MAGIC_N); 00138 } 00139 00140 UT_LIST_ADD_FIRST(list, rw_lock_list, lock); 00141 00142 mutex_exit(&rw_lock_list_mutex); 00143 }
Here is the call graph for this function:

| void rw_lock_free | ( | rw_lock_t * | lock | ) |
Definition at line 151 of file sync0rw.c.
References list(), lock, mutex_enter, mutex_exit(), mutex_free(), rw_lock_get_reader_count(), rw_lock_get_waiters(), rw_lock_get_writer(), rw_lock_list, rw_lock_list_mutex, RW_LOCK_MAGIC_N, RW_LOCK_NOT_LOCKED, rw_lock_validate(), ut_a, UT_LIST_GET_NEXT, UT_LIST_GET_PREV, and UT_LIST_REMOVE.
Referenced by dict_tree_free(), and fil_space_free().
00153 : rw-lock */ 00154 { 00155 #ifdef UNIV_DEBUG 00156 ut_a(rw_lock_validate(lock)); 00157 #endif /* UNIV_DEBUG */ 00158 ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED); 00159 ut_a(rw_lock_get_waiters(lock) == 0); 00160 ut_a(rw_lock_get_reader_count(lock) == 0); 00161 00162 lock->magic_n = 0; 00163 00164 mutex_free(rw_lock_get_mutex(lock)); 00165 00166 mutex_enter(&rw_lock_list_mutex); 00167 00168 if (UT_LIST_GET_PREV(list, lock)) { 00169 ut_a(UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N); 00170 } 00171 if (UT_LIST_GET_NEXT(list, lock)) { 00172 ut_a(UT_LIST_GET_NEXT(list, lock)->magic_n == RW_LOCK_MAGIC_N); 00173 } 00174 00175 UT_LIST_REMOVE(list, rw_lock_list, lock); 00176 00177 mutex_exit(&rw_lock_list_mutex); 00178 }
Here is the call graph for this function:

Here is the caller graph for this function:

Referenced by rw_lock_free(), rw_lock_validate(), rw_lock_x_lock_func(), rw_lock_x_lock_low(), and sync_arr_cell_can_wake_up().
Here is the caller graph for this function:

Referenced by rw_lock_free(), rw_lock_s_lock_spin(), rw_lock_validate(), rw_lock_x_lock_func(), rw_lock_x_lock_low(), and sync_arr_cell_can_wake_up().
Here is the caller graph for this function:

Referenced by fseg_alloc_free_page_general(), fseg_create_general(), and ibuf_free_excess_pages().
Here is the caller graph for this function:

Definition at line 719 of file sync0rw.c.
References FALSE, lock, mutex_enter, mutex_exit(), RW_LOCK_EX, RW_LOCK_SHARED, rw_lock_validate(), TRUE, ut_ad, and ut_error.
Referenced by rw_lock_x_lock_move_ownership().
00721 : TRUE if locked */ 00722 rw_lock_t* lock, /* in: rw-lock */ 00723 ulint lock_type) /* in: lock type: RW_LOCK_SHARED, 00724 RW_LOCK_EX */ 00725 { 00726 ibool ret = FALSE; 00727 00728 ut_ad(lock); 00729 ut_ad(rw_lock_validate(lock)); 00730 00731 mutex_enter(&(lock->mutex)); 00732 00733 if (lock_type == RW_LOCK_SHARED) { 00734 if (lock->reader_count > 0) { 00735 ret = TRUE; 00736 } 00737 } else if (lock_type == RW_LOCK_EX) { 00738 if (lock->writer == RW_LOCK_EX) { 00739 ret = TRUE; 00740 } 00741 } else { 00742 ut_error; 00743 } 00744 00745 mutex_exit(&(lock->mutex)); 00746 00747 return(ret); 00748 }
Here is the call graph for this function:

Here is the caller graph for this function:

| UNIV_INLINE void rw_lock_s_lock_func | ( | rw_lock_t * | lock, | |
| ulint | pass, | |||
| const char * | file_name, | |||
| ulint | line | |||
| ) |
| UNIV_INLINE ibool rw_lock_s_lock_func_nowait | ( | rw_lock_t * | lock, | |
| const char * | file_name, | |||
| ulint | line | |||
| ) |
Referenced by buf_page_get_gen(), buf_page_get_known_nowait(), and buf_page_optimistic_get_func().
Here is the caller graph for this function:

| UNIV_INLINE void rw_lock_s_unlock_direct | ( | rw_lock_t * | lock | ) |
| UNIV_INLINE void rw_lock_s_unlock_func | ( | rw_lock_t * | lock | ) |
| ibool rw_lock_validate | ( | rw_lock_t * | lock | ) |
Definition at line 185 of file sync0rw.c.
References lock, mutex_enter, mutex_exit(), RW_LOCK_EX, rw_lock_get_reader_count(), rw_lock_get_waiters(), rw_lock_get_writer(), RW_LOCK_MAGIC_N, RW_LOCK_NOT_LOCKED, RW_LOCK_WAIT_EX, TRUE, and ut_a.
Referenced by buf_block_init(), rw_lock_free(), rw_lock_is_locked(), rw_lock_s_lock_spin(), and rw_lock_x_lock_func().
00188 { 00189 ut_a(lock); 00190 00191 mutex_enter(rw_lock_get_mutex(lock)); 00192 00193 ut_a(lock->magic_n == RW_LOCK_MAGIC_N); 00194 ut_a((rw_lock_get_reader_count(lock) == 0) 00195 || (rw_lock_get_writer(lock) != RW_LOCK_EX)); 00196 ut_a((rw_lock_get_writer(lock) == RW_LOCK_EX) 00197 || (rw_lock_get_writer(lock) == RW_LOCK_WAIT_EX) 00198 || (rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED)); 00199 ut_a((rw_lock_get_waiters(lock) == 0) 00200 || (rw_lock_get_waiters(lock) == 1)); 00201 ut_a((lock->writer != RW_LOCK_EX) || (lock->writer_count > 0)); 00202 00203 mutex_exit(rw_lock_get_mutex(lock)); 00204 00205 return(TRUE); 00206 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 432 of file sync0rw.c.
References index(), lock, mutex_enter, mutex_enter_fast, mutex_exit(), os_thread_get_curr_id(), os_thread_pf(), os_thread_yield(), RW_LOCK_EX, rw_lock_get_reader_count(), rw_lock_get_writer(), RW_LOCK_NOT_LOCKED, rw_lock_validate(), RW_LOCK_WAIT_EX, rw_lock_x_lock_low(), rw_x_os_wait_count, rw_x_spin_wait_count, rw_x_system_call_count, srv_print_latch_waits, srv_spin_wait_delay, sync_array_reserve_cell(), sync_array_wait_event(), sync_primary_wait_array, SYNC_SPIN_ROUNDS, ut_ad, ut_delay(), ut_error, and ut_rnd_interval().
00434 : pointer to rw-lock */ 00435 ulint pass, /* in: pass value; != 0, if the lock will 00436 be passed to another thread to unlock */ 00437 const char* file_name,/* in: file name where lock requested */ 00438 ulint line) /* in: line where requested */ 00439 { 00440 ulint index; /* index of the reserved wait cell */ 00441 ulint state; /* lock state acquired */ 00442 ulint i; /* spin round count */ 00443 00444 ut_ad(rw_lock_validate(lock)); 00445 00446 lock_loop: 00447 /* Acquire the mutex protecting the rw-lock fields */ 00448 mutex_enter_fast(&(lock->mutex)); 00449 00450 state = rw_lock_x_lock_low(lock, pass, file_name, line); 00451 00452 mutex_exit(&(lock->mutex)); 00453 00454 if (state == RW_LOCK_EX) { 00455 00456 return; /* Locking succeeded */ 00457 00458 } else if (state == RW_LOCK_NOT_LOCKED) { 00459 00460 /* Spin waiting for the writer field to become free */ 00461 i = 0; 00462 00463 while (rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED 00464 && i < SYNC_SPIN_ROUNDS) { 00465 if (srv_spin_wait_delay) { 00466 ut_delay(ut_rnd_interval(0, 00467 srv_spin_wait_delay)); 00468 } 00469 00470 i++; 00471 } 00472 if (i == SYNC_SPIN_ROUNDS) { 00473 os_thread_yield(); 00474 } 00475 } else if (state == RW_LOCK_WAIT_EX) { 00476 00477 /* Spin waiting for the reader count field to become zero */ 00478 i = 0; 00479 00480 while (rw_lock_get_reader_count(lock) != 0 00481 && i < SYNC_SPIN_ROUNDS) { 00482 if (srv_spin_wait_delay) { 00483 ut_delay(ut_rnd_interval(0, 00484 srv_spin_wait_delay)); 00485 } 00486 00487 i++; 00488 } 00489 if (i == SYNC_SPIN_ROUNDS) { 00490 os_thread_yield(); 00491 } 00492 } else { 00493 i = 0; /* Eliminate a compiler warning */ 00494 ut_error; 00495 } 00496 00497 if (srv_print_latch_waits) { 00498 fprintf(stderr, 00499 "Thread %lu spin wait rw-x-lock at %p cfile %s cline %lu rnds %lu\n", 00500 os_thread_pf(os_thread_get_curr_id()), (void*) lock, 00501 lock->cfile_name, (ulong) lock->cline, (ulong) i); 00502 } 00503 00504 rw_x_spin_wait_count++; 00505 00506 /* We try once again to obtain the lock. Acquire the mutex protecting 00507 the rw-lock fields */ 00508 00509 mutex_enter(rw_lock_get_mutex(lock)); 00510 00511 state = rw_lock_x_lock_low(lock, pass, file_name, line); 00512 00513 if (state == RW_LOCK_EX) { 00514 mutex_exit(rw_lock_get_mutex(lock)); 00515 00516 return; /* Locking succeeded */ 00517 } 00518 00519 rw_x_system_call_count++; 00520 00521 sync_array_reserve_cell(sync_primary_wait_array, 00522 lock, RW_LOCK_EX, 00523 file_name, line, 00524 &index); 00525 00526 rw_lock_set_waiters(lock, 1); 00527 00528 mutex_exit(rw_lock_get_mutex(lock)); 00529 00530 if (srv_print_latch_waits) { 00531 fprintf(stderr, 00532 "Thread %lu OS wait for rw-x-lock at %p cfile %s cline %lu\n", 00533 os_thread_pf(os_thread_get_curr_id()), (void*) lock, 00534 lock->cfile_name, (ulong) lock->cline); 00535 } 00536 00537 rw_x_system_call_count++; 00538 rw_x_os_wait_count++; 00539 00540 sync_array_wait_event(sync_primary_wait_array, index); 00541 00542 goto lock_loop; 00543 }
Here is the call graph for this function:

| UNIV_INLINE ibool rw_lock_x_lock_func_nowait | ( | rw_lock_t * | lock, | |
| const char * | file_name, | |||
| ulint | line | |||
| ) |
Referenced by buf_page_get_gen(), buf_page_get_known_nowait(), and buf_page_optimistic_get_func().
Here is the caller graph for this function:

| void rw_lock_x_lock_move_ownership | ( | rw_lock_t * | lock | ) |
Definition at line 304 of file sync0rw.c.
References lock, mutex_enter, mutex_exit(), os_thread_get_curr_id(), RW_LOCK_EX, rw_lock_is_locked(), and ut_ad.
Referenced by ibuf_merge_or_delete_for_page(), and recv_recover_page().
00306 : lock which was x-locked in the 00307 buffer read */ 00308 { 00309 ut_ad(rw_lock_is_locked(lock, RW_LOCK_EX)); 00310 00311 mutex_enter(&(lock->mutex)); 00312 00313 lock->writer_thread = os_thread_get_curr_id(); 00314 00315 lock->pass = 0; 00316 00317 mutex_exit(&(lock->mutex)); 00318 }
Here is the call graph for this function:

Here is the caller graph for this function:

| UNIV_INLINE void rw_lock_x_unlock_direct | ( | rw_lock_t * | lock | ) |
| UNIV_INLINE void rw_lock_x_unlock_func | ( | rw_lock_t * | lock | ) |
| typedef UT_LIST_BASE_NODE_T | ( | rw_lock_t | ) |
| rw_lock_list_t rw_lock_list |
Definition at line 31 of file sync0rw.c.
Referenced by rw_lock_create_func(), rw_lock_free(), and sync_init().
Definition at line 32 of file sync0rw.c.
Referenced by rw_lock_create_func(), rw_lock_free(), sync_init(), sync_thread_add_level(), and sync_thread_reset_level().
Definition at line 20 of file sync0rw.c.
Referenced by rw_lock_s_lock_spin(), and sync_print_wait_info().
Definition at line 19 of file sync0rw.c.
Referenced by rw_lock_s_lock_spin(), and sync_print_wait_info().
Definition at line 26 of file sync0rw.c.
Referenced by rw_lock_x_lock_func(), and sync_print_wait_info().
Definition at line 25 of file sync0rw.c.
Referenced by rw_lock_x_lock_func(), and sync_print_wait_info().
1.4.7

