/*******************************************************************//**
Creates a space memory object and puts it to the tablespace memory cache. If
there is an error, prints an error message to the .err log.
@return    TRUE if success */
UNIV_INTERN
ibool
fil_space_create(
/*=============*/
    const char*    name,    /*!< in: space name */
    ulint        id,    /*!< in: space id */
    ulint        flags,    /*!< in: compressed page size
                and file format, or 0 */
    ulint        purpose)/*!< in: FIL_TABLESPACE, or FIL_LOG if log */
{
    fil_space_t*    space;

    /* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for
    ROW_FORMAT=COMPACT
    ((table->flags & ~(~0 << DICT_TF_BITS)) == DICT_TF_COMPACT) and
    ROW_FORMAT=REDUNDANT (table->flags == 0).  For any other
    format, the tablespace flags should equal
    (table->flags & ~(~0 << DICT_TF_BITS)). */
    ut_a(flags != DICT_TF_COMPACT);
    ut_a(!(flags & (~0UL << DICT_TF_BITS)));

try_again:
    /*printf(
    "InnoDB: Adding tablespace %lu of name %s, purpose %lu\n", id, name,
    purpose);*/

    ut_a(fil_system);
    ut_a(name);

    mutex_enter(&fil_system->mutex);

    space = fil_space_get_by_name(name);

    if (UNIV_LIKELY_NULL(space)) {
      goto try_again;
    }

    space = fil_space_get_by_id(id);

    if (UNIV_LIKELY_NULL(space)) {     return(FALSE);
    }
        /**     *结构体详见     */
    space = mem_alloc(sizeof(fil_space_t));

    space->name = mem_strdup(name);
    space->id = id;

    fil_system->tablespace_version++;
    space->tablespace_version = fil_system->tablespace_version;
    space->mark = FALSE;

    if (UNIV_LIKELY(purpose == FIL_TABLESPACE && !recv_recovery_on)
        && UNIV_UNLIKELY(id > fil_system->max_assigned_id)) {
        if (!fil_system->space_id_reuse_warned) {

        }

        fil_system->max_assigned_id = id;
    }

    space->stop_ios = FALSE;
    space->stop_new_ops = FALSE;
    space->purpose = purpose;
    space->size = ;
    space->flags = flags;

    space->n_reserved_extents = ;

    space->n_pending_flushes = ;
    space->n_pending_ops = ;
    //初始化chain链表
    UT_LIST_INIT(space->chain);
    space->magic_n = FIL_SPACE_MAGIC_N;

    rw_lock_create(fil_space_latch_key, &space->latch, SYNC_FSP);
        //分别以id和name作为哈希值,放入fil_system相应哈希表中
    HASH_INSERT(fil_space_t, hash, fil_system->spaces, id, space);

    HASH_INSERT(fil_space_t, name_hash, fil_system->name_hash,ut_fold_string(name), space);
    space->is_in_unflushed_spaces = FALSE;
        //放入lru中
    UT_LIST_ADD_LAST(space_list, fil_system->space_list, space);

    mutex_exit(&fil_system->mutex);

    return(TRUE);
}
/*******************************************************************//**
Returns the table space by a given name, NULL if not found. */
UNIV_INLINE
fil_space_t*
fil_space_get_by_name(
/*==================*/
    const char*    name)    /*!< in: space name */
{
    fil_space_t*    space;
    ulint        fold;

    ut_ad(mutex_own(&fil_system->mutex));

    fold = ut_fold_string(name);

    HASH_SEARCH(name_hash, fil_system->name_hash, fold,
            fil_space_t*, space,
            ut_ad(space->magic_n == FIL_SPACE_MAGIC_N),
            !strcmp(name, space->name));

    return(space);
}

fil_space_create的更多相关文章

  1. fil_system_struct

    /** The tablespace memory cache */ typedef struct fil_system_struct fil_system_t; /** The tablespace ...

  2. Innodb物理存储结构系列1

    本篇先介绍 下Innodb表空间,文件相关的内存数据结构. 1. 数据结构 Innodb的tablespace和文件的关系,是一对多的关系,先来看三个结构体 1. fil_system_struct: ...

  3. InnoDB undo log物理结构的初始化

    水平有限,如果有误请指出.一直以来未对Innodb 的undo进行好好的学习,最近刚好有点时间准备学习一下,通过阿里内核月报和自己看代码的综合总结一下.本文环境: 代码版本 percona 5.7.2 ...

  4. MySQL启动过程详解三:Innodb存储引擎的启动

    Innodb启动过程如下: 1. 初始化innobase_hton,它是一个handlerton类型的指针,以便在server层能够调用存储引擎的接口. 2. Innodb相关参数的检车和初始化,包括 ...

随机推荐

  1. BitmapSource ConvertTo Bitmap

    偶遇需要把 BitmapSource 转成 Bitmap. .. using System; using System.Drawing; using System.Drawing.Imaging; u ...

  2. 生鲜电商的O2O之道

  3. centos 7 有点意思

    Centos 7 防火墙 Centos尼马换了防火墙,名叫firewalld,还有iptables命令,这就叫坑爹.整了半个世纪才知道,他换了防火墙.添加滤镜,停止iptables都打不开80端口,简 ...

  4. KASS分布式文件系统(Kass File System)

    KASS分布式文件系统(Kass File System),简称KFS,是开始公司自主研发的分布式文件存储服务平台.KFS系统架构及功能服务类似Hadoop/GFS/DFS,它通过HTTP-WEB为上 ...

  5. Linux操作系统下软件的安装方法大全

    一.rpm包安装方式步骤: 1.找到相应的软件包,比如soft.version.rpm,下载到本机某个目录: 2.打开一个终端,su -成root用户: 3.cd soft.version.rpm所在 ...

  6. 利用vim阅读源代码一个好用的工具

    阅读源代码时常常遇到找变量,函数定义的问题.vim为我们提供了一个好用的工具,ctags. 安装 ctags. 在 libvirt的源代码根目录运行 ctags -R . vim -t virConn ...

  7. Java Memory Basic

    转自: http://www.blogjava.net/justinchen/archive/2009/justinchen/archive/2009/01/08/248738.html GC and ...

  8. hdoj 1879 继续畅通工程

    继续畅通工程 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

  9. HDU4804 Campus Design 轮廓线dp

    跟上面那篇轮廓线dp是一样的,但是多了两个条件,一个是在原图上可能有些点是不能放的(即障碍),所以转移的时候要多一个判断color[i][j]是不是等于1什么的,另外一个是我们可以有多的1*1的骨牌, ...

  10. php集成开发环境的安装以及Zend Studio开发工具的安装

    一.集成开发环境: wampserver 下载地址: 官网: http://www.wampserver.com/ 直接下载 http://sourceforge.net/projects/wamps ...