Commit 06bb7e6e authored by marko's avatar marko

branches/zip: Replace buf_frame_alloc() and buf_frame_free()

with buf_block_alloc() and buf_block_free(), in order to
avoid buf_block_align() calls.
parent 5669dc3d
......@@ -851,6 +851,7 @@ btr_page_reorganize_low(
mtr_t* mtr) /* in: mtr */
{
buf_block_t* block;
buf_block_t* temp_block;
page_t* temp_page;
ulint log_mode;
ulint data_size1;
......@@ -876,7 +877,8 @@ btr_page_reorganize_low(
/* Turn logging off */
log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE);
temp_page = buf_frame_alloc();
temp_block = buf_block_alloc(0);
temp_page = temp_block->frame;
/* Copy the old page to temporary space */
buf_frame_copy(temp_page, page);
......@@ -940,7 +942,7 @@ func_exit:
#ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */
buf_frame_free(temp_page);
buf_block_free(temp_block);
/* Restore logging mode */
mtr_set_log_mode(mtr, log_mode);
......
......@@ -91,7 +91,6 @@ void
btr_search_check_free_space_in_heap(void)
/*=====================================*/
{
buf_frame_t* frame;
hash_table_t* table;
mem_heap_t* heap;
......@@ -109,14 +108,14 @@ btr_search_check_free_space_in_heap(void)
be enough free space in the hash table. */
if (heap->free_block == NULL) {
frame = buf_frame_alloc();
buf_block_t* block = buf_block_alloc(0);
rw_lock_x_lock(&btr_search_latch);
if (heap->free_block == NULL) {
heap->free_block = frame;
heap->free_block = block;
} else {
buf_frame_free(frame);
buf_block_free(block);
}
rw_lock_x_unlock(&btr_search_latch);
......
......@@ -127,20 +127,6 @@ buf_block_free(
/*===========*/
buf_block_t* block); /* in, own: block to be freed */
/*************************************************************************
Allocates a buffer frame. */
UNIV_INLINE
buf_frame_t*
buf_frame_alloc(void);
/*==================*/
/* out: buffer frame */
/*************************************************************************
Frees a buffer frame which does not contain a file page. */
UNIV_INLINE
void
buf_frame_free(
/*===========*/
buf_frame_t* frame); /* in: buffer frame */
/*************************************************************************
Copies contents of a buffer frame to a given buffer. */
UNIV_INLINE
byte*
......
......@@ -364,28 +364,6 @@ buf_block_free(
mutex_exit(&(buf_pool->mutex));
}
/*************************************************************************
Allocates a buffer frame. */
UNIV_INLINE
buf_frame_t*
buf_frame_alloc(void)
/*=================*/
/* out: buffer frame */
{
return(buf_block_alloc(0)->frame);
}
/*************************************************************************
Frees a buffer frame which does not contain a file page. */
UNIV_INLINE
void
buf_frame_free(
/*===========*/
buf_frame_t* frame) /* in: buffer frame */
{
buf_block_free(buf_block_align(frame));
}
/*************************************************************************
Copies contents of a buffer frame to a given buffer. */
UNIV_INLINE
......
......@@ -395,12 +395,16 @@ struct mem_block_info_struct {
user data in the block */
ulint start; /* the value of the struct field 'free' at the
creation of the block */
byte* free_block;
void* free_block;
/* if the MEM_HEAP_BTR_SEARCH bit is set in type,
and this is the heap root, this can contain an
allocated buffer frame, which can be appended as a
free block to the heap, if we need more space;
otherwise, this is NULL */
void* buf_block;
/* if this block has been allocated from the buffer
pool, this contains the buf_block_t handle;
otherwise, this is NULL */
#ifdef MEM_PERIODIC_CHECK
UT_LIST_NODE_T(mem_block_t) mem_block_list;
/* List of all mem blocks allocated; protected
......
......@@ -338,6 +338,7 @@ mem_heap_create_block(
const char* file_name,/* in: file name where created */
ulint line) /* in: line where created */
{
buf_block_t* buf_block = NULL;
mem_block_t* block;
ulint len;
......@@ -376,10 +377,13 @@ mem_heap_create_block(
buffer pool, but must get the free block from
the heap header free block field */
block = (mem_block_t*)heap->free_block;
block = (mem_block_t*)
((buf_block_t*) heap->free_block)
->frame;
heap->free_block = NULL;
} else {
block = (mem_block_t*)buf_frame_alloc();
buf_block = buf_block_alloc(0);
block = (mem_block_t*) buf_block->frame;
}
}
}
......@@ -391,6 +395,7 @@ mem_heap_create_block(
return(NULL);
}
block->buf_block = buf_block;
block->magic_n = MEM_BLOCK_MAGIC_N;
ut_strlcpy_rev(block->file_name, file_name, sizeof(block->file_name));
block->line = line;
......@@ -520,13 +525,15 @@ mem_heap_block_free(
} else if (type == MEM_HEAP_DYNAMIC) {
ut_ad(!block->buf_block);
mem_area_free(block, mem_comm_pool);
} else {
ut_ad(type & MEM_HEAP_BUFFER);
if (len >= UNIV_PAGE_SIZE / 2) {
buf_frame_free((byte*)block);
buf_block_free(block->buf_block);
} else {
ut_ad(!block->buf_block);
mem_area_free(block, mem_comm_pool);
}
}
......@@ -540,9 +547,9 @@ mem_heap_free_block_free(
/*=====================*/
mem_heap_t* heap) /* in: heap */
{
if (heap->free_block) {
if (UNIV_LIKELY_NULL(heap->free_block)) {
buf_frame_free(heap->free_block);
buf_block_free(heap->free_block);
heap->free_block = NULL;
}
......
......@@ -3511,6 +3511,7 @@ page_zip_reorganize(
mtr_t* mtr) /* in: mini-transaction */
{
buf_block_t* block;
buf_block_t* temp_block;
page_t* temp_page;
ulint log_mode;
......@@ -3521,7 +3522,8 @@ page_zip_reorganize(
/* Disable logging */
log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE);
temp_page = buf_frame_alloc();
temp_block = buf_block_alloc(0);
temp_page = temp_block->frame;
/* Copy the old page to temporary space */
buf_frame_copy(temp_page, page);
......@@ -3549,14 +3551,14 @@ page_zip_reorganize(
/* Restore the old page and exit. */
buf_frame_copy(page, temp_page);
buf_frame_free(temp_page);
buf_block_free(temp_block);
return(FALSE);
}
lock_move_reorganize_page(page, temp_page);
btr_search_drop_page_hash_index(block);
buf_frame_free(temp_page);
buf_block_free(temp_block);
return(TRUE);
}
......
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