/********************************************************************//**
Low-level function which reads a page asynchronously from a file to the
buffer buf_pool if it is not already there, in which case does nothing.
Sets the io_fix flag and sets an exclusive lock on the buffer frame. The
flag is cleared and the x-lock released by an i/o-handler thread.
@return 1 if a read request was queued, 0 if the page already resided
in buf_pool, or if the page is in the doublewrite buffer blocks in
which case it is never read into the pool, or if the tablespace does
not exist or is being dropped
@return 1 if read request is issued. 0 if it is not */
static
ulint
buf_read_page_low(
/*==============*/
    ulint*    err,    /*!< out: DB_SUCCESS or DB_TABLESPACE_DELETED if we are
            trying to read from a non-existent tablespace, or a
            tablespace which is just now being dropped */
    ibool    sync,    /*!< in: TRUE if synchronous aio is desired */
    ulint    mode,    /*!< in: BUF_READ_IBUF_PAGES_ONLY, ...,
            ORed to OS_AIO_SIMULATED_WAKE_LATER (see below
            at read-ahead functions) */
    ulint    space,    /*!< in: space id */
    ulint    zip_size,/*!< in: compressed page size, or 0 */
    ibool    unzip,    /*!< in: TRUE=request uncompressed page */
    ib_int64_t tablespace_version, /*!< in: if the space memory object has
            this timestamp different from what we are giving here,
            treat the tablespace as dropped; this is a timestamp we
            use to stop dangling page reads from a tablespace
            which we have DISCARDed + IMPORTed back */
    ulint    offset)    /*!< in: page number */
{
    buf_page_t*    bpage;
    ulint        wake_later;

    *err = DB_SUCCESS;

    wake_later = mode & OS_AIO_SIMULATED_WAKE_LATER;
    mode = mode & ~OS_AIO_SIMULATED_WAKE_LATER;

    if (trx_doublewrite && space == TRX_SYS_SPACE
        && (   (offset >= trx_doublewrite->block1
            && offset < trx_doublewrite->block1
            + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE)
           || (offset >= trx_doublewrite->block2
               && offset < trx_doublewrite->block2
               + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE))) {
        ut_print_timestamp(stderr);
        fprintf(stderr,
            "  InnoDB: Warning: trying to read"
            " doublewrite buffer page %lu\n",
            (ulong) offset);

        );
    }

    if (ibuf_bitmap_page(zip_size, offset)
        || trx_sys_hdr_page(space, offset)) {

        /* Trx sys header is so low in the latching order that we play
        safe and do not leave the i/o-completion to an asynchronous
        i/o-thread. Ibuf bitmap pages must always be read with
        syncronous i/o, to make sure they do not get involved in
        thread deadlocks. */

        sync = TRUE;
    }

    /* The following call will also check if the tablespace does not exist
    or is being dropped; if we succeed in initing the page in the buffer
    pool for read, then DISCARD cannot proceed until the read has
    completed */
    bpage = buf_page_init_for_read(err, mode, space, zip_size, unzip,tablespace_version, offset);
    if (bpage == NULL) {

        );
    }

    ut_ad(buf_page_in_file(bpage));

    if (sync) {
        thd_wait_begin(NULL, THD_WAIT_DISKIO);
    }

    if (zip_size) {
        *err = fil_io(OS_FILE_READ | wake_later,
                  sync, space, zip_size, offset, , zip_size,
                  bpage->zip.data, bpage);
    } else {
        ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE);
        //从硬盘中取数据 详见*err = fil_io(OS_FILE_READ | wake_later,
                  sync, space, , offset, , UNIV_PAGE_SIZE,
                  ((buf_block_t*) bpage)->frame, bpage);
    }

    if (sync) {
        thd_wait_end(NULL);
    }

    if (*err == DB_TABLESPACE_DELETED) {
        buf_read_page_handle_error(bpage);
        );
    }

    ut_a(*err == DB_SUCCESS);

    if (sync) {
        /* The i/o is already completed when we arrive from
        fil_read */
        if (!buf_page_io_complete(bpage)) {
            );
        }
    }

    );
}

函数buf_read_page_low的更多相关文章

  1. Python 小而美的函数

    python提供了一些有趣且实用的函数,如any all zip,这些函数能够大幅简化我们得代码,可以更优雅的处理可迭代的对象,同时使用的时候也得注意一些情况   any any(iterable) ...

  2. 探究javascript对象和数组的异同,及函数变量缓存技巧

    javascript中最经典也最受非议的一句话就是:javascript中一切皆是对象.这篇重点要提到的,就是任何jser都不陌生的Object和Array. 有段时间曾经很诧异,到底两种数据类型用来 ...

  3. JavaScript权威指南 - 函数

    函数本身就是一段JavaScript代码,定义一次但可能被调用任意次.如果函数挂载在一个对象上,作为对象的一个属性,通常这种函数被称作对象的方法.用于初始化一个新创建的对象的函数被称作构造函数. 相对 ...

  4. C++对C的函数拓展

    一,内联函数 1.内联函数的概念 C++中的const常量可以用来代替宏常数的定义,例如:用const int a = 10来替换# define a 10.那么C++中是否有什么解决方案来替代宏代码 ...

  5. 菜鸟Python学习笔记第一天:关于一些函数库的使用

    2017年1月3日 星期二 大一学习一门新的计算机语言真的很难,有时候连函数拼写出错查错都能查半天,没办法,谁让我英语太渣. 关于计算机语言的学习我想还是从C语言学习开始为好,Python有很多语言的 ...

  6. javascript中的this与函数讲解

    前言 javascript中没有块级作用域(es6以前),javascript中作用域分为函数作用域和全局作用域.并且,大家可以认为全局作用域其实就是Window函数的函数作用域,我们编写的js代码, ...

  7. 复杂的 Hash 函数组合有意义吗?

    很久以前看到一篇文章,讲某个大网站储存用户口令时,会经过十分复杂的处理.怎么个复杂记不得了,大概就是先 Hash,结果加上一些特殊字符再 Hash,结果再加上些字符.再倒序.再怎么怎么的.再 Hash ...

  8. JS核心系列:浅谈函数的作用域

    一.作用域(scope) 所谓作用域就是:变量在声明它们的函数体以及这个函数体嵌套的任意函数体内都是有定义的. function scope(){ var foo = "global&quo ...

  9. C++中的时间函数

    C++获取时间函数众多,何时该用什么函数,拿到的是什么时间?该怎么用?很多人都会混淆. 本文是本人经历了几款游戏客户端和服务器开发后,对游戏中时间获取的一点总结. 最早学习游戏客户端时,为了获取最精确 ...

随机推荐

  1. NodeJS -Express 4.0 用include取代partial

    在Express 4.0 下按如下方法设置: (1)运行cmd 输入:npm install express-partials -g (2)下载成功后.在app.js 中引用此插件   var par ...

  2. Android keyevent 中的各个值

    Android keyevent 中的各个值,在使用adb shell input 的时候用得到. 是从http://blog.csdn.net/huiguixian/article/details/ ...

  3. Ubuntu 12.4 下升级 Subversion 1.7

    Ubuntu 12.04 默认使用的是Subversion 1.6,而Ubutnu12.10开始,就使用的是Subversion 1.7. 如果从别人的地方拷过来的SVN目录,在使用SVN命令时会报以 ...

  4. 谈谈php中上传文件的处理

    这是一个表单的时代... 我们在浏览器中编辑自己的信息,会遇到上传头像:在文库中,我们会上传文档......到处存在“上传”这个词. php是最好的语言(其他语言的程序猿们不要打我...).php在处 ...

  5. 2729:[HNOI2012]排队 - BZOJ

    题目描述 Description某中学有n 名男同学,m 名女同学和两名老师要排队参加体检.他们排成一条直线,并且任意两名女同学不能相邻,两名老师也不能相邻,那么一共有多少种排法呢?(注意:任意两个人 ...

  6. C++字符串分割

    //字符串分割函数 std::vector<std::string> split(std::string str,std::string pattern) { std::string::s ...

  7. 用Ant实现Java项目的自动构建和部署(转)

    Ant是一个Apache基金会下的跨平台的构件工具,它可以实现项目的自动构建和部署等功能.在本文中,主要让读者熟悉怎样将Ant应用到Java项目中,让它简化构建和部署操作. 一.            ...

  8. 【WCF--初入江湖】06 WCF契约服务行为和异常处理

    06 WCF契约服务行为和异常处理 一.WCF契约服务行为 [1] 服务行为可以修改和控制WCF服务的运行特性. 在实现了WCF服务契约后,可以修改服务的很多执行特性. 这些行为(或者特性)是通过配置 ...

  9. uva 12086 树状数组

    树状数组 #include <cstdio> #include <cstdlib> #include <cmath> #include <map> #i ...

  10. Python Requests模块讲解4

    高级用法 会话对象 请求与响应对象 Prepared Requests SSL证书验证 响应体内容工作流 保持活动状态(持久连接) 流式上传 块编码请求 POST Multiple Multipart ...