2009-02-17 09:06:49 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
|
|
|
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**************************************************//**
|
|
|
|
@file include/fsp0fsp.h
|
2005-10-27 07:29:40 +00:00
|
|
|
File space management
|
|
|
|
|
|
|
|
Created 12/18/1995 Heikki Tuuri
|
|
|
|
*******************************************************/
|
|
|
|
|
|
|
|
#ifndef fsp0fsp_h
|
|
|
|
#define fsp0fsp_h
|
|
|
|
|
|
|
|
#include "univ.i"
|
|
|
|
|
|
|
|
#include "mtr0mtr.h"
|
|
|
|
#include "fut0lst.h"
|
|
|
|
#include "ut0byte.h"
|
|
|
|
#include "page0types.h"
|
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/** If records are inserted in order, there are the following
|
2005-10-27 07:29:40 +00:00
|
|
|
flags to tell this (their type is made byte for the compiler
|
|
|
|
to warn if direction and hint parameters are switched in
|
|
|
|
fseg_alloc_free_page): */
|
2009-05-26 12:28:49 +00:00
|
|
|
/* @{ */
|
|
|
|
#define FSP_UP ((byte)111) /*!< alphabetically upwards */
|
|
|
|
#define FSP_DOWN ((byte)112) /*!< alphabetically downwards */
|
|
|
|
#define FSP_NO_DIR ((byte)113) /*!< no order */
|
|
|
|
/* @} */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/** File space extent size (one megabyte) in pages */
|
2007-12-20 22:09:22 +00:00
|
|
|
#define FSP_EXTENT_SIZE (1 << (20 - UNIV_PAGE_SIZE_SHIFT))
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/** On a page of any file segment, data may be put starting from this
|
|
|
|
offset */
|
2005-10-27 07:29:40 +00:00
|
|
|
#define FSEG_PAGE_DATA FIL_PAGE_DATA
|
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
/** File segment header which points to the inode describing the file
|
|
|
|
segment */
|
|
|
|
/* @{ */
|
|
|
|
/** Data type for file segment header */
|
2005-10-27 07:29:40 +00:00
|
|
|
typedef byte fseg_header_t;
|
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
#define FSEG_HDR_SPACE 0 /*!< space id of the inode */
|
|
|
|
#define FSEG_HDR_PAGE_NO 4 /*!< page number of the inode */
|
|
|
|
#define FSEG_HDR_OFFSET 8 /*!< byte offset of the inode */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-26 12:28:49 +00:00
|
|
|
#define FSEG_HEADER_SIZE 10 /*!< Length of the file system
|
|
|
|
header, in bytes */
|
|
|
|
/* @} */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Initializes the file space system. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
fsp_init(void);
|
|
|
|
/*==========*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2008-03-05 12:40:29 +00:00
|
|
|
Gets the current free limit of the system tablespace. The free limit
|
|
|
|
means the place of the first page which has never been put to the the
|
|
|
|
free list for allocation. The space above that address is initialized
|
2009-05-25 05:30:14 +00:00
|
|
|
to zero. Sets also the global variable log_fsp_current_free_limit.
|
|
|
|
@return free limit in megabytes */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
2008-03-05 12:40:29 +00:00
|
|
|
fsp_header_get_free_limit(void);
|
|
|
|
/*===========================*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2008-03-05 12:40:29 +00:00
|
|
|
Gets the size of the system tablespace from the tablespace header. If
|
|
|
|
we do not have an auto-extending data file, this should be equal to
|
|
|
|
the size of the data files. If there is an auto-extending data file,
|
2009-05-25 05:30:14 +00:00
|
|
|
this can be smaller.
|
|
|
|
@return size in pages */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
2008-03-05 12:40:29 +00:00
|
|
|
fsp_header_get_tablespace_size(void);
|
|
|
|
/*================================*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Reads the file space size stored in the header page.
|
|
|
|
@return tablespace size stored in the space header */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
fsp_get_size_low(
|
|
|
|
/*=============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
page_t* page); /*!< in: header page (page 0 in the tablespace) */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Reads the space id from the first page of a tablespace.
|
|
|
|
@return space id, ULINT UNDEFINED if error */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
fsp_header_get_space_id(
|
|
|
|
/*====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const page_t* page); /*!< in: first page of a tablespace */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Reads the space flags from the first page of a tablespace.
|
|
|
|
@return flags */
|
branches/zip: Implement the configuration parameter and settable global
variable innodb_file_format. Implement file format version stamping of
*.ibd files and SYS_TABLES.TYPE.
This change breaks introduces an incompatible change for for
compressed tables. We can do this, as we have not released yet.
innodb-zip.test: Add tests for stricter KEY_BLOCK_SIZE and ROW_FORMAT
checks.
DICT_TF_COMPRESSED_MASK, DICT_TF_COMPRESSED_SHIFT: Replace with
DICT_TF_ZSSIZE_MASK, DICT_TF_ZSSIZE_SHIFT.
DICT_TF_FORMAT_MASK, DICT_TF_FORMAT_SHIFT, DICT_TF_FORMAT_51,
DICT_TF_FORMAT_ZIP: File format version, stored in table->flags,
in the .ibd file header, and in SYS_TABLES.TYPE.
dict_create_sys_tables_tuple(): Write the table flags to SYS_TABLES.TYPE
if the format is at least DICT_TF_FORMAT_ZIP. For old formats
(DICT_TF_FORMAT_51), write DICT_TABLE_ORDINARY as the table type.
DB_TABLE_ZIP_NO_IBD: Remove the error code. The error handling is done
in ha_innodb.cc; as a failsafe measure, dict_build_table_def_step() will
silently clear the compression and format flags instead of returning this
error.
dict_mem_table_create(): Assert that no extra bits are set in the flags.
dict_sys_tables_get_zip_size(): Rename to dict_sys_tables_get_flags().
Check all flag bits, and return ULINT_UNDEFINED if the combination is
unsupported.
dict_boot(): Document the SYS_TABLES columns N_COLS and TYPE.
dict_table_get_format(), dict_table_set_format(),
dict_table_flags_to_zip_size(): New accessors to table->flags.
dtuple_convert_big_rec(): Introduce the auxiliary variables
local_len, local_prefix_len. Store a 768-byte prefix locally
if the file format is less than DICT_TF_FORMAT_ZIP.
dtuple_convert_back_big_rec(): Restore the columns.
srv_file_format: New variable: innodb_file_format.
fil_create_new_single_table_tablespace(): Replace the parameter zip_size
with table->flags.
fil_open_single_table_tablespace(): Replace the parameter zip_size_in_k
with table->flags. Check the flags.
fil_space_struct, fil_space_create(), fil_op_write_log():
Replace zip_size with flags.
fil_node_open_file(): Note a TODO item for InnoDB Hot Backup.
Check that the tablespace flags match.
fil_space_get_zip_size(): Rename to fil_space_get_flags(). Add a
wrapper for fil_space_get_zip_size().
fsp_header_get_flags(): New function.
fsp_header_init_fields(): Replace zip_size with flags.
FSP_SPACE_FLAGS: New name for the tablespace flags. This field used
to be called FSP_PAGE_ZIP_SIZE, or FSP_LOWEST_NO_WRITE. It has always
been written as 0 in MySQL/InnoDB versions 4.1 to 5.1.
MLOG_ZIP_FILE_CREATE: Rename to MLOG_FILE_CREATE2. Add a 32-bit
parameter for the tablespace flags.
ha_innobase::create(): Check the table attributes ROW_FORMAT and
KEY_BLOCK_SIZE. Issue errors if they are inappropriate, or warnings
if the inherited attributes (in ALTER TABLE) will be ignored.
PAGE_ZIP_MIN_SIZE_SHIFT: New constant: the 2-logarithm of PAGE_ZIP_MIN_SIZE.
2008-03-10 11:05:32 +00:00
|
|
|
UNIV_INTERN
|
|
|
|
ulint
|
|
|
|
fsp_header_get_flags(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const page_t* page); /*!< in: first page of a tablespace */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Reads the compressed page size from the first page of a tablespace.
|
|
|
|
@return compressed page size in bytes, or 0 if uncompressed */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-04-25 07:12:32 +00:00
|
|
|
ulint
|
|
|
|
fsp_header_get_zip_size(
|
2007-01-18 09:59:00 +00:00
|
|
|
/*====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const page_t* page); /*!< in: first page of a tablespace */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2006-06-14 06:29:41 +00:00
|
|
|
Writes the space id and compressed page size to a tablespace header.
|
|
|
|
This function is used past the buffer pool when we in fil0fil.c create
|
|
|
|
a new single-table tablespace. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
2006-06-14 06:29:41 +00:00
|
|
|
fsp_header_init_fields(
|
|
|
|
/*===================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
page_t* page, /*!< in/out: first page in the space */
|
|
|
|
ulint space_id, /*!< in: space id */
|
|
|
|
ulint flags); /*!< in: tablespace flags (FSP_SPACE_FLAGS):
|
2008-03-18 10:10:51 +00:00
|
|
|
0, or table->flags if newer than COMPACT */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Initializes the space header of a new created space and creates also the
|
|
|
|
insert buffer tree root if space == 0. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
fsp_header_init(
|
|
|
|
/*============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint size, /*!< in: current size in blocks */
|
|
|
|
mtr_t* mtr); /*!< in: mini-transaction handle */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Increases the space size field of a space. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
fsp_header_inc_size(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint size_inc,/*!< in: size increment in pages */
|
|
|
|
mtr_t* mtr); /*!< in: mini-transaction handle */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Creates a new segment.
|
2009-05-25 08:09:45 +00:00
|
|
|
@return the block where the segment header is placed, x-latched, NULL
|
|
|
|
if could not create segment because of lack of space */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
fseg_create(
|
|
|
|
/*========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint page, /*!< in: page where the segment header is placed: if
|
2005-10-27 07:29:40 +00:00
|
|
|
this is != 0, the page must belong to another segment,
|
|
|
|
if this is 0, a new page will be allocated and it
|
|
|
|
will belong to the created segment */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint byte_offset, /*!< in: byte offset of the created segment header
|
2005-10-27 07:29:40 +00:00
|
|
|
on the page */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr); /*!< in: mtr */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Creates a new segment.
|
2009-05-25 08:09:45 +00:00
|
|
|
@return the block where the segment header is placed, x-latched, NULL
|
|
|
|
if could not create segment because of lack of space */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t*
|
2005-10-27 07:29:40 +00:00
|
|
|
fseg_create_general(
|
|
|
|
/*================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint page, /*!< in: page where the segment header is placed: if
|
2005-10-27 07:29:40 +00:00
|
|
|
this is != 0, the page must belong to another segment,
|
|
|
|
if this is 0, a new page will be allocated and it
|
|
|
|
will belong to the created segment */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint byte_offset, /*!< in: byte offset of the created segment header
|
2005-10-27 07:29:40 +00:00
|
|
|
on the page */
|
2009-05-25 05:30:14 +00:00
|
|
|
ibool has_done_reservation, /*!< in: TRUE if the caller has already
|
2005-10-27 07:29:40 +00:00
|
|
|
done the reservation for the pages with
|
|
|
|
fsp_reserve_free_extents (at least 2 extents: one for
|
|
|
|
the inode and the other for the segment) then there is
|
|
|
|
no need to do the check for this individual
|
|
|
|
operation */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr); /*!< in: mtr */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Calculates the number of pages reserved by a segment, and how many pages are
|
2009-05-25 05:30:14 +00:00
|
|
|
currently used.
|
|
|
|
@return number of reserved pages */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
fseg_n_reserved_pages(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* header, /*!< in: segment header */
|
|
|
|
ulint* used, /*!< out: number of pages used (<= reserved) */
|
|
|
|
mtr_t* mtr); /*!< in: mtr handle */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Allocates a single free page from a segment. This function implements
|
|
|
|
the intelligent allocation strategy which tries to minimize
|
2009-05-25 05:30:14 +00:00
|
|
|
file space fragmentation.
|
|
|
|
@return the allocated page offset FIL_NULL if no page could be allocated */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
fseg_alloc_free_page(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* seg_header, /*!< in: segment header */
|
|
|
|
ulint hint, /*!< in: hint of which page would be desirable */
|
|
|
|
byte direction, /*!< in: if the new page is needed because
|
2005-10-27 07:29:40 +00:00
|
|
|
of an index page split, and records are
|
|
|
|
inserted there in order, into which
|
|
|
|
direction they go alphabetically: FSP_DOWN,
|
|
|
|
FSP_UP, FSP_NO_DIR */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr); /*!< in: mtr handle */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Allocates a single free page from a segment. This function implements
|
|
|
|
the intelligent allocation strategy which tries to minimize file space
|
2009-05-25 05:30:14 +00:00
|
|
|
fragmentation.
|
|
|
|
@return allocated page offset, FIL_NULL if no page could be allocated */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
fseg_alloc_free_page_general(
|
|
|
|
/*=========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* seg_header,/*!< in: segment header */
|
|
|
|
ulint hint, /*!< in: hint of which page would be desirable */
|
|
|
|
byte direction,/*!< in: if the new page is needed because
|
2005-10-27 07:29:40 +00:00
|
|
|
of an index page split, and records are
|
|
|
|
inserted there in order, into which
|
|
|
|
direction they go alphabetically: FSP_DOWN,
|
|
|
|
FSP_UP, FSP_NO_DIR */
|
2009-05-25 05:30:14 +00:00
|
|
|
ibool has_done_reservation, /*!< in: TRUE if the caller has
|
2005-10-27 07:29:40 +00:00
|
|
|
already done the reservation for the page
|
|
|
|
with fsp_reserve_free_extents, then there
|
|
|
|
is no need to do the check for this individual
|
|
|
|
page */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr); /*!< in: mtr handle */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Reserves free pages from a tablespace. All mini-transactions which may
|
|
|
|
use several pages from the tablespace should call this function beforehand
|
|
|
|
and reserve enough free extents so that they certainly will be able
|
|
|
|
to do their operation, like a B-tree page split, fully. Reservations
|
|
|
|
must be released with function fil_space_release_free_extents!
|
|
|
|
|
|
|
|
The alloc_type below has the following meaning: FSP_NORMAL means an
|
|
|
|
operation which will probably result in more space usage, like an
|
|
|
|
insert in a B-tree; FSP_UNDO means allocation to undo logs: if we are
|
|
|
|
deleting rows, then this allocation will in the long run result in
|
|
|
|
less space usage (after a purge); FSP_CLEANING means allocation done
|
|
|
|
in a physical record delete (like in a purge) or other cleaning operation
|
|
|
|
which will result in less space usage in the long run. We prefer the latter
|
|
|
|
two types of allocation: when space is scarce, FSP_NORMAL allocations
|
|
|
|
will not succeed, but the latter two allocations will succeed, if possible.
|
|
|
|
The purpose is to avoid dead end where the database is full but the
|
|
|
|
user cannot free any space because these freeing operations temporarily
|
|
|
|
reserve some space.
|
|
|
|
|
|
|
|
Single-table tablespaces whose size is < 32 pages are a special case. In this
|
|
|
|
function we would liberally reserve several 64 page extents for every page
|
|
|
|
split or merge in a B-tree. But we do not want to waste disk space if the table
|
|
|
|
only occupies < 32 pages. That is why we apply different rules in that special
|
2009-05-25 05:30:14 +00:00
|
|
|
case, just ensuring that there are 3 free pages available.
|
|
|
|
@return TRUE if we were able to make the reservation */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
fsp_reserve_free_extents(
|
|
|
|
/*=====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint* n_reserved,/*!< out: number of extents actually reserved; if we
|
2006-02-23 19:25:29 +00:00
|
|
|
return TRUE and the tablespace size is < 64 pages,
|
|
|
|
then this can be 0, otherwise it is n_ext */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint n_ext, /*!< in: number of extents to reserve */
|
|
|
|
ulint alloc_type,/*!< in: FSP_NORMAL, FSP_UNDO, or FSP_CLEANING */
|
|
|
|
mtr_t* mtr); /*!< in: mtr */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
This function should be used to get information on how much we still
|
|
|
|
will be able to insert new data to the database without running out the
|
|
|
|
tablespace. Only free extents are taken into account and we also subtract
|
2009-05-25 05:30:14 +00:00
|
|
|
the safety margin required by the above function fsp_reserve_free_extents.
|
|
|
|
@return available space in kB */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2007-08-01 11:18:43 +00:00
|
|
|
ullint
|
2005-10-27 07:29:40 +00:00
|
|
|
fsp_get_available_space_in_free_extents(
|
|
|
|
/*====================================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space); /*!< in: space id */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Frees a single page of a segment. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
fseg_free_page(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* seg_header, /*!< in: segment header */
|
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint page, /*!< in: page offset */
|
|
|
|
mtr_t* mtr); /*!< in: mtr handle */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Frees a segment. The freeing is performed in several mini-transactions,
|
|
|
|
so that there is no danger of bufferfixing too many buffer pages. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
fseg_free(
|
|
|
|
/*======*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes
|
2007-01-18 09:59:00 +00:00
|
|
|
or 0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint page_no,/*!< in: page number where the segment header is
|
2005-10-27 07:29:40 +00:00
|
|
|
placed */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint offset);/*!< in: byte offset of the segment header on that
|
2005-10-27 07:29:40 +00:00
|
|
|
page */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Frees part of a segment. This function can be used to free a segment
|
|
|
|
by repeatedly calling this function in different mini-transactions.
|
|
|
|
Doing the freeing in a single mini-transaction might result in
|
2009-05-25 05:30:14 +00:00
|
|
|
too big a mini-transaction.
|
|
|
|
@return TRUE if freeing completed */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
fseg_free_step(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* header, /*!< in, own: segment header; NOTE: if the header
|
2005-10-27 07:29:40 +00:00
|
|
|
resides on the first page of the frag list
|
|
|
|
of the segment, this pointer becomes obsolete
|
|
|
|
after the last freeing step */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr); /*!< in: mtr */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Frees part of a segment. Differs from fseg_free_step because this function
|
2009-05-25 05:30:14 +00:00
|
|
|
leaves the header page unfreed.
|
|
|
|
@return TRUE if freeing completed, except the header page */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
fseg_free_step_not_header(
|
|
|
|
/*======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* header, /*!< in: segment header which must reside on
|
2005-10-27 07:29:40 +00:00
|
|
|
the first fragment page of the segment */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr); /*!< in: mtr */
|
2009-05-25 09:52:29 +00:00
|
|
|
/***********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Checks if a page address is an extent descriptor page address.
|
|
|
|
@return TRUE if a descriptor page */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
fsp_descr_page(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes;
|
2006-06-06 07:42:04 +00:00
|
|
|
0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint page_no);/*!< in: page number */
|
2009-05-25 09:52:29 +00:00
|
|
|
/***********************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Parses a redo log record of a file page init.
|
|
|
|
@return end of log record or NULL */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
byte*
|
|
|
|
fsp_parse_init_file_page(
|
|
|
|
/*=====================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
byte* ptr, /*!< in: buffer */
|
|
|
|
byte* end_ptr, /*!< in: buffer end */
|
|
|
|
buf_block_t* block); /*!< in: block or NULL */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Validates the file space system and its segments.
|
|
|
|
@return TRUE if ok */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
fsp_validate(
|
|
|
|
/*=========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space); /*!< in: space id */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Prints info of a file space. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
fsp_print(
|
|
|
|
/*======*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space); /*!< in: space id */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Validates a segment.
|
|
|
|
@return TRUE if ok */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
fseg_validate(
|
|
|
|
/*==========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* header, /*!< in: segment header */
|
|
|
|
mtr_t* mtr2); /*!< in: mtr */
|
2008-03-06 12:29:16 +00:00
|
|
|
#ifdef UNIV_BTR_PRINT
|
2009-05-25 09:52:29 +00:00
|
|
|
/*******************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Writes info of a segment. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
fseg_print(
|
|
|
|
/*=======*/
|
2009-05-25 05:30:14 +00:00
|
|
|
fseg_header_t* header, /*!< in: segment header */
|
|
|
|
mtr_t* mtr); /*!< in: mtr */
|
2008-03-06 12:29:16 +00:00
|
|
|
#endif /* UNIV_BTR_PRINT */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Flags for fsp_reserve_free_extents */
|
|
|
|
#define FSP_NORMAL 1000000
|
|
|
|
#define FSP_UNDO 2000000
|
|
|
|
#define FSP_CLEANING 3000000
|
|
|
|
|
|
|
|
/* Number of pages described in a single descriptor page: currently each page
|
|
|
|
description takes less than 1 byte; a descriptor page is repeated every
|
|
|
|
this many file pages */
|
2006-06-07 10:41:58 +00:00
|
|
|
/* #define XDES_DESCRIBED_PER_PAGE UNIV_PAGE_SIZE */
|
|
|
|
/* This has been replaced with either UNIV_PAGE_SIZE or page_zip->size. */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-05-08 06:18:59 +00:00
|
|
|
/* The space low address page map */
|
2005-10-27 07:29:40 +00:00
|
|
|
/*--------------------------------------*/
|
2006-05-08 06:18:59 +00:00
|
|
|
/* The following two pages are repeated
|
|
|
|
every XDES_DESCRIBED_PER_PAGE pages in
|
|
|
|
every tablespace. */
|
|
|
|
#define FSP_XDES_OFFSET 0 /* extent descriptor */
|
|
|
|
#define FSP_IBUF_BITMAP_OFFSET 1 /* insert buffer bitmap */
|
2005-10-27 07:29:40 +00:00
|
|
|
/* The ibuf bitmap pages are the ones whose
|
|
|
|
page number is the number above plus a
|
|
|
|
multiple of XDES_DESCRIBED_PER_PAGE */
|
2006-05-08 06:18:59 +00:00
|
|
|
|
|
|
|
#define FSP_FIRST_INODE_PAGE_NO 2 /* in every tablespace */
|
|
|
|
/* The following pages exist
|
|
|
|
in the system tablespace (space 0). */
|
|
|
|
#define FSP_IBUF_HEADER_PAGE_NO 3 /* in tablespace 0 */
|
|
|
|
#define FSP_IBUF_TREE_ROOT_PAGE_NO 4 /* in tablespace 0 */
|
2005-10-27 07:29:40 +00:00
|
|
|
/* The ibuf tree root page number in
|
|
|
|
tablespace 0; its fseg inode is on the page
|
|
|
|
number FSP_FIRST_INODE_PAGE_NO */
|
2006-05-08 06:18:59 +00:00
|
|
|
#define FSP_TRX_SYS_PAGE_NO 5 /* in tablespace 0 */
|
|
|
|
#define FSP_FIRST_RSEG_PAGE_NO 6 /* in tablespace 0 */
|
|
|
|
#define FSP_DICT_HDR_PAGE_NO 7 /* in tablespace 0 */
|
2005-10-27 07:29:40 +00:00
|
|
|
/*--------------------------------------*/
|
|
|
|
|
|
|
|
#ifndef UNIV_NONINL
|
|
|
|
#include "fsp0fsp.ic"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|