summaryrefslogtreecommitdiff
path: root/storage/innobase/buf/buf0buf.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/buf/buf0buf.cc')
-rw-r--r--storage/innobase/buf/buf0buf.cc272
1 files changed, 113 insertions, 159 deletions
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 078361092fc..6bde6939fd6 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -525,7 +525,7 @@ decrypt_failed:
@retval 0 if all modified persistent pages have been flushed */
lsn_t buf_pool_t::get_oldest_modification()
{
- mutex_enter(&flush_list_mutex);
+ mysql_mutex_lock(&flush_list_mutex);
/* FIXME: Keep temporary tablespace pages in a separate flush
list. We would only need to write out temporary pages if the
@@ -538,7 +538,7 @@ lsn_t buf_pool_t::get_oldest_modification()
ut_ad(bpage->oldest_modification());
lsn_t oldest_lsn= bpage ? bpage->oldest_modification() : 0;
- mutex_exit(&flush_list_mutex);
+ mysql_mutex_unlock(&flush_list_mutex);
/* The result may become stale as soon as we released the mutex.
On log checkpoint, also log_sys.flush_order_mutex will be needed. */
@@ -1063,14 +1063,14 @@ buf_madvise_do_dump()
ret+= madvise(recv_sys.buf, recv_sys.len, MADV_DODUMP);
}
- mutex_enter(&buf_pool.mutex);
+ mysql_mutex_lock(&buf_pool.mutex);
auto chunk = buf_pool.chunks;
for (ulint n = buf_pool.n_chunks; n--; chunk++) {
ret+= madvise(chunk->mem, chunk->mem_size(), MADV_DODUMP);
}
- mutex_exit(&buf_pool.mutex);
+ mysql_mutex_lock(&buf_pool.mutex);
return ret;
}
#endif
@@ -1546,7 +1546,7 @@ bool buf_pool_t::create()
while (++chunk < chunks + n_chunks);
ut_ad(is_initialised());
- mutex_create(LATCH_ID_BUF_POOL, &mutex);
+ mysql_mutex_init(buf_pool_mutex_key, &mutex, MY_MUTEX_INIT_FAST);
UT_LIST_INIT(LRU, &buf_page_t::LRU);
UT_LIST_INIT(withdraw, &buf_page_t::list);
@@ -1570,17 +1570,18 @@ bool buf_pool_t::create()
zip_hash.create(2 * curr_size);
last_printout_time= time(NULL);
- mutex_create(LATCH_ID_FLUSH_LIST, &flush_list_mutex);
+ mysql_mutex_init(flush_list_mutex_key, &flush_list_mutex,
+ MY_MUTEX_INIT_FAST);
- for (int i= 0; i < 3; i++)
- no_flush[i]= os_event_create(0);
+ mysql_cond_init(0, &done_flush_LRU, nullptr);
+ mysql_cond_init(0, &done_flush_list, nullptr);
+ mysql_cond_init(0, &do_flush_list, nullptr);
try_LRU_scan= true;
ut_d(flush_hp.m_mutex= &flush_list_mutex;);
ut_d(lru_hp.m_mutex= &mutex);
ut_d(lru_scan_itr.m_mutex= &mutex);
- ut_d(single_scan_itr.m_mutex= &mutex);
io_buf.create((srv_n_read_io_threads + srv_n_write_io_threads) *
OS_AIO_N_PENDING_IOS_PER_THREAD);
@@ -1604,8 +1605,8 @@ void buf_pool_t::close()
if (!is_initialised())
return;
- mutex_free(&mutex);
- mutex_free(&flush_list_mutex);
+ mysql_mutex_destroy(&mutex);
+ mysql_mutex_destroy(&flush_list_mutex);
for (buf_page_t *bpage= UT_LIST_GET_LAST(LRU), *prev_bpage= nullptr; bpage;
bpage= prev_bpage)
@@ -1633,8 +1634,9 @@ void buf_pool_t::close()
allocator.deallocate_large_dodump(chunk->mem, &chunk->mem_pfx);
}
- for (int i= 0; i < 3; ++i)
- os_event_destroy(no_flush[i]);
+ mysql_cond_destroy(&done_flush_LRU);
+ mysql_cond_destroy(&done_flush_list);
+ mysql_cond_destroy(&do_flush_list);
ut_free(chunks);
chunks= nullptr;
@@ -1661,7 +1663,7 @@ inline bool buf_pool_t::realloc(buf_block_t *block)
buf_block_t* new_block;
ut_ad(withdrawing);
- ut_ad(mutex_own(&mutex));
+ mysql_mutex_assert_owner(&mutex);
ut_ad(block->page.state() == BUF_BLOCK_FILE_PAGE);
new_block = buf_LRU_get_free_only();
@@ -1732,13 +1734,8 @@ inline bool buf_pool_t::realloc(buf_block_t *block)
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 0xff, 4);
MEM_UNDEFINED(block->frame, srv_page_size);
block->page.set_state(BUF_BLOCK_REMOVE_HASH);
-
- /* Relocate flush_list. */
- if (block->page.oldest_modification()) {
- buf_flush_relocate_on_flush_list(
- &block->page, &new_block->page);
- }
-
+ buf_flush_relocate_on_flush_list(&block->page,
+ &new_block->page);
block->page.set_corrupt_id();
/* set other flags of buf_block_t */
@@ -1804,16 +1801,16 @@ inline bool buf_pool_t::withdraw_blocks()
<< withdraw_target << " blocks";
/* Minimize zip_free[i] lists */
- mutex_enter(&mutex);
+ mysql_mutex_lock(&mutex);
buf_buddy_condense_free();
- mutex_exit(&mutex);
+ mysql_mutex_unlock(&mutex);
while (UT_LIST_GET_LEN(withdraw) < withdraw_target) {
/* try to withdraw from free_list */
ulint count1 = 0;
- mutex_enter(&mutex);
+ mysql_mutex_lock(&mutex);
block = reinterpret_cast<buf_block_t*>(
UT_LIST_GET_FIRST(free));
while (block != NULL
@@ -1828,7 +1825,7 @@ inline bool buf_pool_t::withdraw_blocks()
UT_LIST_GET_NEXT(
list, &block->page));
- if (buf_pool.will_be_withdrawn(block->page)) {
+ if (will_be_withdrawn(block->page)) {
/* This should be withdrawn */
UT_LIST_REMOVE(free, &block->page);
UT_LIST_ADD_LAST(withdraw, &block->page);
@@ -1838,40 +1835,29 @@ inline bool buf_pool_t::withdraw_blocks()
block = next_block;
}
- mutex_exit(&mutex);
+ mysql_mutex_unlock(&mutex);
/* reserve free_list length */
if (UT_LIST_GET_LEN(withdraw) < withdraw_target) {
- ulint scan_depth;
- flush_counters_t n;
-
- /* cap scan_depth with current LRU size. */
- mutex_enter(&mutex);
- scan_depth = UT_LIST_GET_LEN(LRU);
- mutex_exit(&mutex);
+ ulint n_flushed = buf_flush_lists(
+ std::max<ulint>(withdraw_target
+ - UT_LIST_GET_LEN(withdraw),
+ srv_LRU_scan_depth), 0);
+ buf_flush_wait_batch_end_acquiring_mutex(true);
- scan_depth = ut_min(
- ut_max(withdraw_target
- - UT_LIST_GET_LEN(withdraw),
- static_cast<ulint>(srv_LRU_scan_depth)),
- scan_depth);
-
- buf_flush_do_batch(true, scan_depth, 0, &n);
- buf_flush_wait_batch_end(true);
-
- if (n.flushed) {
+ if (n_flushed) {
MONITOR_INC_VALUE_CUMULATIVE(
MONITOR_LRU_BATCH_FLUSH_TOTAL_PAGE,
MONITOR_LRU_BATCH_FLUSH_COUNT,
MONITOR_LRU_BATCH_FLUSH_PAGES,
- n.flushed);
+ n_flushed);
}
}
/* relocate blocks/buddies in withdrawn area */
ulint count2 = 0;
- mutex_enter(&mutex);
+ mysql_mutex_lock(&mutex);
buf_page_t* bpage;
bpage = UT_LIST_GET_FIRST(LRU);
while (bpage != NULL) {
@@ -1892,7 +1878,7 @@ inline bool buf_pool_t::withdraw_blocks()
}
if (bpage->state() == BUF_BLOCK_FILE_PAGE
- && buf_pool.will_be_withdrawn(*bpage)) {
+ && will_be_withdrawn(*bpage)) {
if (bpage->can_relocate()) {
buf_pool_mutex_exit_forbid();
if (!realloc(
@@ -1911,7 +1897,7 @@ inline bool buf_pool_t::withdraw_blocks()
bpage = next_bpage;
}
- mutex_exit(&mutex);
+ mysql_mutex_unlock(&mutex);
buf_resize_status(
"withdrawing blocks. (" ULINTPF "/" ULINTPF ")",
@@ -2031,7 +2017,7 @@ inline void buf_pool_t::page_hash_table::write_unlock_all()
inline void buf_pool_t::write_lock_all_page_hash()
{
- ut_ad(mutex_own(&mutex));
+ mysql_mutex_assert_owner(&mutex);
page_hash.write_lock_all();
for (page_hash_table *old_page_hash= freed_page_hash; old_page_hash;
old_page_hash= static_cast<page_hash_table*>
@@ -2103,7 +2089,7 @@ inline void buf_pool_t::resize()
srv_buf_pool_old_size, srv_buf_pool_size,
srv_buf_pool_chunk_unit);
- mutex_enter(&mutex);
+ mysql_mutex_lock(&mutex);
ut_ad(curr_size == old_size);
ut_ad(n_chunks_new == n_chunks);
ut_ad(UT_LIST_GET_LEN(withdraw) == 0);
@@ -2111,7 +2097,7 @@ inline void buf_pool_t::resize()
n_chunks_new = (new_instance_size << srv_page_size_shift)
/ srv_buf_pool_chunk_unit;
curr_size = n_chunks_new * chunks->size;
- mutex_exit(&mutex);
+ mysql_mutex_unlock(&mutex);
#ifdef BTR_CUR_HASH_ADAPT
/* disable AHI if needed */
@@ -2225,7 +2211,7 @@ withdraw_retry:
/* Indicate critical path */
resizing.store(true, std::memory_order_relaxed);
- mutex_enter(&mutex);
+ mysql_mutex_lock(&mutex);
write_lock_all_page_hash();
chunk_t::map_reg = UT_NEW_NOKEY(chunk_t::map());
@@ -2389,7 +2375,7 @@ calc_buf_pool_size:
ib::info() << "hash tables were resized";
}
- mutex_exit(&mutex);
+ mysql_mutex_unlock(&mutex);
write_unlock_all_page_hash();
UT_DELETE(chunk_map_old);
@@ -2454,10 +2440,10 @@ static void buf_resize_callback(void *)
{
DBUG_ENTER("buf_resize_callback");
ut_a(srv_shutdown_state == SRV_SHUTDOWN_NONE);
- mutex_enter(&buf_pool.mutex);
+ mysql_mutex_lock(&buf_pool.mutex);
const auto size= srv_buf_pool_size;
const bool work= srv_buf_pool_old_size != size;
- mutex_exit(&buf_pool.mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
if (work)
buf_pool.resize();
@@ -2495,7 +2481,7 @@ static void buf_relocate(buf_page_t *bpage, buf_page_t *dpage)
{
const ulint fold= bpage->id().fold();
ut_ad(bpage->state() == BUF_BLOCK_ZIP_PAGE);
- ut_ad(mutex_own(&buf_pool.mutex));
+ mysql_mutex_assert_owner(&buf_pool.mutex);
ut_ad(buf_pool.hash_lock_get(bpage->id())->is_write_locked());
ut_a(bpage->io_fix() == BUF_IO_NONE);
ut_a(!bpage->buf_fix_count());
@@ -2568,7 +2554,7 @@ retry:
(*hash_lock)->write_unlock();
/* Allocate a watch[] and then try to insert it into the page_hash. */
- mutex_enter(&mutex);
+ mysql_mutex_lock(&mutex);
/* The maximum number of purge tasks should never exceed
the UT_ARR_SIZE(watch) - 1, and there is no way for a purge task to hold a
@@ -2592,17 +2578,17 @@ retry:
*hash_lock= page_hash.lock_get(fold);
(*hash_lock)->write_lock();
- mutex_exit(&mutex);
+ mysql_mutex_unlock(&mutex);
buf_page_t *bpage= page_hash_get_low(id, fold);
if (UNIV_LIKELY_NULL(bpage))
{
(*hash_lock)->write_unlock();
- mutex_enter(&mutex);
+ mysql_mutex_lock(&mutex);
w->set_state(BUF_BLOCK_NOT_USED);
*hash_lock= page_hash.lock_get(fold);
(*hash_lock)->write_lock();
- mutex_exit(&mutex);
+ mysql_mutex_unlock(&mutex);
goto retry;
}
@@ -2615,7 +2601,7 @@ retry:
}
ut_error;
- mutex_exit(&mutex);
+ mysql_mutex_unlock(&mutex);
return nullptr;
}
@@ -2733,10 +2719,10 @@ err_exit:
{
discard_attempted= true;
hash_lock->read_unlock();
- mutex_enter(&buf_pool.mutex);
+ mysql_mutex_lock(&buf_pool.mutex);
if (buf_page_t *bpage= buf_pool.page_hash_get_low(page_id, fold))
buf_LRU_free_page(bpage, false);
- mutex_exit(&buf_pool.mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
goto lookup;
}
@@ -3261,14 +3247,14 @@ got_block:
if (UNIV_UNLIKELY(mode == BUF_EVICT_IF_IN_POOL)) {
evict_from_pool:
ut_ad(!fix_block->page.oldest_modification());
- mutex_enter(&buf_pool.mutex);
+ mysql_mutex_lock(&buf_pool.mutex);
fix_block->unfix();
if (!buf_LRU_free_page(&fix_block->page, true)) {
ut_ad(0);
}
- mutex_exit(&buf_pool.mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
return(NULL);
}
@@ -3317,7 +3303,7 @@ evict_from_pool:
block = buf_LRU_get_free_block(false);
buf_block_init_low(block);
- mutex_enter(&buf_pool.mutex);
+ mysql_mutex_lock(&buf_pool.mutex);
hash_lock = buf_pool.page_hash.lock_get(fold);
hash_lock->write_lock();
@@ -3336,7 +3322,7 @@ evict_from_pool:
hash_lock->write_unlock();
buf_LRU_block_free_non_file_page(block);
- mutex_exit(&buf_pool.mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
/* Try again */
goto loop;
@@ -3355,9 +3341,7 @@ evict_from_pool:
/* Set after buf_relocate(). */
block->page.set_buf_fix_count(1);
- if (block->page.oldest_modification()) {
- buf_flush_relocate_on_flush_list(bpage, &block->page);
- }
+ buf_flush_relocate_on_flush_list(bpage, &block->page);
/* Buffer-fix, I/O-fix, and X-latch the block
for the duration of the decompression.
@@ -3372,7 +3356,7 @@ evict_from_pool:
MEM_UNDEFINED(bpage, sizeof *bpage);
- mutex_exit(&buf_pool.mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
hash_lock->write_unlock();
buf_pool.n_pend_unzip++;
@@ -3412,7 +3396,7 @@ evict_from_pool:
ut_ad(fix_block->page.state() == BUF_BLOCK_FILE_PAGE);
#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
-
+re_evict:
if (mode != BUF_GET_IF_IN_POOL
&& mode != BUF_GET_IF_IN_POOL_OR_WATCH) {
} else if (!ibuf_debug) {
@@ -3421,18 +3405,19 @@ evict_from_pool:
/* Try to evict the block from the buffer pool, to use the
insert buffer (change buffer) as much as possible. */
- mutex_enter(&buf_pool.mutex);
+ mysql_mutex_lock(&buf_pool.mutex);
fix_block->unfix();
/* Blocks cannot be relocated or enter or exit the
buf_pool while we are holding the buf_pool.mutex. */
+ const bool evicted = buf_LRU_free_page(&fix_block->page, true);
+ space->release_for_io();
- if (buf_LRU_free_page(&fix_block->page, true)) {
- space->release_for_io();
+ if (evicted) {
hash_lock = buf_pool.page_hash.lock_get(fold);
hash_lock->write_lock();
- mutex_exit(&buf_pool.mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
/* We may set the watch, as it would have
been set if the page were not in the
buffer pool in the first place. */
@@ -3456,20 +3441,16 @@ evict_from_pool:
return(NULL);
}
- bool flushed = fix_block->page.ready_for_flush()
- && buf_flush_page(&fix_block->page,
- IORequest::SINGLE_PAGE, space, true);
- space->release_for_io();
- if (flushed) {
- guess = fix_block;
- goto loop;
- }
-
fix_block->fix();
+ mysql_mutex_unlock(&buf_pool.mutex);
+ buf_flush_lists(ULINT_UNDEFINED, LSN_MAX);
+ buf_flush_wait_batch_end_acquiring_mutex(false);
- /* Failed to evict the page; change it directly */
+ if (!fix_block->page.oldest_modification()) {
+ goto re_evict;
+ }
- mutex_exit(&buf_pool.mutex);
+ /* Failed to evict the page; change it directly */
}
#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
@@ -3793,23 +3774,22 @@ FILE_PAGE (the other is buf_page_get_gen).
@param[in] offset offset of the tablespace
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] mtr mini-transaction
+@param[in,out] free_block pre-allocated buffer block
@return pointer to the block, page bufferfixed */
buf_block_t*
buf_page_create(fil_space_t *space, uint32_t offset,
- ulint zip_size, mtr_t *mtr)
+ ulint zip_size, mtr_t *mtr, buf_block_t *free_block)
{
page_id_t page_id(space->id, offset);
ut_ad(mtr->is_active());
ut_ad(page_id.space() != 0 || !zip_size);
space->free_page(offset, false);
-loop:
- buf_block_t *free_block= buf_LRU_get_free_block(false);
free_block->initialise(page_id, zip_size, 1);
const ulint fold= page_id.fold();
-
- mutex_enter(&buf_pool.mutex);
+loop:
+ mysql_mutex_lock(&buf_pool.mutex);
buf_block_t *block= reinterpret_cast<buf_block_t*>
(buf_pool.page_hash_get_low(page_id, fold));
@@ -3820,7 +3800,7 @@ loop:
#ifdef BTR_CUR_HASH_ADAPT
const dict_index_t *drop_hash_entry= nullptr;
#endif
- switch (block->page.state()) {
+ switch (UNIV_EXPECT(block->page.state(), BUF_BLOCK_FILE_PAGE)) {
default:
ut_ad(0);
break;
@@ -3831,16 +3811,15 @@ loop:
while (block->page.io_fix() != BUF_IO_NONE ||
num_fix_count != block->page.buf_fix_count())
{
- mutex_exit(&buf_pool.mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
os_thread_yield();
- mutex_enter(&buf_pool.mutex);
+ mysql_mutex_lock(&buf_pool.mutex);
}
}
rw_lock_x_lock(&block->lock);
#ifdef BTR_CUR_HASH_ADAPT
drop_hash_entry= block->index;
#endif
- buf_LRU_block_free_non_file_page(free_block);
break;
case BUF_BLOCK_ZIP_PAGE:
page_hash_latch *hash_lock= buf_pool.page_hash.lock_get(fold);
@@ -3849,15 +3828,13 @@ loop:
{
hash_lock->write_unlock();
buf_LRU_block_free_non_file_page(free_block);
- mutex_exit(&buf_pool.mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
goto loop;
}
rw_lock_x_lock(&free_block->lock);
buf_relocate(&block->page, &free_block->page);
-
- if (block->page.oldest_modification() > 0)
- buf_flush_relocate_on_flush_list(&block->page, &free_block->page);
+ buf_flush_relocate_on_flush_list(&block->page, &free_block->page);
free_block->page.set_state(BUF_BLOCK_FILE_PAGE);
buf_unzip_LRU_add_block(free_block, FALSE);
@@ -3868,7 +3845,7 @@ loop:
break;
}
- mutex_exit(&buf_pool.mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
#ifdef BTR_CUR_HASH_ADAPT
if (drop_hash_entry)
@@ -3926,7 +3903,7 @@ loop:
else
hash_lock->write_unlock();
- mutex_exit(&buf_pool.mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
mtr->memo_push(block, MTR_MEMO_PAGE_X_FIX);
block->page.set_accessed();
@@ -4074,12 +4051,12 @@ static void buf_mark_space_corrupt(buf_page_t* bpage, const fil_space_t& space)
/** Release and evict a corrupted page.
@param bpage page that was being read */
-void buf_pool_t::corrupted_evict(buf_page_t *bpage)
+ATTRIBUTE_COLD void buf_pool_t::corrupted_evict(buf_page_t *bpage)
{
const page_id_t id(bpage->id());
page_hash_latch *hash_lock= hash_lock_get(id);
- mutex_enter(&mutex);
+ mysql_mutex_lock(&mutex);
hash_lock->write_lock();
ut_ad(bpage->io_fix() == BUF_IO_READ);
@@ -4094,7 +4071,7 @@ void buf_pool_t::corrupted_evict(buf_page_t *bpage)
/* remove from LRU and page_hash */
buf_LRU_free_one_page(bpage, id, hash_lock);
- mutex_exit(&mutex);
+ mysql_mutex_unlock(&mutex);
ut_d(auto n=) n_pend_reads--;
ut_ad(n > 0);
@@ -4104,6 +4081,7 @@ void buf_pool_t::corrupted_evict(buf_page_t *bpage)
@param[in] bpage Corrupted page
@param[in] node data file
Also remove the bpage from LRU list. */
+ATTRIBUTE_COLD
static void buf_corrupt_page_release(buf_page_t *bpage, const fil_node_t &node)
{
ut_ad(bpage->id().space() == node.space->id);
@@ -4220,7 +4198,7 @@ dberr_t buf_page_read_complete(buf_page_t *bpage, const fil_node_t &node)
{
const page_id_t id(bpage->id());
ut_ad(bpage->in_file());
- ut_ad(id.space() || !buf_dblwr_page_inside(id.page_no()));
+ ut_ad(!buf_dblwr.is_inside(id));
ut_ad(id.space() == node.space->id);
ut_ad(bpage->zip_size() == node.space->zip_size());
@@ -4287,7 +4265,7 @@ dberr_t buf_page_read_complete(buf_page_t *bpage, const fil_node_t &node)
}
err= buf_page_check_corrupt(bpage, node);
- if (err != DB_SUCCESS)
+ if (UNIV_UNLIKELY(err != DB_SUCCESS))
{
database_corrupted:
/* Not a real corruption if it was triggered by error injection */
@@ -4375,12 +4353,12 @@ release_page:
@retval nullptr if all freed */
void buf_pool_t::assert_all_freed()
{
- mutex_enter(&mutex);
+ mysql_mutex_lock(&mutex);
const chunk_t *chunk= chunks;
for (auto i= n_chunks; i--; chunk++)
if (const buf_block_t* block= chunk->not_freed())
ib::fatal() << "Page " << block->page.id() << " still fixed or dirty";
- mutex_exit(&mutex);
+ mysql_mutex_unlock(&mutex);
}
#endif /* UNIV_DEBUG */
@@ -4395,33 +4373,20 @@ void buf_refresh_io_stats()
All pages must be in a replaceable state (not modified or latched). */
void buf_pool_invalidate()
{
- mutex_enter(&buf_pool.mutex);
- ut_ad(!buf_pool.init_flush[IORequest::LRU]);
- ut_ad(!buf_pool.init_flush[IORequest::FLUSH_LIST]);
- ut_ad(!buf_pool.init_flush[IORequest::SINGLE_PAGE]);
- ut_ad(!buf_pool.n_flush[IORequest::SINGLE_PAGE]);
-
- if (buf_pool.n_flush[IORequest::LRU]) {
- mutex_exit(&buf_pool.mutex);
- buf_flush_wait_batch_end(true);
- mutex_enter(&buf_pool.mutex);
- }
+ mysql_mutex_lock(&buf_pool.mutex);
- if (buf_pool.n_flush[IORequest::FLUSH_LIST]) {
- mutex_exit(&buf_pool.mutex);
- buf_flush_wait_batch_end(false);
- mutex_enter(&buf_pool.mutex);
- }
+ buf_flush_wait_batch_end(true);
+ buf_flush_wait_batch_end(false);
/* It is possible that a write batch that has been posted
earlier is still not complete. For buffer pool invalidation to
proceed we must ensure there is NO write activity happening. */
- ut_d(mutex_exit(&buf_pool.mutex));
+ ut_d(mysql_mutex_unlock(&buf_pool.mutex));
ut_d(buf_pool.assert_all_freed());
- ut_d(mutex_enter(&buf_pool.mutex));
+ ut_d(mysql_mutex_lock(&buf_pool.mutex));
- while (buf_LRU_scan_and_free_block(true));
+ while (buf_LRU_scan_and_free_block());
ut_ad(UT_LIST_GET_LEN(buf_pool.LRU) == 0);
ut_ad(UT_LIST_GET_LEN(buf_pool.unzip_LRU) == 0);
@@ -4432,7 +4397,7 @@ void buf_pool_invalidate()
memset(&buf_pool.stat, 0x00, sizeof(buf_pool.stat));
buf_refresh_io_stats();
- mutex_exit(&buf_pool.mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
}
#ifdef UNIV_DEBUG
@@ -4444,7 +4409,7 @@ void buf_pool_t::validate()
ulint n_free = 0;
ulint n_zip = 0;
- mutex_enter(&mutex);
+ mysql_mutex_lock(&mutex);
chunk_t* chunk = chunks;
@@ -4485,7 +4450,7 @@ void buf_pool_t::validate()
/* Check dirty blocks. */
- mutex_enter(&flush_list_mutex);
+ mysql_mutex_lock(&flush_list_mutex);
for (buf_page_t* b = UT_LIST_GET_FIRST(flush_list); b;
b = UT_LIST_GET_NEXT(list, b)) {
ut_ad(b->oldest_modification());
@@ -4511,7 +4476,7 @@ void buf_pool_t::validate()
ut_ad(UT_LIST_GET_LEN(flush_list) == n_flushing);
- mutex_exit(&flush_list_mutex);
+ mysql_mutex_unlock(&flush_list_mutex);
if (curr_size == old_size
&& n_lru + n_free > curr_size + n_zip) {
@@ -4531,7 +4496,7 @@ void buf_pool_t::validate()
<< ", free blocks " << n_free << ". Aborting...";
}
- mutex_exit(&mutex);
+ mysql_mutex_unlock(&mutex);
ut_d(buf_LRU_validate());
ut_d(buf_flush_validate());
@@ -4559,8 +4524,8 @@ void buf_pool_t::print()
counts = static_cast<ulint*>(ut_malloc_nokey(sizeof(ulint) * size));
- mutex_enter(&mutex);
- mutex_enter(&flush_list_mutex);
+ mysql_mutex_lock(&mutex);
+ mysql_mutex_lock(&flush_list_mutex);
ib::info()
<< "[buffer pool: size=" << curr_size
@@ -4570,16 +4535,15 @@ void buf_pool_t::print()
<< UT_LIST_GET_LEN(flush_list)
<< ", n pending decompressions=" << n_pend_unzip
<< ", n pending reads=" << n_pend_reads
- << ", n pending flush LRU=" << n_flush[IORequest::LRU]
- << " list=" << n_flush[IORequest::FLUSH_LIST]
- << " single page=" << n_flush[IORequest::SINGLE_PAGE]
+ << ", n pending flush LRU=" << n_flush_LRU
+ << " list=" << n_flush_list
<< ", pages made young=" << stat.n_pages_made_young
<< ", not young=" << stat.n_pages_not_made_young
<< ", pages read=" << stat.n_pages_read
<< ", created=" << stat.n_pages_created
<< ", written=" << stat.n_pages_written << "]";
- mutex_exit(&flush_list_mutex);
+ mysql_mutex_unlock(&flush_list_mutex);
/* Count the number of blocks belonging to each index in the buffer */
@@ -4620,7 +4584,7 @@ void buf_pool_t::print()
}
}
- mutex_exit(&mutex);
+ mysql_mutex_unlock(&mutex);
for (i = 0; i < n_found; i++) {
index = dict_index_get_if_in_cache(index_ids[i]);
@@ -4650,14 +4614,14 @@ ulint buf_get_latched_pages_number()
{
ulint fixed_pages_number= 0;
- mutex_enter(&buf_pool.mutex);
+ mysql_mutex_lock(&buf_pool.mutex);
for (buf_page_t *b= UT_LIST_GET_FIRST(buf_pool.LRU); b;
b= UT_LIST_GET_NEXT(LRU, b))
if (b->in_file() && (b->buf_fix_count() || b->io_fix() != BUF_IO_NONE))
fixed_pages_number++;
- mutex_exit(&buf_pool.mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
return fixed_pages_number;
}
@@ -4670,8 +4634,8 @@ void buf_stats_get_pool_info(buf_pool_info_t *pool_info)
time_t current_time;
double time_elapsed;
- mutex_enter(&buf_pool.mutex);
- mutex_enter(&buf_pool.flush_list_mutex);
+ mysql_mutex_lock(&buf_pool.mutex);
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
pool_info->pool_size = buf_pool.curr_size;
@@ -4687,19 +4651,11 @@ void buf_stats_get_pool_info(buf_pool_info_t *pool_info)
pool_info->n_pend_reads = buf_pool.n_pend_reads;
- pool_info->n_pending_flush_lru =
- (buf_pool.n_flush[IORequest::LRU]
- + buf_pool.init_flush[IORequest::LRU]);
-
- pool_info->n_pending_flush_list =
- (buf_pool.n_flush[IORequest::FLUSH_LIST]
- + buf_pool.init_flush[IORequest::FLUSH_LIST]);
+ pool_info->n_pending_flush_lru = buf_pool.n_flush_LRU;
- pool_info->n_pending_flush_single_page =
- (buf_pool.n_flush[IORequest::SINGLE_PAGE]
- + buf_pool.init_flush[IORequest::SINGLE_PAGE]);
+ pool_info->n_pending_flush_list = buf_pool.n_flush_list;
- mutex_exit(&buf_pool.flush_list_mutex);
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
current_time = time(NULL);
time_elapsed = 0.001 + difftime(current_time,
@@ -4790,7 +4746,7 @@ void buf_stats_get_pool_info(buf_pool_info_t *pool_info)
pool_info->unzip_cur = buf_LRU_stat_cur.unzip;
buf_refresh_io_stats();
- mutex_exit(&buf_pool.mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
}
/*********************************************************************//**
@@ -4813,8 +4769,7 @@ buf_print_io_instance(
"Percent of dirty pages(LRU & free pages): %.3f\n"
"Max dirty pages percent: %.3f\n"
"Pending reads " ULINTPF "\n"
- "Pending writes: LRU " ULINTPF ", flush list " ULINTPF
- ", single page " ULINTPF "\n",
+ "Pending writes: LRU " ULINTPF ", flush list " ULINTPF "\n",
pool_info->pool_size,
pool_info->free_list_len,
pool_info->lru_len,
@@ -4827,8 +4782,7 @@ buf_print_io_instance(
srv_max_buf_pool_modified_pct,
pool_info->n_pend_reads,
pool_info->n_pending_flush_lru,
- pool_info->n_pending_flush_list,
- pool_info->n_pending_flush_single_page);
+ pool_info->n_pending_flush_list);
fprintf(file,
"Pages made young " ULINTPF ", not young " ULINTPF "\n"