函数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++获取时间函数众多,何时该用什么函数,拿到的是什么时间?该怎么用?很多人都会混淆. 本文是本人经历了几款游戏客户端和服务器开发后,对游戏中时间获取的一点总结. 最早学习游戏客户端时,为了获取最精确 ...
随机推荐
- AngularJs学习笔记--expression
原版地址:http://code.angularjs.org/1.0.2/docs/guide/expression 表达式(Expressions)是类Javascript的代码片段,通常放置在绑定 ...
- 驱动笔记 - Makefile
ifneq ($(KERNELRELEASE),) obj-m := hello.ohello-objs := main.o add.o else KDIR := /lib/modules/2.6.1 ...
- swift函数和初始化控件(// MARK:分割线)
import UIKit , , , ) view.backgroundColor = UIColor.redColor() self.view.addSubview( ...
- POJ 1450
#include <iostream> using namespace std; int main() { //freopen("acm.acm","r&qu ...
- VMware 进入bios
在虚拟机创建目录中找到.vmx结尾的文件. 添加bios.forceSetupOnce = "TRUE". 打开虚拟机,他会自动进入bios,随后他会把bios.forceSetu ...
- E文阅读
Lesson 9 A cold welcome 冷遇 What does 'a cold welcome' refer to?On Wednesday evening, we went to the ...
- Tomcat6启用Gzip压缩功能
配置Tomcat根目录下/conf/server.xml文件: <Connector port="8080" protocol="HTTP/1.1" co ...
- JDBC第一次学习
JDBC(Java Data Base Connectivity,java数据库连接),由一些类和接口构成的API,它是J2SE的一部分,由java.sql,javax.sql包组成. 应用程序.J ...
- 以Server模式启动Derby服务竟然抛套接字权限异常
以Server模式启动Derby服务竟然抛套接字权限异常:access denied ("java.net.SocketPermission" "localhost:15 ...
- webmatrix
http://www.microsoft.com/web/webmatrix/ WebMatrix is a free, lightweight, cloud-connected web develo ...