diff --git a/buf/buf0buddy.c b/buf/buf0buddy.c index 4ed56621ce2..b8a5cf9cf4c 100644 --- a/buf/buf0buddy.c +++ b/buf/buf0buddy.c @@ -354,24 +354,9 @@ buf_buddy_relocate( if (buf_flush_ready_for_replace(bpage)) { buf_page_t* dpage = (buf_page_t*) dst; buf_page_t* b; - ulint fold - = buf_page_address_fold(bpage->space, - bpage->offset); memcpy(dpage, bpage, size); - - /* 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); - } + buf_relocate(bpage, dpage); /* relocate buf_pool->zip_clean */ b = UT_LIST_GET_PREV(list, bpage); @@ -387,12 +372,6 @@ buf_buddy_relocate( list, buf_pool->zip_clean, 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); diff --git a/buf/buf0buf.c b/buf/buf0buf.c index e2b90334f42..5d1081ae010 100644 --- a/buf/buf0buf.c +++ b/buf/buf0buf.c @@ -898,6 +898,45 @@ buf_pool_init(void) 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. */ static diff --git a/include/buf0buf.h b/include/buf0buf.h index 5d7a727ef78..76814fef26c 100644 --- a/include/buf0buf.h +++ b/include/buf0buf.h @@ -87,6 +87,16 @@ buf_pool_init(void); /* out, own: buf_pool object, NULL if not 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. */ void