函数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++获取时间函数众多,何时该用什么函数,拿到的是什么时间?该怎么用?很多人都会混淆. 本文是本人经历了几款游戏客户端和服务器开发后,对游戏中时间获取的一点总结. 最早学习游戏客户端时,为了获取最精确 ...
随机推荐
- NGUI 笔记
1.动态加载Atlas,并用NGUITools添加Sprite UIAtlas MyAtlas = Resources.Load("MyAtlas", typeof(UIAtlas ...
- VSS
A deleted file of the same name already exists in this VSS project. Do you want to recover the delet ...
- JavaScript之match()方法讲解
定义和用法 match() 方法可在字符串内检索指定的值,或找到一个或多个正则表达式的匹配. 该方法类似 indexOf() 和 lastIndexOf(),但是它返回指定的值,而不是字符串的位置. ...
- 帝国cms数据还原后提示数据库表不存在怎么解决?
下午,ytkah用帝国cms在wamp调试时发现了一个问题,还原备份好的数据后更新的页面提示数据库表不存在,查看了phpmyadmin分类的数据库表实际上是存在的,这个是怎么回事呢?重新搭建一个新站点 ...
- eclipse luna使用jdk1.8初始化
1.安装jdk版本1.8 2.配置环境变量 D:\Program Files\Java\jdk1.8.0_11 (如果从jdk7更改为jdk8,修改JAVA_HOME变量就可以了.)JAVA_HOME ...
- Sqli-labs less 53
Less-53 和less51是一样的,只是这里的mysql错误不会在前台显示,但是对于stacked injection是一样的利用方式 http://127.0.0.1/sqli-labs/Les ...
- Static、final、abstract、接口、构造方法及java语法总结
Static:定义类的时候一般不用static来修饰,在一定意义上,用static修饰的字段可以作为全局变量,static修饰的字段和方法存储在类的内存区域,所有实例共享.static字段和方法都是属 ...
- Android图片缩放方法
安卓开发中应用到图片的处理时候,我们通常会怎么缩放操作呢,来看下面的两种做法: 方法1:按固定比例进行缩放 在开发一些软件,如新闻客户端,很多时候要显示图片的缩略图,由于手机屏幕限制,一般情况下,我们 ...
- Windows 代码实现关机(直接黑屏)
整理资料的时候发现的以前的代码,本机Win7 x64 Sp1 运行直接关机,黑屏.就是利用RtlAdjustPrivilege函数提权,代码中的注释写的很详细了.用的VS2010写的,直接编译成x64 ...
- linux下top命令查看cpu占用情况
可以通过 top 命令来查看 CPU 使用状况.运行 top 命令后,CPU 使用状态会以全屏的方式显示,并且会处在对话的模式 -- 用基于 top 的命令,可以控制显示方式等等.退出 top 的命令 ...