From cdb5b464451f342b5ad42f9a7711418be3be0346 Mon Sep 17 00:00:00 2001 From: marko Date: Thu, 10 Jan 2008 09:37:13 +0000 Subject: [PATCH] branches/zip: Implement wrappers for all operations on the buffer pool mutex. buf_pool->mutex: Rename to buf_pool_mutex, so that the wrappers will have to be used when changes are merged from other source trees. buf_pool->zip_mutex: Rename to buf_pool_zip_mutex. buf_pool_mutex_own(), buf_pool_mutex_enter(), buf_pool_mutex_exit(): Wrappers for buf_pool_mutex. --- btr/btr0cur.c | 4 +- btr/btr0sea.c | 16 ++-- buf/buf0buddy.c | 66 +++++++------- buf/buf0buf.c | 199 ++++++++++++++++++++++--------------------- buf/buf0flu.c | 56 ++++++------ buf/buf0lru.c | 92 ++++++++++---------- buf/buf0rea.c | 20 ++--- handler/i_s.cc | 6 +- include/buf0buddy.h | 18 ++-- include/buf0buddy.ic | 18 ++-- include/buf0buf.h | 44 ++++++---- include/buf0buf.ic | 46 +++++----- include/buf0flu.ic | 6 +- include/buf0lru.h | 4 +- include/mtr0log.ic | 4 +- include/row0upd.ic | 4 +- mtr/mtr0mtr.c | 4 +- 17 files changed, 314 insertions(+), 293 deletions(-) diff --git a/btr/btr0cur.c b/btr/btr0cur.c index c63ae7fbfbc..1bda02a9f4f 100644 --- a/btr/btr0cur.c +++ b/btr/btr0cur.c @@ -3619,7 +3619,7 @@ btr_blob_free( mtr_commit(mtr); - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); mutex_enter(&block->mutex); /* Only free the block if it is still allocated to @@ -3639,7 +3639,7 @@ btr_blob_free( } } - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); mutex_exit(&block->mutex); } diff --git a/btr/btr0sea.c b/btr/btr0sea.c index fe4e7da0547..042b9c2d6db 100644 --- a/btr/btr0sea.c +++ b/btr/btr0sea.c @@ -781,9 +781,9 @@ btr_search_guess_on_hash( ulint page_no = page_get_page_no(page); ulint space_id = page_get_space_id(page); - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); block = (buf_block_t*) buf_page_hash_get(space_id, page_no); - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); } if (UNIV_UNLIKELY(!block) @@ -1650,7 +1650,7 @@ btr_search_validate(void) rec_offs_init(offsets_); rw_lock_x_lock(&btr_search_latch); - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); cell_count = hash_get_n_cells(btr_search_sys->hash_index); @@ -1658,11 +1658,11 @@ btr_search_validate(void) /* We release btr_search_latch every once in a while to give other queries a chance to run. */ if ((i != 0) && ((i % chunk_size) == 0)) { - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); rw_lock_x_unlock(&btr_search_latch); os_thread_yield(); rw_lock_x_lock(&btr_search_latch); - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); } node = hash_get_nth_cell(btr_search_sys->hash_index, i)->node; @@ -1753,11 +1753,11 @@ btr_search_validate(void) /* We release btr_search_latch every once in a while to give other queries a chance to run. */ if (i != 0) { - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); rw_lock_x_unlock(&btr_search_latch); os_thread_yield(); rw_lock_x_lock(&btr_search_latch); - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); } if (!ha_validate(btr_search_sys->hash_index, i, end_index)) { @@ -1765,7 +1765,7 @@ btr_search_validate(void) } } - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); rw_lock_x_unlock(&btr_search_latch); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); diff --git a/buf/buf0buddy.c b/buf/buf0buddy.c index 7fcceca4676..ec9d27246fd 100644 --- a/buf/buf0buddy.c +++ b/buf/buf0buddy.c @@ -20,24 +20,24 @@ Created December 2006 by Marko Makela /* Statistic counters */ /** Number of frames allocated from the buffer pool to the buddy system. -Protected by buf_pool->mutex. */ +Protected by buf_pool_mutex. */ ulint buf_buddy_n_frames; /** Counts of blocks allocated from the buddy system. -Protected by buf_pool->mutex. */ +Protected by buf_pool_mutex. */ ulint buf_buddy_used[BUF_BUDDY_SIZES + 1]; /** Counts of blocks relocated by the buddy system. -Protected by buf_pool->mutex. */ +Protected by buf_pool_mutex. */ ib_uint64_t buf_buddy_relocated[BUF_BUDDY_SIZES + 1]; /** Preferred minimum number of frames allocated from the buffer pool to the buddy system. Unless this number is exceeded or the buffer pool is scarce, the LRU algorithm will not free compressed-only pages -in order to satisfy an allocation request. Protected by buf_pool->mutex. */ +in order to satisfy an allocation request. Protected by buf_pool_mutex. */ ulint buf_buddy_min_n_frames = 0; /** Preferred maximum number of frames allocated from the buffer pool to the buddy system. Unless this number is exceeded, the buddy allocator will not try to free clean compressed-only pages before falling back -to the LRU algorithm. Protected by buf_pool->mutex. */ +to the LRU algorithm. Protected by buf_pool_mutex. */ ulint buf_buddy_max_n_frames = ULINT_UNDEFINED; /************************************************************************** @@ -127,7 +127,7 @@ buf_buddy_alloc_zip( { buf_page_t* bpage; - ut_ad(mutex_own(&buf_pool->mutex)); + ut_ad(buf_pool_mutex_own()); ut_a(i < BUF_BUDDY_SIZES); #if defined UNIV_DEBUG && !defined UNIV_DEBUG_VALGRIND @@ -179,8 +179,8 @@ buf_buddy_block_free( buf_page_t* bpage; buf_block_t* block; - ut_ad(mutex_own(&buf_pool->mutex)); - ut_ad(!mutex_own(&buf_pool->zip_mutex)); + ut_ad(buf_pool_mutex_own()); + ut_ad(!mutex_own(&buf_pool_zip_mutex)); ut_a(!ut_align_offset(buf, UNIV_PAGE_SIZE)); HASH_SEARCH(hash, buf_pool->zip_hash, fold, buf_page_t*, bpage, @@ -213,8 +213,8 @@ buf_buddy_block_register( buf_block_t* block) /* in: buffer frame to allocate */ { const ulint fold = BUF_POOL_ZIP_FOLD(block); - ut_ad(mutex_own(&buf_pool->mutex)); - ut_ad(!mutex_own(&buf_pool->zip_mutex)); + ut_ad(buf_pool_mutex_own()); + ut_ad(!mutex_own(&buf_pool_zip_mutex)); buf_block_set_state(block, BUF_BLOCK_MEMORY); @@ -276,12 +276,12 @@ buf_buddy_alloc_clean( ulint i, /* in: index of buf_pool->zip_free[] */ ibool* lru) /* in: pointer to a variable that will be assigned TRUE if storage was allocated from the LRU list - and buf_pool->mutex was temporarily released */ + and buf_pool_mutex was temporarily released */ { buf_page_t* bpage; - ut_ad(mutex_own(&buf_pool->mutex)); - ut_ad(!mutex_own(&buf_pool->zip_mutex)); + ut_ad(buf_pool_mutex_own()); + ut_ad(!mutex_own(&buf_pool_zip_mutex)); if (buf_buddy_n_frames < buf_buddy_max_n_frames) { @@ -301,7 +301,7 @@ buf_buddy_alloc_clean( j = ut_min(UT_LIST_GET_LEN(buf_pool->zip_clean), 100); bpage = UT_LIST_GET_FIRST(buf_pool->zip_clean); - mutex_enter(&buf_pool->zip_mutex); + mutex_enter(&buf_pool_zip_mutex); for (; j--; bpage = UT_LIST_GET_NEXT(list, bpage)) { if (bpage->zip.ssize != dummy_zip.ssize @@ -312,7 +312,7 @@ buf_buddy_alloc_clean( /* Reuse the block. */ - mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool_zip_mutex); bpage = buf_buddy_alloc_zip(i); /* bpage may be NULL if buf_buddy_free() @@ -320,7 +320,7 @@ buf_buddy_alloc_clean( buf_LRU_block_remove_hashed_page()] recombines blocks and invokes buf_buddy_block_free(). Because - buf_pool->mutex will not be released + buf_pool_mutex will not be released after buf_buddy_block_free(), there will be at least one block available in the buffer pool, and thus it does not make sense @@ -329,7 +329,7 @@ buf_buddy_alloc_clean( return(bpage); } - mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool_zip_mutex); } /* Free blocks from the end of the LRU list until enough space @@ -381,7 +381,7 @@ free_LRU: } /* A successful buf_LRU_free_block() may release and - reacquire buf_pool->mutex, and thus bpage->LRU of + reacquire buf_pool_mutex, and thus bpage->LRU of an uncompressed page may point to garbage. Furthermore, if bpage were a compressed page descriptor, it would have been deallocated by buf_LRU_free_block(). @@ -396,8 +396,8 @@ free_LRU: /************************************************************************** Allocate a block. The thread calling this function must hold -buf_pool->mutex and must not hold buf_pool->zip_mutex or any block->mutex. -The buf_pool->mutex may only be released and reacquired if lru != NULL. */ +buf_pool_mutex and must not hold buf_pool_zip_mutex or any block->mutex. +The buf_pool_mutex may only be released and reacquired if lru != NULL. */ void* buf_buddy_alloc_low( @@ -408,13 +408,13 @@ buf_buddy_alloc_low( or BUF_BUDDY_SIZES */ ibool* lru) /* in: pointer to a variable that will be assigned TRUE if storage was allocated from the LRU list - and buf_pool->mutex was temporarily released, + and buf_pool_mutex was temporarily released, or NULL if the LRU list should not be used */ { buf_block_t* block; - ut_ad(mutex_own(&buf_pool->mutex)); - ut_ad(!mutex_own(&buf_pool->zip_mutex)); + ut_ad(buf_pool_mutex_own()); + ut_ad(!mutex_own(&buf_pool_zip_mutex)); if (i < BUF_BUDDY_SIZES) { /* Try to allocate from the buddy system. */ @@ -449,10 +449,10 @@ buf_buddy_alloc_low( } /* Try replacing an uncompressed page in the buffer pool. */ - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); block = buf_LRU_get_free_block(0); *lru = TRUE; - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); alloc_big: buf_buddy_block_register(block); @@ -476,7 +476,7 @@ buf_buddy_relocate_block( { buf_page_t* b; - ut_ad(mutex_own(&buf_pool->mutex)); + ut_ad(buf_pool_mutex_own()); switch (buf_page_get_state(bpage)) { case BUF_BLOCK_ZIP_FREE: @@ -494,10 +494,10 @@ buf_buddy_relocate_block( break; } - mutex_enter(&buf_pool->zip_mutex); + mutex_enter(&buf_pool_zip_mutex); if (!buf_page_can_relocate(bpage)) { - mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool_zip_mutex); return(FALSE); } @@ -514,7 +514,7 @@ buf_buddy_relocate_block( UT_LIST_ADD_FIRST(list, buf_pool->zip_clean, dpage); } - mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool_zip_mutex); return(TRUE); } @@ -532,8 +532,8 @@ buf_buddy_relocate( buf_page_t* bpage; const ulint size = BUF_BUDDY_LOW << i; - ut_ad(mutex_own(&buf_pool->mutex)); - ut_ad(!mutex_own(&buf_pool->zip_mutex)); + ut_ad(buf_pool_mutex_own()); + ut_ad(!mutex_own(&buf_pool_zip_mutex)); ut_ad(!ut_align_offset(src, size)); ut_ad(!ut_align_offset(dst, size)); UNIV_MEM_ASSERT_W(dst, size); @@ -632,8 +632,8 @@ buf_buddy_free_low( buf_page_t* bpage; buf_page_t* buddy; - ut_ad(mutex_own(&buf_pool->mutex)); - ut_ad(!mutex_own(&buf_pool->zip_mutex)); + ut_ad(buf_pool_mutex_own()); + ut_ad(!mutex_own(&buf_pool_zip_mutex)); ut_ad(i <= BUF_BUDDY_SIZES); ut_ad(buf_buddy_used[i] > 0); diff --git a/buf/buf0buf.c b/buf/buf0buf.c index 0cd356b232b..79db101c295 100644 --- a/buf/buf0buf.c +++ b/buf/buf0buf.c @@ -224,6 +224,13 @@ static const int WAIT_FOR_READ = 5000; buf_pool_t* buf_pool = NULL; /* The buffer buf_pool of the database */ +/* mutex protecting the buffer pool struct and control blocks, except the +read-write lock in them */ +mutex_t buf_pool_mutex; +/* mutex protecting the control blocks of compressed-only pages +(of type buf_page_t, not buf_block_t) */ +mutex_t buf_pool_zip_mutex; + #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG static ulint buf_dbg_counter = 0; /* This is used to insert validation operations in excution in the @@ -746,7 +753,7 @@ buf_chunk_contains_zip( ulint i; ut_ad(buf_pool); - ut_ad(mutex_own(&buf_pool->mutex)); + ut_ad(buf_pool_mutex_own()); block = chunk->blocks; @@ -800,7 +807,7 @@ buf_chunk_not_freed( ulint i; ut_ad(buf_pool); - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); block = chunk->blocks; @@ -833,7 +840,7 @@ buf_chunk_all_free( ulint i; ut_ad(buf_pool); - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); block = chunk->blocks; @@ -859,7 +866,7 @@ buf_chunk_free( buf_block_t* block; const buf_block_t* block_end; - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); block_end = chunk->blocks + chunk->size; @@ -901,11 +908,11 @@ buf_pool_init(void) /* 1. Initialize general fields ------------------------------- */ - mutex_create(&buf_pool->mutex, SYNC_BUF_POOL); + mutex_create(&buf_pool_mutex, SYNC_BUF_POOL); - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); - mutex_create(&buf_pool->zip_mutex, SYNC_BUF_BLOCK); + mutex_create(&buf_pool_zip_mutex, SYNC_BUF_BLOCK); buf_pool->n_chunks = 1; buf_pool->chunks = chunk = mem_alloc(sizeof *chunk); @@ -941,7 +948,7 @@ buf_pool_init(void) --------------------------- */ /* All fields are initialized by mem_zalloc(). */ - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); btr_search_sys_create(buf_pool->curr_size * UNIV_PAGE_SIZE / sizeof(void*) / 64); @@ -965,7 +972,7 @@ buf_relocate( buf_page_t* b; ulint fold; - ut_ad(mutex_own(&buf_pool->mutex)); + ut_ad(buf_pool_mutex_own()); ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_a(buf_page_get_io_fix(bpage) == BUF_IO_NONE); ut_a(bpage->buf_fix_count == 0); @@ -1021,11 +1028,11 @@ buf_pool_shrink( buf_chunk_t* max_chunk; buf_chunk_t* max_free_chunk; - ut_ad(!mutex_own(&buf_pool->mutex)); + ut_ad(!buf_pool_mutex_own()); try_again: btr_search_disable(); /* Empty the adaptive hash index again */ - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); shrink_again: if (buf_pool->n_chunks <= 1) { @@ -1088,7 +1095,7 @@ shrink_again: mutex_enter(&block->mutex); /* The following calls will temporarily - release block->mutex and buf_pool->mutex. + release block->mutex and buf_pool_mutex. Therefore, we have to always retry, even if !dirty && !nonfree. */ @@ -1104,7 +1111,7 @@ shrink_again: mutex_exit(&block->mutex); } - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); /* Request for a flush of the chunk if it helps. Do not flush if there are non-free blocks, since @@ -1153,7 +1160,7 @@ shrink_again: func_done: srv_buf_pool_old_size = srv_buf_pool_size; func_exit: - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); btr_search_enable(); } @@ -1171,7 +1178,7 @@ buf_pool_page_hash_rebuild(void) hash_table_t* zip_hash; buf_page_t* b; - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); /* Free, create, and populate the hash table. */ hash_table_free(buf_pool->page_hash); @@ -1251,7 +1258,7 @@ buf_pool_page_hash_rebuild(void) } } - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); } /************************************************************************ @@ -1261,17 +1268,17 @@ void buf_pool_resize(void) /*=================*/ { - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); if (srv_buf_pool_old_size == srv_buf_pool_size) { - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); return; } if (srv_buf_pool_curr_size + 1048576 > srv_buf_pool_size) { - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); /* Disable adaptive hash indexes and empty the index in order to free up memory in the buffer pool chunks. */ @@ -1305,7 +1312,7 @@ buf_pool_resize(void) } srv_buf_pool_old_size = srv_buf_pool_size; - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); } buf_pool_page_hash_rebuild(); @@ -1320,19 +1327,19 @@ buf_block_make_young( /*=================*/ buf_page_t* bpage) /* in: block to make younger */ { - ut_ad(!mutex_own(&(buf_pool->mutex))); + ut_ad(!buf_pool_mutex_own()); /* Note that we read freed_page_clock's without holding any mutex: this is allowed since the result is used only in heuristics */ if (buf_page_peek_if_too_old(bpage)) { - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); /* There has been freeing activity in the LRU list: best to move to the head of the LRU list */ buf_LRU_make_block_young(bpage); - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); } } @@ -1346,13 +1353,13 @@ buf_page_make_young( /*================*/ buf_page_t* bpage) /* in: buffer block of a file page */ { - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); ut_a(buf_page_in_file(bpage)); buf_LRU_make_block_young(bpage); - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); } /************************************************************************ @@ -1367,7 +1374,7 @@ buf_reset_check_index_page_at_flush( { buf_block_t* block; - mutex_enter_fast(&(buf_pool->mutex)); + buf_pool_mutex_enter(); block = (buf_block_t*) buf_page_hash_get(space, offset); @@ -1375,7 +1382,7 @@ buf_reset_check_index_page_at_flush( block->check_index_page_at_flush = FALSE; } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); } /************************************************************************ @@ -1394,7 +1401,7 @@ buf_page_peek_if_search_hashed( buf_block_t* block; ibool is_hashed; - mutex_enter_fast(&(buf_pool->mutex)); + buf_pool_mutex_enter(); block = (buf_block_t*) buf_page_hash_get(space, offset); @@ -1404,7 +1411,7 @@ buf_page_peek_if_search_hashed( is_hashed = block->is_hashed; } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(is_hashed); } @@ -1426,7 +1433,7 @@ buf_page_set_file_page_was_freed( { buf_page_t* bpage; - mutex_enter_fast(&(buf_pool->mutex)); + buf_pool_mutex_enter(); bpage = buf_page_hash_get(space, offset); @@ -1434,7 +1441,7 @@ buf_page_set_file_page_was_freed( bpage->file_page_was_freed = TRUE; } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(bpage); } @@ -1455,7 +1462,7 @@ buf_page_reset_file_page_was_freed( { buf_page_t* bpage; - mutex_enter_fast(&(buf_pool->mutex)); + buf_pool_mutex_enter(); bpage = buf_page_hash_get(space, offset); @@ -1463,7 +1470,7 @@ buf_page_reset_file_page_was_freed( bpage->file_page_was_freed = FALSE; } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(bpage); } @@ -1490,7 +1497,7 @@ buf_page_get_zip( buf_pool->n_page_gets++; for (;;) { - mutex_enter_fast(&buf_pool->mutex); + buf_pool_mutex_enter(); lookup: bpage = buf_page_hash_get(space, offset); if (bpage) { @@ -1499,7 +1506,7 @@ lookup: /* Page not in buf_pool: needs to be read from file */ - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); buf_read_page(space, zip_size, offset); @@ -1510,7 +1517,7 @@ lookup: if (UNIV_UNLIKELY(!bpage->zip.data)) { /* There is no compressed page. */ - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); return(NULL); } @@ -1544,7 +1551,7 @@ lookup: must_read = buf_page_get_io_fix(bpage) == BUF_IO_READ; - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); buf_page_set_accessed(bpage, TRUE); @@ -1687,7 +1694,7 @@ buf_block_is_uncompressed( const buf_chunk_t* chunk = buf_pool->chunks; const buf_chunk_t* const echunk = chunk + buf_pool->n_chunks; - ut_ad(mutex_own(&buf_pool->mutex)); + ut_ad(buf_pool_mutex_own()); if (UNIV_UNLIKELY((((ulint) block) % sizeof *block) != 0)) { /* The pointer should be aligned. */ @@ -1745,7 +1752,7 @@ buf_page_get_gen( buf_pool->n_page_gets++; loop: block = guess; - mutex_enter_fast(&(buf_pool->mutex)); + buf_pool_mutex_enter(); if (block) { /* If the guess is a compressed page descriptor that @@ -1776,7 +1783,7 @@ loop2: if (block == NULL) { /* Page not in buf_pool: needs to be read from file */ - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); if (mode == BUF_GET_IF_IN_POOL) { @@ -1797,7 +1804,7 @@ loop2: if (must_read && mode == BUF_GET_IF_IN_POOL) { /* The page is only being read to buffer */ - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); return(NULL); } @@ -1821,19 +1828,19 @@ loop2: wait_until_unfixed: /* The block is buffer-fixed or I/O-fixed. Try again later. */ - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); os_thread_sleep(WAIT_FOR_READ); goto loop; } /* Allocate an uncompressed page. */ - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); block = buf_LRU_get_free_block(0); ut_a(block); - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); mutex_enter(&block->mutex); { @@ -1842,7 +1849,7 @@ wait_until_unfixed: if (UNIV_UNLIKELY(bpage != hash_bpage)) { /* The buf_pool->page_hash was modified - while buf_pool->mutex was released. + while buf_pool_mutex was released. Free the block that was allocated. */ buf_LRU_block_free_non_file_page(block); @@ -1858,7 +1865,7 @@ wait_until_unfixed: || buf_page_get_io_fix(bpage) != BUF_IO_NONE)) { /* The block was buffer-fixed or I/O-fixed - while buf_pool->mutex was not held by this thread. + while buf_pool_mutex was not held by this thread. Free the block that was allocated and try again. This should be extremely unlikely. */ @@ -1871,7 +1878,7 @@ wait_until_unfixed: /* Move the compressed page from bpage to block, and uncompress it. */ - mutex_enter(&buf_pool->zip_mutex); + mutex_enter(&buf_pool_zip_mutex); buf_relocate(bpage, &block->page); buf_block_init_low(block); @@ -1913,14 +1920,14 @@ wait_until_unfixed: buf_pool->n_pend_unzip++; rw_lock_x_lock(&block->lock); mutex_exit(&block->mutex); - mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool_zip_mutex); buf_buddy_free(bpage, sizeof *bpage); - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); /* Decompress the page and apply buffered operations - while not holding buf_pool->mutex or block->mutex. */ + while not holding buf_pool_mutex or block->mutex. */ success = buf_zip_decompress(block, srv_use_checksums); if (UNIV_LIKELY(success)) { @@ -1929,7 +1936,7 @@ wait_until_unfixed: } /* Unfix and unlatch the block. */ - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); mutex_enter(&block->mutex); buf_pool->n_pend_unzip--; block->page.buf_fix_count--; @@ -1939,7 +1946,7 @@ wait_until_unfixed: if (UNIV_UNLIKELY(!success)) { - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); return(NULL); } @@ -1960,7 +1967,7 @@ wait_until_unfixed: UNIV_MEM_ASSERT_RW(&block->page, sizeof block->page); buf_block_buf_fix_inc(block, file, line); - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); /* Check if this is the first access to the page */ @@ -2271,16 +2278,16 @@ buf_page_try_get_func( ibool success; ulint fix_type; - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); block = buf_block_hash_get(space_id, page_no); if (!block) { - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); return(NULL); } mutex_enter(&block->mutex); - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); @@ -2396,7 +2403,7 @@ buf_page_init( { buf_page_t* hash_page; - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); ut_ad(mutex_own(&(block->mutex))); ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE); @@ -2429,7 +2436,7 @@ buf_page_init( (const void*) hash_page, (const void*) block); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG mutex_exit(&block->mutex); - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); buf_print(); buf_LRU_print(); buf_validate(); @@ -2507,7 +2514,7 @@ buf_page_init_for_read( ut_ad(block); } - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); if (buf_page_hash_get(space, offset)) { /* The page is already in the buffer pool. */ @@ -2519,7 +2526,7 @@ err_exit: } err_exit2: - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); if (mode == BUF_READ_IBUF_PAGES_ONLY) { @@ -2561,11 +2568,11 @@ err_exit2: if (UNIV_UNLIKELY(zip_size)) { page_zip_set_size(&block->page.zip, zip_size); - /* buf_pool->mutex may be released and + /* buf_pool_mutex may be released and reacquired by buf_buddy_alloc(). Thus, we must release block->mutex in order not to break the latching order in the reacquisition - of buf_pool->mutex. We also must defer this + of buf_pool_mutex. We also must defer this operation until after the block descriptor has been added to buf_pool->LRU and buf_pool->page_hash. */ @@ -2590,7 +2597,7 @@ err_exit2: bpage = buf_buddy_alloc(sizeof *bpage, &lru); /* If buf_buddy_alloc() allocated storage from the LRU list, - it released and reacquired buf_pool->mutex. Thus, we must + it released and reacquired buf_pool_mutex. Thus, we must check the page_hash again, as it may have been modified. */ if (UNIV_UNLIKELY(lru) && UNIV_LIKELY_NULL(buf_page_hash_get(space, offset))) { @@ -2605,7 +2612,7 @@ err_exit2: page_zip_set_size(&bpage->zip, zip_size); bpage->zip.data = data; - mutex_enter(&buf_pool->zip_mutex); + mutex_enter(&buf_pool_zip_mutex); UNIV_MEM_DESC(bpage->zip.data, page_zip_get_size(&bpage->zip), bpage); buf_page_init_low(bpage); @@ -2631,11 +2638,11 @@ err_exit2: buf_page_set_io_fix(bpage, BUF_IO_READ); - mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool_zip_mutex); } buf_pool->n_pend_reads++; - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); if (mode == BUF_READ_IBUF_PAGES_ONLY) { @@ -2671,7 +2678,7 @@ buf_page_create( free_block = buf_LRU_get_free_block(0); - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); block = (buf_block_t*) buf_page_hash_get(space, offset); @@ -2684,7 +2691,7 @@ buf_page_create( #endif /* UNIV_DEBUG_FILE_ACCESSES */ /* Page can be found in buf_pool */ - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); buf_block_free(free_block); @@ -2718,7 +2725,7 @@ buf_page_create( ibool lru; /* Prevent race conditions during buf_buddy_alloc(), - which may release and reacquire buf_pool->mutex, + which may release and reacquire buf_pool_mutex, by IO-fixing and X-latching the block. */ buf_page_set_io_fix(&block->page, BUF_IO_READ); @@ -2726,10 +2733,10 @@ buf_page_create( page_zip_set_size(&block->page.zip, zip_size); mutex_exit(&block->mutex); - /* buf_pool->mutex may be released and reacquired by + /* buf_pool_mutex may be released and reacquired by buf_buddy_alloc(). Thus, we must release block->mutex in order not to break the latching order in - the reacquisition of buf_pool->mutex. We also must + the reacquisition of buf_pool_mutex. We also must defer this operation until after the block descriptor has been added to buf_pool->LRU and buf_pool->page_hash. */ data = buf_buddy_alloc(zip_size, &lru); @@ -2740,7 +2747,7 @@ buf_page_create( rw_lock_x_unlock(&block->lock); } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX); @@ -2926,7 +2933,7 @@ corrupt: } } - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); mutex_enter(buf_page_get_mutex(bpage)); #ifdef UNIV_IBUF_COUNT_DEBUG @@ -2981,7 +2988,7 @@ corrupt: } mutex_exit(buf_page_get_mutex(bpage)); - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); #ifdef UNIV_DEBUG if (buf_debug_prints) { @@ -3012,11 +3019,11 @@ buf_pool_invalidate(void) freed = buf_LRU_search_and_free_block(100); } - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0); - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); } #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG @@ -3040,7 +3047,7 @@ buf_validate(void) ut_ad(buf_pool); - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); chunk = buf_pool->chunks; @@ -3134,7 +3141,7 @@ buf_validate(void) } } - mutex_enter(&buf_pool->zip_mutex); + mutex_enter(&buf_pool_zip_mutex); /* Check clean compressed-only blocks. */ @@ -3211,7 +3218,7 @@ buf_validate(void) ut_a(buf_page_hash_get(b->space, b->offset) == b); } - mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool_zip_mutex); if (n_lru + n_free > buf_pool->curr_size + n_zip) { fprintf(stderr, "n LRU %lu, n free %lu, pool %lu zip %lu\n", @@ -3233,7 +3240,7 @@ buf_validate(void) ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush); ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush); - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); ut_a(buf_LRU_validate()); ut_a(buf_flush_validate()); @@ -3267,7 +3274,7 @@ buf_print(void) index_ids = mem_alloc(sizeof(dulint) * size); counts = mem_alloc(sizeof(ulint) * size); - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); fprintf(stderr, "buf_pool size %lu\n" @@ -3330,7 +3337,7 @@ buf_print(void) } } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); for (i = 0; i < n_found; i++) { index = dict_index_get_if_in_cache(index_ids[i]); @@ -3367,7 +3374,7 @@ buf_get_latched_pages_number(void) ulint i; ulint fixed_pages_number = 0; - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); chunk = buf_pool->chunks; @@ -3396,7 +3403,7 @@ buf_get_latched_pages_number(void) } } - mutex_enter(&buf_pool->zip_mutex); + mutex_enter(&buf_pool_zip_mutex); /* Traverse the lists of clean and dirty compressed-only blocks. */ @@ -3436,8 +3443,8 @@ buf_get_latched_pages_number(void) } } - mutex_exit(&buf_pool->zip_mutex); - mutex_exit(&(buf_pool->mutex)); + mutex_exit(&buf_pool_zip_mutex); + buf_pool_mutex_exit(); return(fixed_pages_number); } @@ -3465,7 +3472,7 @@ buf_get_modified_ratio_pct(void) { ulint ratio; - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list)) / (1 + UT_LIST_GET_LEN(buf_pool->LRU) @@ -3473,7 +3480,7 @@ buf_get_modified_ratio_pct(void) /* 1 + is there to avoid division by zero */ - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(ratio); } @@ -3493,7 +3500,7 @@ buf_print_io( ut_ad(buf_pool); size = buf_pool->curr_size; - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); fprintf(file, "Buffer pool size %lu\n" @@ -3548,7 +3555,7 @@ buf_print_io( buf_pool->n_pages_created_old = buf_pool->n_pages_created; buf_pool->n_pages_written_old = buf_pool->n_pages_written; - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); } /************************************************************************** @@ -3577,7 +3584,7 @@ buf_all_freed(void) ut_ad(buf_pool); - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); chunk = buf_pool->chunks; @@ -3594,7 +3601,7 @@ buf_all_freed(void) } } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(TRUE); } @@ -3610,7 +3617,7 @@ buf_pool_check_no_pending_io(void) { ibool ret; - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); if (buf_pool->n_pend_reads + buf_pool->n_flush[BUF_FLUSH_LRU] + buf_pool->n_flush[BUF_FLUSH_LIST] @@ -3620,7 +3627,7 @@ buf_pool_check_no_pending_io(void) ret = TRUE; } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(ret); } @@ -3634,11 +3641,11 @@ buf_get_free_list_len(void) { ulint len; - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); len = UT_LIST_GET_LEN(buf_pool->free); - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(len); } diff --git a/buf/buf0flu.c b/buf/buf0flu.c index de0bd9ef1fe..1f947748bca 100644 --- a/buf/buf0flu.c +++ b/buf/buf0flu.c @@ -51,16 +51,16 @@ buf_flush_insert_into_flush_list( /*=============================*/ buf_page_t* bpage) /* in: block which is modified */ { - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL) || (UT_LIST_GET_FIRST(buf_pool->flush_list)->oldest_modification <= bpage->oldest_modification)); switch (buf_page_get_state(bpage)) { case BUF_BLOCK_ZIP_PAGE: - mutex_enter(&buf_pool->zip_mutex); + mutex_enter(&buf_pool_zip_mutex); buf_page_set_state(bpage, BUF_BLOCK_ZIP_DIRTY); - mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool_zip_mutex); UT_LIST_REMOVE(list, buf_pool->zip_clean, bpage); /* fall through */ case BUF_BLOCK_ZIP_DIRTY: @@ -99,13 +99,13 @@ buf_flush_insert_sorted_into_flush_list( buf_page_t* prev_b; buf_page_t* b; - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); switch (buf_page_get_state(bpage)) { case BUF_BLOCK_ZIP_PAGE: - mutex_enter(&buf_pool->zip_mutex); + mutex_enter(&buf_pool_zip_mutex); buf_page_set_state(bpage, BUF_BLOCK_ZIP_DIRTY); - mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool_zip_mutex); UT_LIST_REMOVE(list, buf_pool->zip_clean, bpage); /* fall through */ case BUF_BLOCK_ZIP_DIRTY: @@ -157,7 +157,7 @@ buf_flush_ready_for_replace( buf_page_t* bpage) /* in: buffer control block, must be buf_page_in_file(bpage) and in the LRU list */ { - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_ad(bpage->in_LRU_list); @@ -190,7 +190,7 @@ buf_flush_ready_for_flush( enum buf_flush flush_type)/* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ { ut_a(buf_page_in_file(bpage)); - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); ut_ad(mutex_own(buf_page_get_mutex(bpage))); if (bpage->oldest_modification != 0 @@ -222,7 +222,7 @@ buf_flush_remove( /*=============*/ buf_page_t* bpage) /* in: pointer to the block in question */ { - ut_ad(mutex_own(&buf_pool->mutex)); + ut_ad(buf_pool_mutex_own()); ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_ad(bpage->in_flush_list); ut_d(bpage->in_flush_list = FALSE); @@ -758,12 +758,12 @@ buf_flush_try_page( ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST || flush_type == BUF_FLUSH_SINGLE_PAGE); - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); bpage = buf_page_hash_get(space, offset); if (!bpage) { - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(0); } @@ -774,7 +774,7 @@ buf_flush_try_page( if (!buf_flush_ready_for_flush(bpage, flush_type)) { mutex_exit(block_mutex); - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); return(0); } @@ -803,7 +803,7 @@ buf_flush_try_page( } mutex_exit(block_mutex); - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); if (!locked) { buf_flush_buffered_writes(); @@ -846,7 +846,7 @@ buf_flush_try_page( immediately. */ mutex_exit(block_mutex); - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); break; case BUF_FLUSH_SINGLE_PAGE: @@ -862,7 +862,7 @@ buf_flush_try_page( buf_pool->n_flush[flush_type]++; mutex_exit(block_mutex); - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); if (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE) { rw_lock_s_lock_gen(&((buf_block_t*) bpage)->lock, @@ -922,7 +922,7 @@ buf_flush_try_neighbors( high = fil_space_get_size(space); } - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); for (i = low; i < high; i++) { @@ -956,7 +956,7 @@ buf_flush_try_neighbors( flush the doublewrite buffer before we start waiting. */ - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); mutex_exit(block_mutex); @@ -969,14 +969,14 @@ buf_flush_try_neighbors( count += buf_flush_try_page(space, i, flush_type); - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); } else { mutex_exit(block_mutex); } } } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(count); } @@ -1020,14 +1020,14 @@ buf_flush_batch( ut_ad((flush_type != BUF_FLUSH_LIST) || sync_thread_levels_empty_gen(TRUE)); #endif /* UNIV_SYNC_DEBUG */ - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); if ((buf_pool->n_flush[flush_type] > 0) || (buf_pool->init_flush[flush_type] == TRUE)) { /* There is already a flush batch of the same type running */ - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(ULINT_UNDEFINED); } @@ -1078,7 +1078,7 @@ flush_next: space = buf_page_get_space(bpage); offset = buf_page_get_page_no(bpage); - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); mutex_exit(block_mutex); old_page_count = page_count; @@ -1091,7 +1091,7 @@ flush_next: flush_type, offset, page_count - old_page_count); */ - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); goto flush_next; } else if (flush_type == BUF_FLUSH_LRU) { @@ -1124,7 +1124,7 @@ flush_next: os_event_set(buf_pool->no_flush[flush_type]); } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); buf_flush_buffered_writes(); @@ -1172,7 +1172,7 @@ buf_flush_LRU_recommendation(void) ulint n_replaceable; ulint distance = 0; - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); n_replaceable = UT_LIST_GET_LEN(buf_pool->free); @@ -1198,7 +1198,7 @@ buf_flush_LRU_recommendation(void) bpage = UT_LIST_GET_PREV(LRU, bpage); } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) { @@ -1275,11 +1275,11 @@ buf_flush_validate(void) { ibool ret; - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); ret = buf_flush_validate_low(); - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(ret); } diff --git a/buf/buf0lru.c b/buf/buf0lru.c index 4bcf12821dc..2c5e203efc9 100644 --- a/buf/buf0lru.c +++ b/buf/buf0lru.c @@ -51,7 +51,7 @@ ibool buf_lru_switched_on_innodb_mon = FALSE; /********************************************************************** Takes a block out of the LRU list and page hash table. If the block is compressed-only (BUF_BLOCK_ZIP_PAGE), -the object will be freed and buf_pool->zip_mutex will be released. +the object will be freed and buf_pool_zip_mutex will be released. If a compressed page or a compressed-only block descriptor is freed, other compressed pages or compressed-only block descriptors may be @@ -92,7 +92,7 @@ buf_LRU_invalidate_tablespace( ibool all_freed; scan_again: - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); all_freed = TRUE; @@ -133,7 +133,7 @@ scan_again: && ((buf_block_t*) bpage)->is_hashed) { page_no = buf_page_get_page_no(bpage); - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); mutex_exit(block_mutex); /* Note that the following call will acquire @@ -172,7 +172,7 @@ next_page: bpage = prev_bpage; } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); if (!all_freed) { os_thread_sleep(20000); @@ -195,14 +195,14 @@ buf_LRU_get_recent_limit(void) ulint len; ulint limit; - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); len = UT_LIST_GET_LEN(buf_pool->LRU); if (len < BUF_LRU_OLD_MIN_LEN) { /* The LRU list is too short to do read-ahead */ - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(0); } @@ -211,7 +211,7 @@ buf_LRU_get_recent_limit(void) limit = buf_page_get_LRU_position(bpage) - len / BUF_LRU_INITIAL_RATIO; - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(limit); } @@ -226,7 +226,7 @@ buf_LRU_insert_zip_clean( { buf_page_t* b; - ut_ad(mutex_own(&buf_pool->mutex)); + ut_ad(buf_pool_mutex_own()); ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_PAGE); /* Find the first successor of bpage in the LRU list @@ -266,7 +266,7 @@ buf_LRU_search_and_free_block( buf_page_t* bpage; ibool freed; - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); freed = FALSE; bpage = UT_LIST_GET_LAST(buf_pool->LRU); @@ -355,7 +355,7 @@ func_exit: if (!freed) { buf_pool->LRU_flush_ended = 0; } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(freed); } @@ -373,18 +373,18 @@ void buf_LRU_try_free_flushed_blocks(void) /*=================================*/ { - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); while (buf_pool->LRU_flush_ended > 0) { - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); buf_LRU_search_and_free_block(1); - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); } /********************************************************************** @@ -400,7 +400,7 @@ buf_LRU_buf_pool_running_out(void) { ibool ret = FALSE; - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->curr_size / 4) { @@ -408,7 +408,7 @@ buf_LRU_buf_pool_running_out(void) ret = TRUE; } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(ret); } @@ -425,7 +425,7 @@ buf_LRU_get_free_only(void) { buf_block_t* block; - ut_ad(mutex_own(&buf_pool->mutex)); + ut_ad(buf_pool_mutex_own()); block = (buf_block_t*) UT_LIST_GET_FIRST(buf_pool->free); @@ -467,7 +467,7 @@ buf_LRU_get_free_block( ibool mon_value_was = FALSE; ibool started_monitor = FALSE; loop: - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->curr_size / 20) { @@ -554,7 +554,7 @@ loop: block->page.zip.data = NULL; } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); if (started_monitor) { srv_print_innodb_monitor = mon_value_was; @@ -566,7 +566,7 @@ loop: /* If no block was in the free list, search from the end of the LRU list and try to free a block there */ - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); freed = buf_LRU_search_and_free_block(n_iterations); @@ -615,18 +615,18 @@ loop: os_aio_simulated_wake_handler_threads(); - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); if (buf_pool->LRU_flush_ended > 0) { /* We have written pages in an LRU flush. To make the insert buffer more efficient, we try to move these pages to the free list. */ - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); buf_LRU_try_free_flushed_blocks(); } else { - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); } if (n_iterations > 10) { @@ -651,7 +651,7 @@ buf_LRU_old_adjust_len(void) ulint new_len; ut_a(buf_pool->LRU_old); - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); ut_ad(3 * (BUF_LRU_OLD_MIN_LEN / 8) > BUF_LRU_OLD_TOLERANCE + 5); for (;;) { @@ -693,7 +693,7 @@ buf_LRU_old_init(void) { buf_page_t* bpage; - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == BUF_LRU_OLD_MIN_LEN); /* We first initialize all blocks in the LRU list as old and then use @@ -724,7 +724,7 @@ buf_LRU_remove_block( { ut_ad(buf_pool); ut_ad(bpage); - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); ut_a(buf_page_in_file(bpage)); @@ -784,7 +784,7 @@ buf_LRU_add_block_to_end_low( ut_ad(buf_pool); ut_ad(bpage); - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); ut_a(buf_page_in_file(bpage)); @@ -840,7 +840,7 @@ buf_LRU_add_block_low( { ut_ad(buf_pool); ut_ad(bpage); - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); ut_a(buf_page_in_file(bpage)); ut_ad(!bpage->in_LRU_list); @@ -936,19 +936,19 @@ buf_LRU_free_block( the descriptor object will be freed as well. If this function returns FALSE, it will not temporarily release - buf_pool->mutex. */ + buf_pool_mutex. */ buf_page_t* bpage, /* in: block to be freed */ ibool zip, /* in: TRUE if should remove also the compressed page of an uncompressed page */ ibool* buf_pool_mutex_released) /* in: pointer to a variable that will - be assigned TRUE if buf_pool->mutex + be assigned TRUE if buf_pool_mutex was temporarily released, or NULL */ { buf_page_t* b = NULL; mutex_t* block_mutex = buf_page_get_mutex(bpage); - ut_ad(mutex_own(&buf_pool->mutex)); + ut_ad(buf_pool_mutex_own()); ut_ad(mutex_own(block_mutex)); ut_ad(buf_page_in_file(bpage)); ut_ad(bpage->in_LRU_list); @@ -1053,7 +1053,7 @@ alloc: /* Prevent buf_page_get_gen() from decompressing the block while we release - buf_pool->mutex and block_mutex. */ + buf_pool_mutex and block_mutex. */ b->buf_fix_count++; b->io_fix = BUF_IO_READ; } @@ -1062,7 +1062,7 @@ alloc: *buf_pool_mutex_released = TRUE; } - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); mutex_exit(block_mutex); /* Remove possible adaptive hash index on the page. @@ -1094,14 +1094,14 @@ alloc: : BUF_NO_CHECKSUM_MAGIC); } - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); mutex_enter(block_mutex); if (b) { - mutex_enter(&buf_pool->zip_mutex); + mutex_enter(&buf_pool_zip_mutex); b->buf_fix_count--; buf_page_set_io_fix(b, BUF_IO_NONE); - mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool_zip_mutex); } buf_LRU_block_free_hashed_page((buf_block_t*) bpage); @@ -1122,7 +1122,7 @@ buf_LRU_block_free_non_file_page( { void* data; - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); ut_ad(mutex_own(&block->mutex)); ut_ad(block); @@ -1169,7 +1169,7 @@ buf_LRU_block_free_non_file_page( /********************************************************************** Takes a block out of the LRU list and page hash table. If the block is compressed-only (BUF_BLOCK_ZIP_PAGE), -the object will be freed and buf_pool->zip_mutex will be released. +the object will be freed and buf_pool_zip_mutex will be released. If a compressed page or a compressed-only block descriptor is freed, other compressed pages or compressed-only block descriptors may be @@ -1190,7 +1190,7 @@ buf_LRU_block_remove_hashed_page( { const buf_page_t* hashed_bpage; ut_ad(bpage); - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_a(buf_page_get_io_fix(bpage) == BUF_IO_NONE); @@ -1279,7 +1279,7 @@ buf_LRU_block_remove_hashed_page( #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG mutex_exit(buf_page_get_mutex(bpage)); - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); buf_print(); buf_LRU_print(); buf_validate(); @@ -1304,7 +1304,7 @@ buf_LRU_block_remove_hashed_page( UT_LIST_REMOVE(list, buf_pool->zip_clean, bpage); - mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool_zip_mutex); buf_buddy_free(bpage->zip.data, page_zip_get_size(&bpage->zip)); buf_buddy_free(bpage, sizeof(*bpage)); @@ -1355,7 +1355,7 @@ buf_LRU_block_free_hashed_page( buf_block_t* block) /* in: block, must contain a file page and be in a state where it can be freed */ { - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); ut_ad(mutex_own(&block->mutex)); buf_block_set_state(block, BUF_BLOCK_MEMORY); @@ -1377,7 +1377,7 @@ buf_LRU_validate(void) ulint LRU_pos; ut_ad(buf_pool); - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) { @@ -1431,7 +1431,7 @@ buf_LRU_validate(void) ut_a(buf_page_get_state(bpage) == BUF_BLOCK_NOT_USED); } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(TRUE); } #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ @@ -1447,7 +1447,7 @@ buf_LRU_print(void) const buf_page_t* bpage; ut_ad(buf_pool); - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); fprintf(stderr, "Pool ulint clock %lu\n", (ulong) buf_pool->ulint_clock); @@ -1510,6 +1510,6 @@ buf_LRU_print(void) bpage = UT_LIST_GET_NEXT(LRU, bpage); } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); } #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */ diff --git a/buf/buf0rea.c b/buf/buf0rea.c index 3775e363d94..92659488f7c 100644 --- a/buf/buf0rea.c +++ b/buf/buf0rea.c @@ -222,11 +222,11 @@ buf_read_ahead_random( LRU_recent_limit = buf_LRU_get_recent_limit(); - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); if (buf_pool->n_pend_reads > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(0); } @@ -245,13 +245,13 @@ buf_read_ahead_random( if (recent_blocks >= BUF_READ_AHEAD_RANDOM_THRESHOLD) { - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); goto read_ahead; } } } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); /* Do nothing */ return(0); @@ -436,10 +436,10 @@ buf_read_ahead_linear( tablespace_version = fil_space_get_version(space); - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); if (high > fil_space_get_size(space)) { - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); /* The area is not whole, return */ return(0); @@ -447,7 +447,7 @@ buf_read_ahead_linear( if (buf_pool->n_pend_reads > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(0); } @@ -487,7 +487,7 @@ buf_read_ahead_linear( - BUF_READ_AHEAD_LINEAR_THRESHOLD) { /* Too many failures: return */ - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(0); } @@ -498,7 +498,7 @@ buf_read_ahead_linear( bpage = buf_page_hash_get(space, offset); if (bpage == NULL) { - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(0); } @@ -524,7 +524,7 @@ buf_read_ahead_linear( pred_offset = fil_page_get_prev(frame); succ_offset = fil_page_get_next(frame); - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); if ((offset == low) && (succ_offset == offset + 1)) { diff --git a/handler/i_s.cc b/handler/i_s.cc index 90af1335075..3591fd546dc 100644 --- a/handler/i_s.cc +++ b/handler/i_s.cc @@ -1064,13 +1064,13 @@ i_s_zip_fill_low( /* Determine log2(PAGE_ZIP_MIN_SIZE / 2 / BUF_BUDDY_LOW). */ for (uint r = PAGE_ZIP_MIN_SIZE / 2 / BUF_BUDDY_LOW; r >>= 1; y++); - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); for (uint x = 0; x <= BUF_BUDDY_SIZES; x++) { table->field[0]->store(BUF_BUDDY_LOW << x); table->field[1]->store(buf_buddy_relocated[x]); if (reset) { - /* This is protected by buf_pool->mutex. */ + /* This is protected by buf_pool_mutex. */ buf_buddy_relocated[x] = 0; } @@ -1103,7 +1103,7 @@ i_s_zip_fill_low( } } - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); DBUG_RETURN(status); } diff --git a/include/buf0buddy.h b/include/buf0buddy.h index f376a3ea2e9..bf2e4f885f7 100644 --- a/include/buf0buddy.h +++ b/include/buf0buddy.h @@ -19,13 +19,13 @@ Created December 2006 by Marko Makela /************************************************************************** Allocate a block. The thread calling this function must hold -buf_pool->mutex and must not hold buf_pool->zip_mutex or any -block->mutex. The buf_pool->mutex may only be released and reacquired +buf_pool_mutex and must not hold buf_pool_zip_mutex or any +block->mutex. The buf_pool_mutex may only be released and reacquired if lru == BUF_BUDDY_USE_LRU. This function should only be used for allocating compressed page frames or control blocks (buf_page_t). Allocated control blocks must be properly initialized immediately after buf_buddy_alloc() has returned the memory, before releasing -buf_pool->mutex. */ +buf_pool_mutex. */ UNIV_INLINE void* buf_buddy_alloc( @@ -35,7 +35,7 @@ buf_buddy_alloc( ulint size, /* in: block size, up to UNIV_PAGE_SIZE */ ibool* lru) /* in: pointer to a variable that will be assigned TRUE if storage was allocated from the LRU list - and buf_pool->mutex was temporarily released, + and buf_pool_mutex was temporarily released, or NULL if the LRU list should not be used */ __attribute__((malloc)); @@ -51,23 +51,23 @@ buf_buddy_free( __attribute__((nonnull)); /** Number of frames allocated from the buffer pool to the buddy system. -Protected by buf_pool->mutex. */ +Protected by buf_pool_mutex. */ extern ulint buf_buddy_n_frames; /** Preferred minimum number of frames allocated from the buffer pool to the buddy system. Unless this number is exceeded or the buffer pool is scarce, the LRU algorithm will not free compressed-only pages -in order to satisfy an allocation request. Protected by buf_pool->mutex. */ +in order to satisfy an allocation request. Protected by buf_pool_mutex. */ extern ulint buf_buddy_min_n_frames; /** Preferred maximum number of frames allocated from the buffer pool to the buddy system. Unless this number is exceeded, the buddy allocator will not try to free clean compressed-only pages before falling back -to the LRU algorithm. Protected by buf_pool->mutex. */ +to the LRU algorithm. Protected by buf_pool_mutex. */ extern ulint buf_buddy_max_n_frames; /** Counts of blocks allocated from the buddy system. -Protected by buf_pool->mutex. */ +Protected by buf_pool_mutex. */ extern ulint buf_buddy_used[BUF_BUDDY_SIZES + 1]; /** Counts of blocks relocated by the buddy system. -Protected by buf_pool->mutex. */ +Protected by buf_pool_mutex. */ extern ib_uint64_t buf_buddy_relocated[BUF_BUDDY_SIZES + 1]; #ifndef UNIV_NONINL diff --git a/include/buf0buddy.ic b/include/buf0buddy.ic index 5935c1662ba..1b16d49dfb1 100644 --- a/include/buf0buddy.ic +++ b/include/buf0buddy.ic @@ -18,8 +18,8 @@ Created December 2006 by Marko Makela /************************************************************************** Allocate a block. The thread calling this function must hold -buf_pool->mutex and must not hold buf_pool->zip_mutex or any block->mutex. -The buf_pool->mutex may only be released and reacquired if +buf_pool_mutex and must not hold buf_pool_zip_mutex or any block->mutex. +The buf_pool_mutex may only be released and reacquired if lru == BUF_BUDDY_USE_LRU. */ void* @@ -31,7 +31,7 @@ buf_buddy_alloc_low( or BUF_BUDDY_SIZES */ ibool* lru) /* in: pointer to a variable that will be assigned TRUE if storage was allocated from the LRU list - and buf_pool->mutex was temporarily released, + and buf_pool_mutex was temporarily released, or NULL if the LRU list should not be used */ __attribute__((malloc)); @@ -68,13 +68,13 @@ buf_buddy_get_slot( /************************************************************************** Allocate a block. The thread calling this function must hold -buf_pool->mutex and must not hold buf_pool->zip_mutex or any -block->mutex. The buf_pool->mutex may only be released and reacquired +buf_pool_mutex and must not hold buf_pool_zip_mutex or any +block->mutex. The buf_pool_mutex may only be released and reacquired if lru == BUF_BUDDY_USE_LRU. This function should only be used for allocating compressed page frames or control blocks (buf_page_t). Allocated control blocks must be properly initialized immediately after buf_buddy_alloc() has returned the memory, before releasing -buf_pool->mutex. */ +buf_pool_mutex. */ UNIV_INLINE void* buf_buddy_alloc( @@ -84,10 +84,10 @@ buf_buddy_alloc( ulint size, /* in: block size, up to UNIV_PAGE_SIZE */ ibool* lru) /* in: pointer to a variable that will be assigned TRUE if storage was allocated from the LRU list - and buf_pool->mutex was temporarily released, + and buf_pool_mutex was temporarily released, or NULL if the LRU list should not be used */ { - ut_ad(mutex_own(&buf_pool->mutex)); + ut_ad(buf_pool_mutex_own()); return(buf_buddy_alloc_low(buf_buddy_get_slot(size), lru)); } @@ -102,7 +102,7 @@ buf_buddy_free( pointed to by the buffer pool */ ulint size) /* in: block size, up to UNIV_PAGE_SIZE */ { - ut_ad(mutex_own(&buf_pool->mutex)); + ut_ad(buf_pool_mutex_own()); buf_buddy_free_low(buf, buf_buddy_get_slot(size)); } diff --git a/include/buf0buf.h b/include/buf0buf.h index ccf3551bb6b..67de975734e 100644 --- a/include/buf0buf.h +++ b/include/buf0buf.h @@ -947,16 +947,16 @@ for compressed and uncompressed frames */ struct buf_page_struct{ /* None of the following bit-fields must be modified without - holding buf_page_get_mutex() [block->mutex or buf_pool->zip_mutex], + holding buf_page_get_mutex() [block->mutex or buf_pool_zip_mutex], since they can be stored in the same machine word. Some of them are - additionally protected by buf_pool->mutex. */ + additionally protected by buf_pool_mutex. */ unsigned space:32; /* tablespace id */ unsigned offset:32; /* page number */ unsigned state:3; /* state of the control block (@see enum buf_page_state); also - protected by buf_pool->mutex. + protected by buf_pool_mutex. State transitions from BUF_BLOCK_READY_FOR_USE to BUF_BLOCK_MEMORY need not be @@ -972,13 +972,13 @@ struct buf_page_struct{ without holding any mutex or latch */ unsigned io_fix:2; /* type of pending I/O operation (@see enum buf_io_fix); also - protected by buf_pool->mutex */ + protected by buf_pool_mutex */ unsigned buf_fix_count:24;/* count of how manyfold this block is currently bufferfixed */ page_zip_des_t zip; /* compressed page; zip.data (but not the data it points to) is - also protected by buf_pool->mutex */ + also protected by buf_pool_mutex */ buf_page_t* hash; /* node used in chaining to buf_pool->page_hash or buf_pool->zip_hash */ @@ -987,7 +987,7 @@ struct buf_page_struct{ ibool in_zip_hash; /* TRUE if in buf_pool->zip_hash */ #endif /* UNIV_DEBUG */ - /* 2. Page flushing fields; protected by buf_pool->mutex */ + /* 2. Page flushing fields; protected by buf_pool_mutex */ UT_LIST_NODE_T(buf_page_t) list; /* based on state, this is a list @@ -1001,12 +1001,12 @@ struct buf_page_struct{ BUF_BLOCK_ZIP_FREE: zip_free[] */ #ifdef UNIV_DEBUG ibool in_flush_list; /* TRUE if in buf_pool->flush_list; - when buf_pool->mutex is free, the + when buf_pool_mutex is free, the following should hold: in_flush_list == (state == BUF_BLOCK_FILE_PAGE || state == BUF_BLOCK_ZIP_DIRTY) */ ibool in_free_list; /* TRUE if in buf_pool->free; when - buf_pool->mutex is free, the following + buf_pool_mutex is free, the following should hold: in_free_list == (state == BUF_BLOCK_NOT_USED) */ #endif /* UNIV_DEBUG */ @@ -1021,7 +1021,7 @@ struct buf_page_struct{ not yet been flushed on disk; zero if all modifications are on disk */ - /* 3. LRU replacement algorithm fields; protected by buf_pool->mutex */ + /* 3. LRU replacement algorithm fields; protected by buf_pool_mutex */ UT_LIST_NODE_T(buf_page_t) LRU; /* node of the LRU list */ @@ -1166,12 +1166,6 @@ struct buf_pool_struct{ /* 1. General fields */ - mutex_t mutex; /* mutex protecting the buffer pool - struct and control blocks, except the - read-write lock in them */ - mutex_t zip_mutex; /* mutex protecting the control blocks - of compressed-only pages (of type - buf_page_t, not buf_block_t) */ ulint n_chunks; /* number of buffer pool chunks */ buf_chunk_t* chunks; /* buffer pool chunks */ ulint curr_size; /* current pool size in pages */ @@ -1266,6 +1260,26 @@ struct buf_pool_struct{ #endif }; +/* mutex protecting the buffer pool struct and control blocks, except the +read-write lock in them */ +extern mutex_t buf_pool_mutex; +/* mutex protecting the control blocks of compressed-only pages +(of type buf_page_t, not buf_block_t) */ +extern mutex_t buf_pool_zip_mutex; + +/* Accessors for buf_pool_mutex. Use these instead of accessing +buf_pool_mutex directly. */ + +/* Test if buf_pool_mutex is owned. */ +#define buf_pool_mutex_own() mutex_own(&buf_pool_mutex) +/* Acquire the buffer pool mutex. */ +#define buf_pool_mutex_enter() do { \ + ut_ad(!mutex_own(&buf_pool_zip_mutex)); \ + mutex_enter(&buf_pool_mutex); \ +} while (0) +/* Release the buffer pool mutex. */ +#define buf_pool_mutex_exit() mutex_exit(&buf_pool_mutex) + /************************************************************************ Let us list the consistency conditions for different control block states. diff --git a/include/buf0buf.ic b/include/buf0buf.ic index 1119249a66e..4dc524acd18 100644 --- a/include/buf0buf.ic +++ b/include/buf0buf.ic @@ -76,7 +76,7 @@ buf_pool_get_oldest_modification(void) buf_page_t* bpage; ib_uint64_t lsn; - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); bpage = UT_LIST_GET_LAST(buf_pool->flush_list); @@ -87,7 +87,7 @@ buf_pool_get_oldest_modification(void) lsn = bpage->oldest_modification; } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(lsn); } @@ -101,7 +101,7 @@ buf_pool_clock_tic(void) /*====================*/ /* out: new clock value */ { - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); buf_pool->ulint_clock++; @@ -265,7 +265,7 @@ buf_page_get_mutex( break; case BUF_BLOCK_ZIP_PAGE: case BUF_BLOCK_ZIP_DIRTY: - return(&buf_pool->zip_mutex); + return(&buf_pool_zip_mutex); default: return(&((buf_block_t*) bpage)->mutex); } @@ -366,7 +366,7 @@ buf_page_set_io_fix( buf_page_t* bpage, /* in/out: control block */ enum buf_io_fix io_fix) /* in: io_fix state */ { - ut_ad(mutex_own(&buf_pool->mutex)); + ut_ad(buf_pool_mutex_own()); ut_ad(mutex_own(buf_page_get_mutex(bpage))); bpage->io_fix = io_fix; @@ -394,7 +394,7 @@ buf_page_can_relocate( /*==================*/ const buf_page_t* bpage) /* control block being relocated */ { - ut_ad(mutex_own(&buf_pool->mutex)); + ut_ad(buf_pool_mutex_own()); ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_ad(buf_page_in_file(bpage)); ut_ad(bpage->in_LRU_list); @@ -427,7 +427,7 @@ buf_page_set_old( ibool old) /* in: old */ { ut_a(buf_page_in_file(bpage)); - ut_ad(mutex_own(&buf_pool->mutex)); + ut_ad(buf_pool_mutex_own()); bpage->old = old; } @@ -634,9 +634,9 @@ buf_frame_get_page_zip( const byte* ptr) /* in: pointer to the page */ { const page_zip_des_t* page_zip; - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); page_zip = buf_block_get_page_zip(buf_block_align(ptr)); - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); return(page_zip); } #endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */ @@ -701,7 +701,7 @@ buf_block_free( /*===========*/ buf_block_t* block) /* in, own: block to be freed */ { - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); mutex_enter(&block->mutex); @@ -711,7 +711,7 @@ buf_block_free( mutex_exit(&block->mutex); - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); } /************************************************************************* @@ -757,13 +757,13 @@ buf_page_io_query( { ibool io_fixed; - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); ut_ad(buf_page_in_file(bpage)); ut_ad(bpage->buf_fix_count > 0); io_fixed = buf_page_get_io_fix(bpage) != BUF_IO_NONE; - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(io_fixed); } @@ -781,7 +781,7 @@ buf_page_get_newest_modification( { ib_uint64_t lsn; - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); if (buf_page_in_file(bpage)) { lsn = bpage->newest_modification; @@ -789,7 +789,7 @@ buf_page_get_newest_modification( lsn = 0; } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); return(lsn); } @@ -805,7 +805,7 @@ buf_block_modify_clock_inc( buf_block_t* block) /* in: block */ { #ifdef UNIV_SYNC_DEBUG - ut_ad((mutex_own(&(buf_pool->mutex)) + ut_ad((buf_pool_mutex_own() && (block->page.buf_fix_count == 0)) || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE)); #endif /* UNIV_SYNC_DEBUG */ @@ -889,7 +889,7 @@ buf_page_hash_get( ulint fold; ut_ad(buf_pool); - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); /* Look for the page in the hash table */ @@ -936,11 +936,11 @@ buf_page_peek( { const buf_page_t* bpage; - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); bpage = buf_page_hash_get(space, offset); - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); return(bpage != NULL); } @@ -961,9 +961,9 @@ buf_page_release_zip( switch (buf_page_get_state(bpage)) { case BUF_BLOCK_ZIP_PAGE: case BUF_BLOCK_ZIP_DIRTY: - mutex_enter(&buf_pool->zip_mutex); + mutex_enter(&buf_pool_zip_mutex); bpage->buf_fix_count--; - mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool_zip_mutex); return; case BUF_BLOCK_FILE_PAGE: block = (buf_block_t*) bpage; @@ -1003,9 +1003,9 @@ buf_page_release( ut_a(block->page.buf_fix_count > 0); if (rw_latch == RW_X_LATCH && mtr->modifications) { - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); buf_flush_note_modification(block, mtr); - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); } mutex_enter(&block->mutex); diff --git a/include/buf0flu.ic b/include/buf0flu.ic index e99368a7fb8..7a35de25e51 100644 --- a/include/buf0flu.ic +++ b/include/buf0flu.ic @@ -36,7 +36,7 @@ buf_flush_note_modification( #ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ - ut_ad(mutex_own(&(buf_pool->mutex))); + ut_ad(buf_pool_mutex_own()); ut_ad(mtr->start_lsn != 0); ut_ad(mtr->modifications); @@ -76,7 +76,7 @@ buf_flush_recv_note_modification( ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ - mutex_enter(&(buf_pool->mutex)); + buf_pool_mutex_enter(); ut_ad(block->page.newest_modification <= end_lsn); @@ -93,5 +93,5 @@ buf_flush_recv_note_modification( ut_ad(block->page.oldest_modification <= start_lsn); } - mutex_exit(&(buf_pool->mutex)); + buf_pool_mutex_exit(); } diff --git a/include/buf0lru.h b/include/buf0lru.h index 5820a20d2a4..76b26c29fb5 100644 --- a/include/buf0lru.h +++ b/include/buf0lru.h @@ -83,13 +83,13 @@ buf_LRU_free_block( the descriptor object will be freed as well. If this function returns FALSE, it will not temporarily release - buf_pool->mutex. */ + buf_pool_mutex. */ buf_page_t* block, /* in: block to be freed */ ibool zip, /* in: TRUE if should remove also the compressed page of an uncompressed page */ ibool* buf_pool_mutex_released); /* in: pointer to a variable that will - be assigned TRUE if buf_pool->mutex + be assigned TRUE if buf_pool_mutex was temporarily released, or NULL */ /********************************************************************** Look for a replaceable block from the end of the LRU list and put it to diff --git a/include/mtr0log.ic b/include/mtr0log.ic index e3f60c2cd3f..98853568f23 100644 --- a/include/mtr0log.ic +++ b/include/mtr0log.ic @@ -191,10 +191,10 @@ mlog_write_initial_log_record_fast( #endif #ifdef UNIV_DEBUG - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); /* We now assume that all x-latched pages have been modified! */ block = (buf_block_t*) buf_block_align(ptr); - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); if (!mtr_memo_contains(mtr, block, MTR_MEMO_MODIFY)) { diff --git a/include/row0upd.ic b/include/row0upd.ic index ac21c20f3fe..bbec5ebf0b1 100644 --- a/include/row0upd.ic +++ b/include/row0upd.ic @@ -115,9 +115,9 @@ row_upd_rec_sys_fields( ut_ad(rec_offs_validate(rec, index, offsets)); #ifdef UNIV_SYNC_DEBUG if (!rw_lock_own(&btr_search_latch, RW_LOCK_EX)) { - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); ut_ad(!buf_block_align(rec)->is_hashed); - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); } #endif /* UNIV_SYNC_DEBUG */ diff --git a/mtr/mtr0mtr.c b/mtr/mtr0mtr.c index ba362a904c0..70babd45f23 100644 --- a/mtr/mtr0mtr.c +++ b/mtr/mtr0mtr.c @@ -314,9 +314,9 @@ mtr_memo_contains_page( { ibool ret; - mutex_enter(&buf_pool->mutex); + buf_pool_mutex_enter(); ret = mtr_memo_contains(mtr, buf_block_align(ptr), type); - mutex_exit(&buf_pool->mutex); + buf_pool_mutex_exit(); return(ret); }