函数fsp_fill_free_list
/**********************************************************************//** Puts new extents to the free list if there are free extents above the free limit. If an extent happens to contain an extent descriptor page, the extent is put to the FSP_FREE_FRAG list with the page marked as used. */ static void fsp_fill_free_list( /*===============*/ ibool init_space, /*!< in: TRUE if this is a single-table tablespace and we are only initing the tablespace's first extent descriptor page and ibuf bitmap page; then we do not allocate more extents */ ulint space, /*!< in: space */ fsp_header_t* header, /*!< in/out: space header */ mtr_t* mtr) /*!< in/out: mini-transaction */ { ulint limit; ulint size; ulint zip_size; xdes_t* descr; ulint count = ; ulint frag_n_used; ulint actual_increase; ulint i; mtr_t ibuf_mtr; ut_ad(header && mtr); ut_ad(page_offset(header) == FSP_HEADER_OFFSET); /* Check if we can fill free list from above the free list limit */ size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr); limit = mtr_read_ulint(header + FSP_FREE_LIMIT, MLOG_4BYTES, mtr); zip_size = dict_table_flags_to_zip_size( mach_read_from_4(FSP_SPACE_FLAGS + header)); ut_a(ut_is_2pow(zip_size)); ut_a(zip_size <= UNIV_PAGE_SIZE); ut_a(!zip_size || zip_size >= PAGE_ZIP_MIN_SIZE); && srv_auto_extend_last_data_file && size < limit + FSP_EXTENT_SIZE * FSP_FREE_ADD) { /* Try to increase the last data file size */ fsp_try_extend_data_file(&actual_increase, space, header, mtr); size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr); } && !init_space && size < limit + FSP_EXTENT_SIZE * FSP_FREE_ADD) { /* Try to increase the .ibd file size */ fsp_try_extend_data_file(&actual_increase, space, header, mtr); size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr); } i = limit; /** *还是先暂时分配4个page * *#define FSP_FREE_ADD 4 *#define FSP_EXTENT_SIZE 64 *init_space 为false,所以第一个条件不执行 *fsp_init_file_page初始化后,limit为0 *while( (0+64 < size)&& 0<4){ init_xdes = (0%16328)=0 count=1 } while( (16328<size) &&1<4 ){ init_xdes=16328%16328=0 count=2 } .. while(65312<size && 3<4) init_xdex=65312%16328=0 count=4 } 结束while循环 最终header + FSP_FREE_LIMIT 为 65312+64 */
) || ((i + FSP_EXTENT_SIZE <= size) && (count < FSP_FREE_ADD))) { ibool init_xdes; if (zip_size) { init_xdes = ut_2pow_remainder(i, zip_size) == ; } else { init_xdes = ut_2pow_remainder(i, UNIV_PAGE_SIZE) == ; } mlog_write_ulint(header + FSP_FREE_LIMIT, i + FSP_EXTENT_SIZE,MLOG_4BYTES, mtr); /* Update the free limit info in the log system and make a checkpoint */ ) { ut_a(!zip_size); log_fsp_current_free_limit_set_and_checkpoint( (i + FSP_EXTENT_SIZE) / (( * ) / UNIV_PAGE_SIZE)); } if (UNIV_UNLIKELY(init_xdes)) { buf_block_t* block; /* We are going to initialize a new descriptor page and a new ibuf bitmap page: the prior contents of the pages should be ignored. */ ) { /** *从free-list,unzip-lru,common-lru取出block *初始化block */ block = buf_page_create(space, i, zip_size, mtr);//详见 buf_page_get(space, zip_size, i,RW_X_LATCH, mtr); buf_block_dbg_add_level(block,SYNC_FSP_PAGE); //初始化blck一些属性 fsp_init_file_page(block, mtr); mlog_write_ulint(buf_block_get_frame(block)+ FIL_PAGE_TYPE,FIL_PAGE_TYPE_XDES,MLOG_2BYTES, mtr); } /* Initialize the ibuf bitmap page in a separate mini-transaction because it is low in the latching order, and we must be able to release its latch before returning from the fsp routine */ mtr_start(&ibuf_mtr); block = buf_page_create(space, i + FSP_IBUF_BITMAP_OFFSET, zip_size, &ibuf_mtr); buf_page_get(space, zip_size, i + FSP_IBUF_BITMAP_OFFSET, RW_X_LATCH, &ibuf_mtr); buf_block_dbg_add_level(block, SYNC_FSP_PAGE); fsp_init_file_page(block, &ibuf_mtr); ibuf_bitmap_page_init(block, &ibuf_mtr); mtr_commit(&ibuf_mtr); } /** *1)根据偏移量i,计算出des page的page_no * 1.1)如果page_no非0,则要根据offset在buf_pool->page_hash找到一个block,条件为page->offset == i * 1.2)如果page_no为0,继续 *2)在xdes page中定位哪xdes entry的起始地址 */ descr = xdes_get_descriptor_with_space_hdr(header, space, i,mtr);//详见 xdes_init(descr, mtr); if (UNIV_UNLIKELY(init_xdes)) { /* The first page in the extent is a descriptor page and the second is an ibuf bitmap page: mark them used */ xdes_set_bit(descr, XDES_FREE_BIT, , FALSE, mtr); xdes_set_bit(descr, XDES_FREE_BIT, FSP_IBUF_BITMAP_OFFSET, FALSE, mtr); xdes_set_state(descr, XDES_FREE_FRAG, mtr); flst_add_last(header + FSP_FREE_FRAG,descr + XDES_FLST_NODE, mtr); frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED,MLOG_4BYTES, mtr); mlog_write_ulint(header + FSP_FRAG_N_USED,frag_n_used + , MLOG_4BYTES, mtr); } else { flst_add_last(header + FSP_FREE,descr + XDES_FLST_NODE, mtr); count++; } i += FSP_EXTENT_SIZE; } }
函数fsp_fill_free_list的更多相关文章
- Python 小而美的函数
python提供了一些有趣且实用的函数,如any all zip,这些函数能够大幅简化我们得代码,可以更优雅的处理可迭代的对象,同时使用的时候也得注意一些情况 any any(iterable) ...
- 探究javascript对象和数组的异同,及函数变量缓存技巧
javascript中最经典也最受非议的一句话就是:javascript中一切皆是对象.这篇重点要提到的,就是任何jser都不陌生的Object和Array. 有段时间曾经很诧异,到底两种数据类型用来 ...
- JavaScript权威指南 - 函数
函数本身就是一段JavaScript代码,定义一次但可能被调用任意次.如果函数挂载在一个对象上,作为对象的一个属性,通常这种函数被称作对象的方法.用于初始化一个新创建的对象的函数被称作构造函数. 相对 ...
- C++对C的函数拓展
一,内联函数 1.内联函数的概念 C++中的const常量可以用来代替宏常数的定义,例如:用const int a = 10来替换# define a 10.那么C++中是否有什么解决方案来替代宏代码 ...
- 菜鸟Python学习笔记第一天:关于一些函数库的使用
2017年1月3日 星期二 大一学习一门新的计算机语言真的很难,有时候连函数拼写出错查错都能查半天,没办法,谁让我英语太渣. 关于计算机语言的学习我想还是从C语言学习开始为好,Python有很多语言的 ...
- javascript中的this与函数讲解
前言 javascript中没有块级作用域(es6以前),javascript中作用域分为函数作用域和全局作用域.并且,大家可以认为全局作用域其实就是Window函数的函数作用域,我们编写的js代码, ...
- 复杂的 Hash 函数组合有意义吗?
很久以前看到一篇文章,讲某个大网站储存用户口令时,会经过十分复杂的处理.怎么个复杂记不得了,大概就是先 Hash,结果加上一些特殊字符再 Hash,结果再加上些字符.再倒序.再怎么怎么的.再 Hash ...
- JS核心系列:浅谈函数的作用域
一.作用域(scope) 所谓作用域就是:变量在声明它们的函数体以及这个函数体嵌套的任意函数体内都是有定义的. function scope(){ var foo = "global&quo ...
- C++中的时间函数
C++获取时间函数众多,何时该用什么函数,拿到的是什么时间?该怎么用?很多人都会混淆. 本文是本人经历了几款游戏客户端和服务器开发后,对游戏中时间获取的一点总结. 最早学习游戏客户端时,为了获取最精确 ...
随机推荐
- HDU 1028Ignatius and the Princess III(母函数简单题)
Ignatius and the Princess III Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- ObjectStore onFetch方法获取记录总数
转自:http://blog.csdn.net/earthhour/article/details/38686029 ObjectStore onFetch方法获取记录总数 require(['doj ...
- c++中的原子操作
1. c/c++标准中没有定义任何操作符为原子的,操作符是否原子和平台及编译器版本有关 2. GCC提供了一组内建的原子操作,这些操作是以函数的形式提供的,这些函数不需要引用任何头文件 2.1 对变量 ...
- NodeJS异常处理uncaughtException篇
很多 NodeJS 的开发者在抱怨异常处理太麻烦,我们会通过一些列博客梳理一下NodeJS中常见的异常处理的手段. 和大多数编程语言一样,在 NodeJS 里可以通过throw抛出一个异常: thro ...
- iOS工程预编译文件的创建
在搜索 添加工程名/自己的pch文件名记住加后缀
- 深入浅出ES6(十二):代理 Proxies
作者 Jason Orendorff github主页 https://github.com/jorendorff 请看这样一段代码: var obj = new Proxy({}, { get: ...
- m_pMainWnd(转载)
今天写程序时遇到个简单而又很有意思的问题,封装了一个网络接口类,发送数据以及网络的回调接口都在这个类里面,打算在回调函数里给AfxGetMainWnd()发送消息以更新主界面的数据,同时程序有一个登录 ...
- Linux:chmod -R 777 * 是什么意思?
首先,chmod命令是linux上用于改变权限的命令,-R 是递归遍历子目录,因为你要操作的文件使用的*通配符.777,第一个7代表文件所属者的权限,第二个7代表文件所属者所在组的权限,第三个7代表其 ...
- 有N个大小不等的自然数(1--N),请将它们由小到大排序。要求程序算法:时间复杂度为O(n),空间复杂度为O(1)。
#include<stdio.h> int main() { ]={,,,,,,,,}; int i,tmp; ;i<;i++) { ) { tmp=a[i]; a[i]=a[a[i ...
- Linux下面如何安装Django
首先你需要肯定你的机子上装了Python 现在ubuntu已经自带,所以不必操心 当然你可以在你的机子下测试一下,只需在 terminal 下输入 python 如果出现下面的界面就说明你机子已经装了 ...