Commit 79782263 authored by marko's avatar marko

branches/zip: Refactor some code for relocating buffer control blocks.

buf_relocate(): New function, split from buf_buddy_relocate().
parent cb530ba3
...@@ -354,24 +354,9 @@ buf_buddy_relocate( ...@@ -354,24 +354,9 @@ buf_buddy_relocate(
if (buf_flush_ready_for_replace(bpage)) { if (buf_flush_ready_for_replace(bpage)) {
buf_page_t* dpage = (buf_page_t*) dst; buf_page_t* dpage = (buf_page_t*) dst;
buf_page_t* b; buf_page_t* b;
ulint fold
= buf_page_address_fold(bpage->space,
bpage->offset);
memcpy(dpage, bpage, size); memcpy(dpage, bpage, size);
buf_relocate(bpage, dpage);
/* relocate buf_pool->LRU */
b = UT_LIST_GET_PREV(LRU, bpage);
UT_LIST_REMOVE(LRU, buf_pool->LRU, bpage);
if (b) {
UT_LIST_INSERT_AFTER(
LRU, buf_pool->LRU, b, dpage);
} else {
UT_LIST_ADD_FIRST(
LRU, buf_pool->LRU, dpage);
}
/* relocate buf_pool->zip_clean */ /* relocate buf_pool->zip_clean */
b = UT_LIST_GET_PREV(list, bpage); b = UT_LIST_GET_PREV(list, bpage);
...@@ -387,12 +372,6 @@ buf_buddy_relocate( ...@@ -387,12 +372,6 @@ buf_buddy_relocate(
list, buf_pool->zip_clean, list, buf_pool->zip_clean,
dpage); dpage);
} }
/* relocate buf_pool->page_hash */
HASH_DELETE(buf_page_t, hash,
buf_pool->page_hash, fold, bpage);
HASH_INSERT(buf_page_t, hash,
buf_pool->page_hash, fold, dpage);
} }
mutex_exit(&buf_pool->zip_mutex); mutex_exit(&buf_pool->zip_mutex);
......
...@@ -898,6 +898,45 @@ buf_pool_init(void) ...@@ -898,6 +898,45 @@ buf_pool_init(void)
return(buf_pool); return(buf_pool);
} }
/************************************************************************
Relocate a buffer control block. Relocates the block on the LRU list
and in buf_pool->page_hash. Does not relocate bpage->list. */
void
buf_relocate(
/*=========*/
buf_page_t* bpage, /* control block being relocated */
buf_page_t* dpage) /* destination control block */
{
buf_page_t* b;
ulint fold;
#ifdef UNIV_SYNC_DEBUG
ut_a(mutex_own(&buf_pool->mutex));
ut_a(mutex_own(buf_page_get_mutex(bpage)));
ut_a(mutex_own(buf_page_get_mutex(dpage)));
#endif /* UNIV_SYNC_DEBUG */
ut_a(buf_page_get_io_fix(bpage) == BUF_IO_NONE);
ut_a(bpage->buf_fix_count == 0);
ut_a(buf_page_in_file(bpage));
/* relocate buf_pool->LRU */
b = UT_LIST_GET_PREV(LRU, bpage);
UT_LIST_REMOVE(LRU, buf_pool->LRU, bpage);
if (b) {
UT_LIST_INSERT_AFTER(LRU, buf_pool->LRU, b, dpage);
} else {
UT_LIST_ADD_FIRST(LRU, buf_pool->LRU, dpage);
}
/* relocate buf_pool->page_hash */
fold = buf_page_address_fold(bpage->space, bpage->offset);
HASH_DELETE(buf_page_t, hash, buf_pool->page_hash, fold, bpage);
HASH_INSERT(buf_page_t, hash, buf_pool->page_hash, fold, dpage);
}
/************************************************************************ /************************************************************************
Shrinks the buffer pool. */ Shrinks the buffer pool. */
static static
......
...@@ -87,6 +87,16 @@ buf_pool_init(void); ...@@ -87,6 +87,16 @@ buf_pool_init(void);
/* out, own: buf_pool object, NULL if not /* out, own: buf_pool object, NULL if not
enough memory or error */ enough memory or error */
/************************************************************************ /************************************************************************
Relocate a buffer control block. Relocates the block on the LRU list
and in buf_pool->page_hash. Does not relocate bpage->list. */
void
buf_relocate(
/*=========*/
buf_page_t* bpage, /* control block being relocated */
buf_page_t* dpage) /* destination control block */
__attribute__((nonnull));
/************************************************************************
Resizes the buffer pool. */ Resizes the buffer pool. */
void void
......
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