函数buf_LRU_free_from_unzip_LRU_list

时间:2022-05-15 05:09:07
/******************************************************************//**
Try to free an uncompressed page of a compressed block from the unzip
LRU list.  The compressed page is preserved, and it need not be clean.
@return    TRUE if freed */
UNIV_INLINE
ibool
buf_LRU_free_from_unzip_LRU_list(
/*=============================*/
    buf_pool_t*    buf_pool,    /*!< in: buffer pool instance */
    ulint        n_iterations)    /*!< in: how many times this has
                    been called repeatedly without
                    result: a high value means that
                    we should search farther; we will
                    search n_iterations / 5 of the
                    unzip_LRU list, or nothing if
                    n_iterations >= 5 */
{
    buf_block_t*    block;
    ulint        distance;

    ut_ad(buf_pool_mutex_own(buf_pool));

    /* Theoratically it should be much easier to find a victim
    from unzip_LRU as we can choose even a dirty block (as we'll
    be evicting only the uncompressed frame).  In a very unlikely
    eventuality that we are unable to find a victim from
    unzip_LRU, we fall back to the regular LRU list.  We do this
    if we have done five iterations so far. */

    )
        || !buf_LRU_evict_from_unzip_LRU(buf_pool)) {

        return(FALSE);
    }

    distance =  +; //宏详见   for (block = UT_LIST_GET_LAST(buf_pool->unzip_LRU);
         UNIV_LIKELY(block != NULL) && UNIV_LIKELY(distance > );
         block = UT_LIST_GET_PREV(unzip_LRU, block), distance--) {

        ibool freed;

        ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
        ut_ad(block->in_unzip_LRU_list);
        ut_ad(block->page.in_LRU_list);

        mutex_enter(&block->mutex);
        freed = buf_LRU_free_block(&block->page, FALSE); //这里
        mutex_exit(&block->mutex);

        if (freed) {
            return(TRUE);
        }
    }

    return(FALSE);
}