Commit cdb5b464 authored by marko's avatar marko

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.
parent 4c8c6f37
......@@ -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);
}
......
......@@ -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);
......
......@@ -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);
......
This diff is collapsed.
......@@ -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);
}
......
This diff is collapsed.
......@@ -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)) {
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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));
}
......
......@@ -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.
......
......@@ -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);
......
......@@ -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();
}
......@@ -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
......
......@@ -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)) {
......
......@@ -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 */
......
......@@ -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);
}
......
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