函数buf_LRU_add_block

/******************************************************************//**
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);//插入到buff_pool头结点 详见

        bpage->freed_page_clock = buf_pool->freed_page_clock;
    } else {

        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);

    

        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);//设置lru->old位置 详见

    } 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)) {//如果是压缩的页,则放到uzip_lru中
        buf_unzip_LRU_add_block((buf_block_t*) bpage, old);
    }
}
上一篇:Redis数据结构详解之Set(三)


下一篇:docker制作node程序镜像: