函数buf_page_init

 

/********************************************************************//**
Inits a page to the buffer buf_pool. */
static __attribute__((nonnull))
void
buf_page_init(
/*==========*/
    buf_pool_t*    buf_pool,/*!< in/out: buffer pool */
    ulint        space,    /*!< in: space id */
    ulint        offset,    /*!< in: offset of the page within space
                in units of a page */
    ulint        fold,    /*!< in: buf_page_address_fold(space,offset) */
    ulint        zip_size,/*!< in: compressed page size, or 0 */
    buf_block_t*    block)    /*!< in/out: block to init */
{
    buf_page_t*    hash_page;

    ut_ad(buf_pool == buf_pool_get(space, offset));
    ut_ad(buf_pool_mutex_own(buf_pool));
    ut_ad(mutex_own(&(block->mutex)));
    ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE);

    /* Set the state of the block */
    buf_block_set_file_page(block, space, offset);
    buf_block_init_low(block);

    block->lock_hash_val = lock_rec_hash(space, offset);

    buf_page_init_low(&block->page);

    /* Insert into the hash table of file pages */

    hash_page = buf_page_hash_get_low(buf_pool, space, offset, fold);//在hash中查找page 详见    if (UNIV_LIKELY(!hash_page)) {
    } else if (buf_pool_watch_is_sentinel(buf_pool, hash_page)) {
        /* Preserve the reference count. */
        ulint    buf_fix_count = hash_page->buf_fix_count;

        ut_a(buf_fix_count > 0);
        block->page.buf_fix_count += buf_fix_count;
        buf_pool_watch_remove(buf_pool, fold, hash_page);
    } else {
        fprintf(stderr,
            "InnoDB: Error: page %lu %lu already found"
            " in the hash table: %p, %p\n",
            (ulong) space,
            (ulong) offset,
            (const void*) hash_page, (const void*) block);
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
        mutex_exit(&block->mutex);
        buf_pool_mutex_exit(buf_pool);
        buf_print();
        buf_LRU_print();
        buf_validate();
        buf_LRU_validate();
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
        ut_error;
    }

    ut_ad(!block->page.in_zip_hash);
    ut_ad(!block->page.in_page_hash);
    ut_d(block->page.in_page_hash = TRUE);
    HASH_INSERT(buf_page_t, hash, buf_pool->page_hash,fold, &block->page);
    if (zip_size) {
        page_zip_set_size(&block->page.zip, zip_size);
    }
}

 

你可能感兴趣的:(函数buf_page_init)