函数buf_LRU_block_remove_hashed_page

/******************************************************************//**
Takes a block out of the LRU list and page hash table.
If the block is compressed-only (BUF_BLOCK_ZIP_PAGE),
the object will be freed and buf_pool->zip_mutex will be released.

If a compressed page or a compressed-only block descriptor is freed,
other compressed pages or compressed-only block descriptors may be
relocated.
@return the new state of the block (BUF_BLOCK_ZIP_FREE if the state
was BUF_BLOCK_ZIP_PAGE, or BUF_BLOCK_REMOVE_HASH otherwise) */
static
enum buf_page_state
buf_LRU_block_remove_hashed_page(
/*=============================*/
    buf_page_t*    bpage,    /*!< in: block, must contain a file page and
                be in a state where it can be freed; there
                may or may not be a hash index to the page */
    ibool        zip)    /*!< in: TRUE if should remove also the
                compressed page of an uncompressed page */
{
    ulint            fold;
    const buf_page_t*    hashed_bpage;
    buf_pool_t*        buf_pool = buf_pool_from_bpage(bpage);

    ut_ad(bpage);
    ut_ad(buf_pool_mutex_own(buf_pool));
    ut_ad(mutex_own(buf_page_get_mutex(bpage)));

    ut_a(buf_page_get_io_fix(bpage) == BUF_IO_NONE);
    ut_a(bpage->buf_fix_count == 0);

#if UNIV_WORD_SIZE == 4
    /* On 32-bit systems, there is no padding in
    buf_page_t.  On other systems, Valgrind could complain
    about uninitialized pad bytes. */
    UNIV_MEM_ASSERT_RW(bpage, sizeof *bpage);
#endif

    buf_LRU_remove_block(bpage);

    buf_pool->freed_page_clock += 1;

    switch (buf_page_get_state(bpage)) {
    case BUF_BLOCK_FILE_PAGE:
        UNIV_MEM_ASSERT_W(bpage, sizeof(buf_block_t));
        UNIV_MEM_ASSERT_W(((buf_block_t*) bpage)->frame,
                  UNIV_PAGE_SIZE);
        buf_block_modify_clock_inc((buf_block_t*) bpage);
        if (bpage->zip.data) {
            const page_t*    page = ((buf_block_t*) bpage)->frame;
            const ulint    zip_size
                = page_zip_get_size(&bpage->zip);

            ut_a(!zip || bpage->oldest_modification == 0);

            switch (UNIV_EXPECT(fil_page_get_type(page),
                        FIL_PAGE_INDEX)) {
            case FIL_PAGE_TYPE_ALLOCATED:
            case FIL_PAGE_INODE:
            case FIL_PAGE_IBUF_BITMAP:
            case FIL_PAGE_TYPE_FSP_HDR:
            case FIL_PAGE_TYPE_XDES:
                /* These are essentially uncompressed pages. */
                if (!zip) {
                    /* InnoDB writes the data to the
                    uncompressed page frame.  Copy it
                    to the compressed page, which will
                    be preserved. */
                    memcpy(bpage->zip.data, page,
                           zip_size);
                }
                break;
            case FIL_PAGE_TYPE_ZBLOB:
            case FIL_PAGE_TYPE_ZBLOB2:
                break;
            case FIL_PAGE_INDEX:
#ifdef UNIV_ZIP_DEBUG
                ut_a(page_zip_validate(
                         &bpage->zip, page,
                         ((buf_block_t*) bpage)->index));
#endif /* UNIV_ZIP_DEBUG */
                break;
            default:
                ut_print_timestamp(stderr);
                fputs("  InnoDB: ERROR: The compressed page"
                      " to be evicted seems corrupt:", stderr);
                ut_print_buf(stderr, page, zip_size);
                fputs("\nInnoDB: Possibly older version"
                      " of the page:", stderr);
                ut_print_buf(stderr, bpage->zip.data,
                         zip_size);
                putc(‘\n‘, stderr);
                ut_error;
            }

            break;
        }
        /* fall through */
    case BUF_BLOCK_ZIP_PAGE:
        ut_a(bpage->oldest_modification == 0);
        UNIV_MEM_ASSERT_W(bpage->zip.data,
                  page_zip_get_size(&bpage->zip));
        break;
    case BUF_BLOCK_ZIP_FREE:
    case BUF_BLOCK_ZIP_DIRTY:
    case BUF_BLOCK_NOT_USED:
    case BUF_BLOCK_READY_FOR_USE:
    case BUF_BLOCK_MEMORY:
    case BUF_BLOCK_REMOVE_HASH:
        ut_error;
        break;
    }

    fold = buf_page_address_fold(bpage->space, bpage->offset);
    hashed_bpage = buf_page_hash_get_low(
        buf_pool, bpage->space, bpage->offset, fold);

    if (UNIV_UNLIKELY(bpage != hashed_bpage)) {
        fprintf(stderr,
            "InnoDB: Error: page %lu %lu not found"
            " in the hash table\n",
            (ulong) bpage->space,
            (ulong) bpage->offset);
        if (hashed_bpage) {
            fprintf(stderr,
                "InnoDB: In hash table we find block"
                " %p of %lu %lu which is not %p\n",
                (const void*) hashed_bpage,
                (ulong) hashed_bpage->space,
                (ulong) hashed_bpage->offset,
                (const void*) bpage);
        }

#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
        mutex_exit(buf_page_get_mutex(bpage));
        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(!bpage->in_zip_hash);
    ut_ad(bpage->in_page_hash);
    ut_d(bpage->in_page_hash = FALSE);
    HASH_DELETE(buf_page_t, hash, buf_pool->page_hash, fold, bpage); //这里    switch (buf_page_get_state(bpage)) {
    case BUF_BLOCK_ZIP_PAGE:
        ut_ad(!bpage->in_free_list);
        ut_ad(!bpage->in_flush_list);
        ut_ad(!bpage->in_LRU_list);
        ut_a(bpage->zip.data);
        ut_a(buf_page_get_zip_size(bpage));

#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
        UT_LIST_REMOVE(list, buf_pool->zip_clean, bpage);
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */

        mutex_exit(&buf_pool->zip_mutex);
        buf_pool_mutex_exit_forbid(buf_pool);

        buf_buddy_free(
            buf_pool, bpage->zip.data,
            page_zip_get_size(&bpage->zip));

        buf_pool_mutex_exit_allow(buf_pool);
        buf_page_free_descriptor(bpage);
        return(BUF_BLOCK_ZIP_FREE);

    case BUF_BLOCK_FILE_PAGE:
        memset(((buf_block_t*) bpage)->frame
               + FIL_PAGE_OFFSET, 0xff, 4);
        memset(((buf_block_t*) bpage)->frame
               + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 0xff, 4);
        UNIV_MEM_INVALID(((buf_block_t*) bpage)->frame,
                 UNIV_PAGE_SIZE);
        buf_page_set_state(bpage, BUF_BLOCK_REMOVE_HASH);

        if (zip && bpage->zip.data) {
            /* Free the compressed page. */
            void*    data = bpage->zip.data;
            bpage->zip.data = NULL;

            ut_ad(!bpage->in_free_list);
            ut_ad(!bpage->in_flush_list);
            ut_ad(!bpage->in_LRU_list);
            mutex_exit(&((buf_block_t*) bpage)->mutex);
            buf_pool_mutex_exit_forbid(buf_pool);

            buf_buddy_free(
                buf_pool, data,
                page_zip_get_size(&bpage->zip));

            buf_pool_mutex_exit_allow(buf_pool);
            mutex_enter(&((buf_block_t*) bpage)->mutex);
            page_zip_set_size(&bpage->zip, 0);
        }

        return(BUF_BLOCK_REMOVE_HASH);

    case BUF_BLOCK_ZIP_FREE:
    case BUF_BLOCK_ZIP_DIRTY:
    case BUF_BLOCK_NOT_USED:
    case BUF_BLOCK_READY_FOR_USE:
    case BUF_BLOCK_MEMORY:
    case BUF_BLOCK_REMOVE_HASH:
        break;
    }

    ut_error;
    return(BUF_BLOCK_ZIP_FREE);
}
时间: 2024-11-03 21:38:15

函数buf_LRU_block_remove_hashed_page的相关文章

js高阶函数

map()方法定义在JavaScript的Array中,我们调用Array的map()方法,传入我们自己的函数,就得到了一个新的Array作为结果: function pow(x) { return x * x; } var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]; arr.map(pow); // [1, 4, 9, 16, 25, 36, 49, 64, 81] reduce()把一个函数作用在这个Array的[x1, x2, x3...]上,这个函数必须接收两个

Django url 标签和reverse()函数的使用(转)

原文:http://www.yihaomen.com/article/python/355.htm 使用url标签和reverse()函数,可以避免在模板和view中对url进行硬编码,这样即使url改变了,对模板和view也没有影响 起初用django 开发应用的时候,完全是在urls.py 中硬编码配置地址,在views.py中HttpResponseRedirect()也是硬编码转向地址,当然在template 中也是一样了,这样带来一个问题,如果在urls.py 中修改了某个页面的地址,

Python2.7-内置函数

具体参见:https://docs.python.org/2/library/functions.html#file 1.进制转换:bin(x), oct(x), hex(x) 把一个十进制数分别转换为2.8.16进制 2.字符转换:chr(x)将数字(255以内不报错,128以后无字符)转换为对应ASCII字符, unichr(x)将数字转换为unicode, ord(x) 将字符转数字与前两个相反, unicode(obj, [encoding, [error]]) 用encoding解码o

linux Shell函数

Shell函数类似于Shell脚本,里面存放了一系列的指令,不过Shell的函数存在于内存,而不是硬盘文件,所以速度很快,另外,Shell还能对函数进行预处理,所以函数的启动比脚本更快. 1.函数定义 1 2 3 4 function 函数名() {     语句     [return] } 关键字function表示定义一个函数,可以省略,其后是函数名,有时函数名后可以跟一个括号,符号"{"表示函数执行命令的入口,该符号也可以在函数名那一行,"}"表示函数体的结

pythonの函数学习笔记(一)

函数是可以实现一些特定功能的小方法或小程序定义函数function的方法:def function_name(arg1,arg2[,...]): statement [return value]注意事项:1.def开头,代表定义函数,def和函数名中间要敲一个空格:2.返回值不是必须的,如果没有renturn语句,则默认返回值None:3.函数名必须以下划线或字母开头,可以包含任意字母.数字或下划线的组合,区分大小写且不能是保留字: py使用名称空间的概念存储对象,这个名称空间就是对象作用的区域

条件、循环、函数定义、字符串操作练习

注意标准库的两种导入与使用方式,建议大家采用<库名>.<函数名>的方式. 对前面的代码进行优化,用for,while,if,def实现: 用循环画五角星 1 import turtle 2 3 turtle.fillcolor("red") 4 turtle.begin_fill() 5 for i in range(5): 6 turtle.forward(100) 7 turtle.right(144) 8 turtle.end_fill() 用循环画同心圆

sql常用格式化函数及字符串函数

一.常用格式化函数 1.日期转字符串 select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS') //2017-09-18 22:41:50 YYYY:年(4和更多位) MM:月份号(01-12) DD:一个月里的日(01-31) HH24:一天的小时数(00-23) MI:分钟(00-59) SS:秒(00-59) 2.字符串转日期 select to_date('2017-09-18','YYYY-MM-DD') //2017-09-

Delphi常用系统函数总结

字符串处理函数 Unit System 函数原型 function Concat(s1 [, s2,..., sn]: string): string; 说明 与 S := S1 + S2 + S3 ...; 相同. 将字符串相加. 函数原型 function Copy(S: string; Index, Count: Integer): string;说明 S : 字符串. Indexd : 从第几位开始拷贝. Count : 总共要拷贝几位. 从母字符串拷贝至另一个字符串. 函数原型 pro

python练习之map()和reduce()函数

利用map()函数,把用户输入的不规范的英文名字,变为首字母大写,其他小写的规范名字.输入:['adam', 'LISA', 'barT'],输出:['Adam', 'Lisa', 'Bart']: 1 def normalize(name): 2 name=name.lower() 3 name=name[0].upper()+name[1:] 4 return name 5 6 7 8 9 10 # 测试: 11 L1 = ['adam', 'LISA', 'barT'] 12 L2 = l