Commit 2c8d9a4e authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-10813: Update buf_page_t::buf_fix_count outside mutex

Since MySQL 5.6.16 (and MariaDB Server 10.0.11), changes of
buf_page_t::buf_fix_count are atomic memory operations if
PAGE_ATOMIC_REF_COUNT is defined. Since MySQL 5.7
(and MariaDB Server 10.2.2), the field is always updated
by atomic memory operations.

In a few occurrences, updates of the counter were unnecessarily
surrounded by an acquisition and release of the block mutex
(buf_block_t::mutex or buf_pool_t::zip_mutex). Remove these
unnecessary mutex operations.
parent 945c748a
...@@ -463,11 +463,7 @@ btr_cur_optimistic_latch_leaves( ...@@ -463,11 +463,7 @@ btr_cur_optimistic_latch_leaves(
file, line, mtr)) { file, line, mtr)) {
if (btr_page_get_prev(buf_block_get_frame(block), mtr) if (btr_page_get_prev(buf_block_get_frame(block), mtr)
== left_page_no) { == left_page_no) {
/* adjust buf_fix_count */
buf_page_mutex_enter(block);
buf_block_buf_fix_dec(block); buf_block_buf_fix_dec(block);
buf_page_mutex_exit(block);
*latch_mode = mode; *latch_mode = mode;
return(true); return(true);
} else { } else {
...@@ -483,10 +479,7 @@ btr_cur_optimistic_latch_leaves( ...@@ -483,10 +479,7 @@ btr_cur_optimistic_latch_leaves(
} }
unpin_failed: unpin_failed:
/* unpin the block */ /* unpin the block */
buf_page_mutex_enter(block);
buf_block_buf_fix_dec(block); buf_block_buf_fix_dec(block);
buf_page_mutex_exit(block);
return(false); return(false);
default: default:
......
...@@ -4915,10 +4915,7 @@ buf_page_optimistic_get( ...@@ -4915,10 +4915,7 @@ buf_page_optimistic_get(
} }
if (!success) { if (!success) {
buf_page_mutex_enter(block);
buf_block_buf_fix_dec(block); buf_block_buf_fix_dec(block);
buf_page_mutex_exit(block);
return(FALSE); return(FALSE);
} }
...@@ -4932,10 +4929,7 @@ buf_page_optimistic_get( ...@@ -4932,10 +4929,7 @@ buf_page_optimistic_get(
rw_lock_x_unlock(&block->lock); rw_lock_x_unlock(&block->lock);
} }
buf_page_mutex_enter(block);
buf_block_buf_fix_dec(block); buf_block_buf_fix_dec(block);
buf_page_mutex_exit(block);
return(FALSE); return(FALSE);
} }
...@@ -5040,10 +5034,7 @@ buf_page_get_known_nowait( ...@@ -5040,10 +5034,7 @@ buf_page_get_known_nowait(
} }
if (!success) { if (!success) {
buf_page_mutex_enter(block);
buf_block_buf_fix_dec(block); buf_block_buf_fix_dec(block);
buf_page_mutex_exit(block);
return(FALSE); return(FALSE);
} }
...@@ -5137,10 +5128,7 @@ buf_page_try_get_func( ...@@ -5137,10 +5128,7 @@ buf_page_try_get_func(
} }
if (!success) { if (!success) {
buf_page_mutex_enter(block);
buf_block_buf_fix_dec(block); buf_block_buf_fix_dec(block);
buf_page_mutex_exit(block);
return(NULL); return(NULL);
} }
......
...@@ -1374,11 +1374,8 @@ fsp_page_create( ...@@ -1374,11 +1374,8 @@ fsp_page_create(
} else { } else {
rw_lock_sx_lock(&block->lock); rw_lock_sx_lock(&block->lock);
} }
mutex_enter(&block->mutex);
buf_block_buf_fix_inc(block, __FILE__, __LINE__); buf_block_buf_fix_inc(block, __FILE__, __LINE__);
mutex_exit(&block->mutex);
mtr_memo_push(init_mtr, block, rw_latch == RW_X_LATCH mtr_memo_push(init_mtr, block, rw_latch == RW_X_LATCH
? MTR_MEMO_PAGE_X_FIX : MTR_MEMO_PAGE_SX_FIX); ? MTR_MEMO_PAGE_X_FIX : MTR_MEMO_PAGE_SX_FIX);
......
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