/******************************************************************//** Adds a block to the LRU list. Please make sure that the zip_size is already set into the page zip when invoking the function, so that we can get correct zip_size from the buffer page when adding a block into LRU */ UNIV_INTERN void buf_LRU_add_block( /*==============*/ buf_page_t* bpage, /*!< in: control block */ ibool old) /*!< in: TRUE if should be put to the old blocks in the LRU list, else put to the start; if the LRU list is very short, the block is added to the start, regardless of this parameter */ { buf_LRU_add_block_low(bpage, old); } /******************************************************************//** Adds a block to the LRU list. Please make sure that the zip_size is already set into the page zip when invoking the function, so that we can get correct zip_size from the buffer page when adding a block into LRU */ UNIV_INLINE void buf_LRU_add_block_low( /*==================*/ buf_page_t* bpage, /*!< in: control block */ ibool old) /*!< in: TRUE if should be put to the old blocks in the LRU list, else put to the start; if the LRU list is very short, the block is added to the start, regardless of this parameter */ { buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); ut_ad(buf_pool); ut_ad(bpage); ut_ad(buf_pool_mutex_own(buf_pool)); ut_a(buf_page_in_file(bpage)); ut_ad(!bpage->in_LRU_list); if (!old || (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN)) { UT_LIST_ADD_FIRST(LRU, buf_pool->LRU, bpage); bpage->freed_page_clock = buf_pool->freed_page_clock; } else { #ifdef UNIV_LRU_DEBUG /* buf_pool->LRU_old must be the first item in the LRU list whose "old" flag is set. */ ut_a(buf_pool->LRU_old->old); ut_a(!UT_LIST_GET_PREV(LRU, buf_pool->LRU_old) || !UT_LIST_GET_PREV(LRU, buf_pool->LRU_old)->old); ut_a(!UT_LIST_GET_NEXT(LRU, buf_pool->LRU_old) || UT_LIST_GET_NEXT(LRU, buf_pool->LRU_old)->old); #endif /* UNIV_LRU_DEBUG */ UT_LIST_INSERT_AFTER(LRU, buf_pool->LRU, buf_pool->LRU_old, bpage); buf_pool->LRU_old_len++; } ut_d(bpage->in_LRU_list = TRUE); incr_LRU_size_in_bytes(bpage, buf_pool); if (UT_LIST_GET_LEN(buf_pool->LRU) > BUF_LRU_OLD_MIN_LEN) { ut_ad(buf_pool->LRU_old); /* Adjust the length of the old block list if necessary */ buf_page_set_old(bpage, old); buf_LRU_old_adjust_len(buf_pool); } else if (UT_LIST_GET_LEN(buf_pool->LRU) == BUF_LRU_OLD_MIN_LEN) { /* The LRU list is now long enough for LRU_old to become defined: init it */ buf_LRU_old_init(buf_pool); } else { buf_page_set_old(bpage, buf_pool->LRU_old != NULL); } /* If this is a zipped block with decompressed frame as well then put it on the unzip_LRU list */ if (buf_page_belongs_to_unzip_LRU(bpage)) { buf_unzip_LRU_add_block((buf_block_t*) bpage, old); } }
时间: 2024-10-08 20:50:06