InnoDB Plugin  1.0
Macros | Typedefs | Functions
fsp0fsp.h File Reference
#include "univ.i"
#include "mtr0mtr.h"
#include "fut0lst.h"
#include "ut0byte.h"
#include "page0types.h"
#include "fsp0types.h"
#include "fsp0fsp.ic"
Include dependency graph for fsp0fsp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FSP_FLAGS_WIDTH_POST_ANTELOPE   1
#define FSP_FLAGS_WIDTH_ZIP_SSIZE   4
#define FSP_FLAGS_WIDTH_ATOMIC_BLOBS   1
#define FSP_FLAGS_WIDTH_PAGE_SSIZE   4
#define FSP_FLAGS_WIDTH_DATA_DIR   1
#define FSP_FLAGS_WIDTH
#define FSP_FLAGS_MASK   (~(~0 << FSP_FLAGS_WIDTH))
#define FSP_FLAGS_POS_POST_ANTELOPE   0
#define FSP_FLAGS_POS_ZIP_SSIZE
#define FSP_FLAGS_POS_ATOMIC_BLOBS
#define FSP_FLAGS_POS_PAGE_SSIZE
#define FSP_FLAGS_POS_DATA_DIR
#define FSP_FLAGS_POS_UNUSED
#define FSP_FLAGS_MASK_POST_ANTELOPE
#define FSP_FLAGS_MASK_ZIP_SSIZE
#define FSP_FLAGS_MASK_ATOMIC_BLOBS
#define FSP_FLAGS_MASK_PAGE_SSIZE
#define FSP_FLAGS_MASK_DATA_DIR
#define FSP_FLAGS_GET_POST_ANTELOPE(flags)
#define FSP_FLAGS_GET_ZIP_SSIZE(flags)
#define FSP_FLAGS_HAS_ATOMIC_BLOBS(flags)
#define FSP_FLAGS_GET_PAGE_SSIZE(flags)
#define FSP_FLAGS_HAS_DATA_DIR(flags)
#define FSP_FLAGS_GET_UNUSED(flags)   (flags >> FSP_FLAGS_POS_UNUSED)
#define FSP_FLAGS_SET_PAGE_SSIZE(flags, ssize)   (flags | (ssize << FSP_FLAGS_POS_PAGE_SSIZE))
#define FSP_HEADER_OFFSET   FIL_PAGE_DATA
#define FSP_SPACE_ID   0 /* space id */
#define FSP_NOT_USED
#define FSP_SIZE
#define FSP_FREE_LIMIT
#define FSP_SPACE_FLAGS
#define FSP_FRAG_N_USED
#define FSP_FREE   24 /* list of free extents */
#define FSP_FREE_FRAG   (24 + FLST_BASE_NODE_SIZE)
#define FSP_FULL_FRAG   (24 + 2 * FLST_BASE_NODE_SIZE)
#define FSP_SEG_ID   (24 + 3 * FLST_BASE_NODE_SIZE)
#define FSP_SEG_INODES_FULL   (32 + 3 * FLST_BASE_NODE_SIZE)
#define FSP_SEG_INODES_FREE   (32 + 4 * FLST_BASE_NODE_SIZE)
#define FSP_HEADER_SIZE   (32 + 5 * FLST_BASE_NODE_SIZE)
#define FSP_FREE_ADD
#define FSEG_INODE_PAGE_NODE   FSEG_PAGE_DATA
#define FSEG_ARR_OFFSET   (FSEG_PAGE_DATA + FLST_NODE_SIZE)
#define FSEG_ID
#define FSEG_NOT_FULL_N_USED   8
#define FSEG_FREE   12
#define FSEG_NOT_FULL   (12 + FLST_BASE_NODE_SIZE)
#define FSEG_FULL   (12 + 2 * FLST_BASE_NODE_SIZE)
#define FSEG_MAGIC_N   (12 + 3 * FLST_BASE_NODE_SIZE)
#define FSEG_FRAG_ARR   (16 + 3 * FLST_BASE_NODE_SIZE)
#define FSEG_FRAG_ARR_N_SLOTS   (FSP_EXTENT_SIZE / 2)
#define FSEG_FRAG_SLOT_SIZE
#define FSEG_INODE_SIZE
#define FSP_SEG_INODES_PER_PAGE(zip_size)
#define FSEG_MAGIC_N_VALUE   97937874
#define FSEG_FILLFACTOR
#define FSEG_FRAG_LIMIT   FSEG_FRAG_ARR_N_SLOTS
#define FSEG_FREE_LIST_LIMIT
#define FSEG_FREE_LIST_MAX_LEN   4
#define XDES_ID
#define XDES_FLST_NODE
#define XDES_STATE   (FLST_NODE_SIZE + 8)
#define XDES_BITMAP   (FLST_NODE_SIZE + 12)
#define XDES_BITS_PER_PAGE   2 /* How many bits are there per page */
#define XDES_FREE_BIT
#define XDES_CLEAN_BIT
#define XDES_FREE   1 /* extent is in free list of space */
#define XDES_FREE_FRAG
#define XDES_FULL_FRAG
#define XDES_FSEG   4 /* extent belongs to a segment */
#define XDES_SIZE
#define XDES_SIZE_MAX
#define XDES_SIZE_MIN
#define XDES_ARR_OFFSET   (FSP_HEADER_OFFSET + FSP_HEADER_SIZE)
#define fseg_alloc_free_page(seg_header, hint, direction, mtr)

Typedefs

typedef byte fsp_header_t
typedef byte xdes_t
typedef byte fseg_inode_t

Functions

UNIV_INTERN void fsp_init (void)
UNIV_INTERN ulint fsp_header_get_tablespace_size (void)
UNIV_INTERN ulint fsp_get_size_low (page_t *page)
UNIV_INTERN ulint fsp_header_get_space_id (const page_t *page)
UNIV_INTERN ulint fsp_header_get_flags (const page_t *page)
UNIV_INTERN ulint fsp_header_get_zip_size (const page_t *page)
UNIV_INTERN void fsp_header_init_fields (page_t *page, ulint space_id, ulint flags)
UNIV_INTERN void fsp_header_init (ulint space, ulint size, mtr_t *mtr)
UNIV_INTERN void fsp_header_inc_size (ulint space, ulint size_inc, mtr_t *mtr)
UNIV_INTERN buf_block_tfseg_create (ulint space, ulint page, ulint byte_offset, mtr_t *mtr)
UNIV_INTERN buf_block_tfseg_create_general (ulint space, ulint page, ulint byte_offset, ibool has_done_reservation, mtr_t *mtr)
UNIV_INTERN ulint fseg_n_reserved_pages (fseg_header_t *header, ulint *used, mtr_t *mtr)
UNIV_INTERN buf_block_tfseg_alloc_free_page_general (fseg_header_t *seg_header, ulint hint, byte direction, ibool has_done_reservation, mtr_t *mtr, mtr_t *init_mtr))
UNIV_INTERN ibool fsp_reserve_free_extents (ulint *n_reserved, ulint space, ulint n_ext, ulint alloc_type, mtr_t *mtr)
UNIV_INTERN ullint fsp_get_available_space_in_free_extents (ulint space)
UNIV_INTERN void fseg_free_page (fseg_header_t *seg_header, ulint space, ulint page, mtr_t *mtr)
UNIV_INTERN bool fseg_page_is_free (fseg_header_t *seg_header, ulint space, ulint page))
UNIV_INTERN ibool fseg_free_step (fseg_header_t *header, mtr_t *mtr)
UNIV_INTERN ibool fseg_free_step_not_header (fseg_header_t *header, mtr_t *mtr)
UNIV_INLINE ibool fsp_descr_page (ulint zip_size, ulint page_no)
UNIV_INTERN byte * fsp_parse_init_file_page (byte *ptr, byte *end_ptr, buf_block_t *block)
UNIV_INTERN ibool fsp_validate (ulint space)
UNIV_INTERN void fsp_print (ulint space)
UNIV_INTERN ibool fseg_validate (fseg_header_t *header, mtr_t *mtr)
UNIV_INLINE bool fsp_flags_is_valid (ulint flags))
UNIV_INLINE ibool fsp_flags_is_compressed (ulint flags)
UNIV_INLINE ulint xdes_calc_descriptor_index (ulint zip_size, ulint offset)
UNIV_INLINE ibool xdes_get_bit (const xdes_t *descr, ulint bit, ulint offset)
UNIV_INLINE ulint xdes_calc_descriptor_page (ulint zip_size, ulint offset)
UNIV_INLINE ulint fsp_flags_get_zip_size (ulint flags)
UNIV_INLINE ulint fsp_flags_get_page_size (ulint flags)

Detailed Description

File space management

Created 12/18/1995 Heikki Tuuri

Macro Definition Documentation

#define fseg_alloc_free_page (   seg_header,
  hint,
  direction,
  mtr 
)
Value:
fseg_alloc_free_page_general(seg_header, hint, direction, \
FALSE, mtr, mtr)

Allocates a single free page from a segment. This function implements the intelligent allocation strategy which tries to minimize file space fragmentation.

Parameters
in/out]seg_header segment header
[in]hinthint of which page would be desirable
[in]directionif the new page is needed because 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
in/out]mtr mini-transaction
Returns
X-latched block, or NULL if no page could be allocated
#define FSEG_FILLFACTOR
Value:
8 /* If this value is x, then if
the number of unused but reserved
pages in a segment is less than
reserved pages * 1/x, and there are
at least FSEG_FRAG_LIMIT used pages,
then we allow a new empty extent to
be added to the segment in
fseg_alloc_free_page. Otherwise, we
use unused pages of the segment. */
#define FSEG_FRAG_SLOT_SIZE
Value:
4 /* a fragment page slot contains its
page number within space, FIL_NULL
means that the slot is not in use */
#define FSEG_FREE_LIST_LIMIT
Value:
40 /* If the reserved size of a segment
is at least this many extents, we
allow extents to be put to the free
list of the extent: at most
FSEG_FREE_LIST_MAX_LEN many */
#define FSEG_ID
Value:
0 /* 8 bytes of segment id: if this is 0,
it means that the header is unused */
#define FSEG_INODE_SIZE
Value:
(16 + 3 * FLST_BASE_NODE_SIZE \
+ FSEG_FRAG_ARR_N_SLOTS * FSEG_FRAG_SLOT_SIZE)
#define FSP_FLAGS_GET_PAGE_SSIZE (   flags)
Value:

Return the value of the PAGE_SSIZE field

#define FSP_FLAGS_GET_POST_ANTELOPE (   flags)
Value:

Return the value of the POST_ANTELOPE field

#define FSP_FLAGS_GET_UNUSED (   flags)    (flags >> FSP_FLAGS_POS_UNUSED)

Return the contents of the UNUSED bits

#define FSP_FLAGS_GET_ZIP_SSIZE (   flags)
Value:

Return the value of the ZIP_SSIZE field

#define FSP_FLAGS_HAS_ATOMIC_BLOBS (   flags)
Value:

Return the value of the ATOMIC_BLOBS field

#define FSP_FLAGS_HAS_DATA_DIR (   flags)
Value:

Return the value of the DATA_DIR field

#define FSP_FLAGS_MASK   (~(~0 << FSP_FLAGS_WIDTH))

A mask of all the known/used bits in tablespace flags

#define FSP_FLAGS_MASK_ATOMIC_BLOBS
Value:

Bit mask of the ATOMIC_BLOBS field

#define FSP_FLAGS_MASK_DATA_DIR
Value:

Bit mask of the DATA_DIR field

#define FSP_FLAGS_MASK_PAGE_SSIZE
Value:

Bit mask of the PAGE_SSIZE field

#define FSP_FLAGS_MASK_POST_ANTELOPE
Value:

Bit mask of the POST_ANTELOPE field

#define FSP_FLAGS_MASK_ZIP_SSIZE
Value:

Bit mask of the ZIP_SSIZE field

#define FSP_FLAGS_POS_ATOMIC_BLOBS
Value:

Zero relative shift position of the ATOMIC_BLOBS field

#define FSP_FLAGS_POS_DATA_DIR
Value:

Zero relative shift position of the start of the UNUSED bits

#define FSP_FLAGS_POS_PAGE_SSIZE
Value:

Zero relative shift position of the PAGE_SSIZE field

#define FSP_FLAGS_POS_POST_ANTELOPE   0

Zero relative shift position of the POST_ANTELOPE field

#define FSP_FLAGS_POS_UNUSED
Value:

Zero relative shift position of the start of the UNUSED bits

#define FSP_FLAGS_POS_ZIP_SSIZE
Value:

Zero relative shift position of the ZIP_SSIZE field

#define FSP_FLAGS_SET_PAGE_SSIZE (   flags,
  ssize 
)    (flags | (ssize << FSP_FLAGS_POS_PAGE_SSIZE))
Set a PAGE_SSIZE into the correct bits in a given

tablespace flags.

#define FSP_FLAGS_WIDTH
#define FSP_FLAGS_WIDTH_ATOMIC_BLOBS   1
Width of the ATOMIC_BLOBS flag.  The ability to break up a long

column into an in-record prefix and an externally stored part is available to the two Barracuda row formats COMPRESSED and DYNAMIC.

#define FSP_FLAGS_WIDTH_DATA_DIR   1
Width of the DATA_DIR flag.  This flag indicates that the tablespace

is found in a remote location, not the default data directory.

#define FSP_FLAGS_WIDTH_PAGE_SSIZE   4

Number of flag bits used to indicate the tablespace page size

#define FSP_FLAGS_WIDTH_POST_ANTELOPE   1

Width of the POST_ANTELOPE flag

#define FSP_FLAGS_WIDTH_ZIP_SSIZE   4

Number of flag bits used to indicate the tablespace zip page size

#define FSP_FRAG_N_USED
Value:
20 /* number of used pages in the
FSP_FREE_FRAG list */
#define FSP_FREE_ADD
Value:
4 /* this many free extents are added
to the free list from above
FSP_FREE_LIMIT at a time */
#define FSP_FREE_LIMIT
Value:
12 /* Minimum page number for which the
free list has not been initialized:
the pages >= this limit are, by
definition, free; note that in a
single-table tablespace where size
< 64 pages, this number is 64, i.e.,
we have initialized the space
about the first extent, but have not
physically allocted those pages to the
file */
#define FSP_HEADER_OFFSET   FIL_PAGE_DATA

Offset of the space header within a file page

#define FSP_NOT_USED
Value:
4 /* this field contained a value up to
which we know that the modifications
in the database have been flushed to
the file space; not used now */
#define FSP_SEG_INODES_PER_PAGE (   zip_size)
Value:
(((zip_size ? zip_size : UNIV_PAGE_SIZE) \
- FSEG_ARR_OFFSET - 10) / FSEG_INODE_SIZE)
#define FSP_SIZE
Value:
8 /* Current size of the space in
pages */
#define FSP_SPACE_FLAGS
Value:
16 /* fsp_space_t.flags, similar to
dict_table_t::flags */
#define XDES_ARR_OFFSET   (FSP_HEADER_OFFSET + FSP_HEADER_SIZE)

Offset of the descriptor array on a descriptor page

#define XDES_CLEAN_BIT
Value:
1 /* NOTE: currently not used!
Index of the bit which tells if
there are old versions of tuples
on the page */
#define XDES_FLST_NODE
Value:
8 /* The list node data structure
for the descriptors */
#define XDES_FREE_BIT
Value:
0 /* Index of the bit which tells if
the page is free */
#define XDES_FREE_FRAG
Value:
2 /* extent is in free fragment list of
space */
#define XDES_FULL_FRAG
Value:
3 /* extent is in full fragment list of
space */
#define XDES_ID
Value:
0 /* The identifier of the segment
to which this extent belongs */
#define XDES_SIZE
Value:
(XDES_BITMAP \
+ UT_BITS_IN_BYTES(FSP_EXTENT_SIZE * XDES_BITS_PER_PAGE))

File extent data structure size in bytes.

#define XDES_SIZE_MAX
Value:
(XDES_BITMAP \
+ UT_BITS_IN_BYTES(FSP_EXTENT_SIZE_MAX * XDES_BITS_PER_PAGE))

File extent data structure size in bytes for MAX page size.

#define XDES_SIZE_MIN
Value:
(XDES_BITMAP \
+ UT_BITS_IN_BYTES(FSP_EXTENT_SIZE_MIN * XDES_BITS_PER_PAGE))

File extent data structure size in bytes for MIN page size.

Function Documentation

UNIV_INTERN buf_block_t* fseg_alloc_free_page_general ( fseg_header_t *  seg_header,
ulint  hint,
byte  direction,
ibool  has_done_reservation,
mtr_t mtr,
mtr_t init_mtr 
)

Allocates a single free page from a segment. This function implements the intelligent allocation strategy which tries to minimize file space fragmentation.

Return values
NULLif no page could be allocated
block,rw_lock_x_lock_count(&block->lock)== 1 if allocation succeeded (init_mtr == mtr, or the page was not previously freed in mtr)
block(not allocated or initialized) otherwise
Parameters
seg_headerin/out: segment header
hintin: hint of which page would be desirable
directionin: if the new page is needed because 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
has_done_reservationin: TRUE if the caller has 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
mtrin/out: mini-transaction
init_mtrin/out: mtr or another mini-transaction in which the page should be initialized. If init_mtr!=mtr, but the page is already latched in mtr, do not initialize the page.
UNIV_INTERN buf_block_t* fseg_create ( ulint  space,
ulint  page,
ulint  byte_offset,
mtr_t mtr 
)

Creates a new segment.

Returns
the block where the segment header is placed, x-latched, NULL if could not create segment because of lack of space in/out: mini-transaction
Parameters
spacein: space id
pagein: page where the segment header is placed: if 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
byte_offsetin: byte offset of the created segment header on the page
UNIV_INTERN buf_block_t* fseg_create_general ( ulint  space,
ulint  page,
ulint  byte_offset,
ibool  has_done_reservation,
mtr_t mtr 
)

Creates a new segment.

Returns
the block where the segment header is placed, x-latched, NULL if could not create segment because of lack of space in/out: mini-transaction
Parameters
spacein: space id
pagein: page where the segment header is placed: if 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
byte_offsetin: byte offset of the created segment header on the page
has_done_reservationin: TRUE if the caller has already 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
UNIV_INTERN void fseg_free_page ( fseg_header_t *  seg_header,
ulint  space,
ulint  page,
mtr_t mtr 
)

Frees a single page of a segment. in/out: mini-transaction

Parameters
seg_headerin: segment header
spacein: space id
pagein: page offset
UNIV_INTERN ibool fseg_free_step ( fseg_header_t *  header,
mtr_t mtr 
)

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 too big a mini-transaction.

Returns
TRUE if freeing completed in/out: mini-transaction
Parameters
headerin, own: segment header; NOTE: if the header resides on the first page of the frag list of the segment, this pointer becomes obsolete after the last freeing step
UNIV_INTERN ibool fseg_free_step_not_header ( fseg_header_t *  header,
mtr_t mtr 
)

Frees part of a segment. Differs from fseg_free_step because this function leaves the header page unfreed.

Returns
TRUE if freeing completed, except the header page in/out: mini-transaction
Parameters
headerin: segment header which must reside on the first fragment page of the segment
UNIV_INTERN ulint fseg_n_reserved_pages ( fseg_header_t *  header,
ulint *  used,
mtr_t mtr 
)

Calculates the number of pages reserved by a segment, and how many pages are currently used.

Returns
number of reserved pages in/out: mini-transaction
Parameters
headerin: segment header
usedout: number of pages used (<= reserved)
UNIV_INTERN bool fseg_page_is_free ( fseg_header_t *  seg_header,
ulint  space,
ulint  page 
)

Checks if a single page of a segment is free.

Returns
true if free
Parameters
seg_headerin: segment header
spacein: space id
pagein: page offset
UNIV_INTERN ibool fseg_validate ( fseg_header_t *  header,
mtr_t mtr 
)

Validates a segment.

Returns
TRUE if ok in/out: mini-transaction
Parameters
headerin: segment header
UNIV_INLINE ibool fsp_descr_page ( ulint  zip_size,
ulint  page_no 
)

Checks if a page address is an extent descriptor page address.

Returns
TRUE if a descriptor page in: page number

Checks if a page address is an extent descriptor page address.

Returns
TRUE if a descriptor page
Parameters
zip_sizein: compressed page size in bytes; 0 for uncompressed pages
page_noin: page number
UNIV_INLINE ulint fsp_flags_get_page_size ( ulint  flags)

Extract the page size from tablespace flags.

Returns
page size of the tablespace in bytes in: tablespace flags

Extract the page size from tablespace flags.

Returns
page size of the tablespace in bytes
Parameters
flagsin: tablespace flags
UNIV_INLINE ulint fsp_flags_get_zip_size ( ulint  flags)

Extract the zip size from tablespace flags. A tablespace has only one physical page size whether that page is compressed or not.

Returns
compressed page size of the file-per-table tablespace in bytes, or zero if the table is not compressed. in: tablespace flags

Extract the zip size from tablespace flags.

Returns
compressed page size of the file-per-table tablespace in bytes, or zero if the table is not compressed.
Parameters
flagsin: tablespace flags
UNIV_INLINE ibool fsp_flags_is_compressed ( ulint  flags)

Determine if the tablespace is compressed from dict_table_t::flags.

Returns
TRUE if compressed, FALSE if not compressed in: tablespace flags

Determine if the tablespace is compressed from dict_table_t::flags.

Returns
TRUE if compressed, FALSE if not compressed
Parameters
flagsin: tablespace flags
UNIV_INLINE bool fsp_flags_is_valid ( ulint  flags)

Validate and return the tablespace flags, which are stored in the tablespace header at offset FSP_SPACE_FLAGS. They should be 0 for ROW_FORMAT=COMPACT and ROW_FORMAT=REDUNDANT. The newer row formats, COMPRESSED and DYNAMIC, use a file format > Antelope so they should have a file format number plus the DICT_TF_COMPACT bit set.

Returns
true if check ok
Parameters
flagsin: tablespace flags
UNIV_INTERN ullint fsp_get_available_space_in_free_extents ( ulint  space)

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 the safety margin required by the above function fsp_reserve_free_extents.

Returns
available space in kB in: space id
UNIV_INTERN ulint fsp_get_size_low ( page_t page)

Reads the file space size stored in the header page.

Returns
tablespace size stored in the space header in: header page (page 0 in the tablespace)
UNIV_INTERN ulint fsp_header_get_flags ( const page_t page)

Reads the space flags from the first page of a tablespace.

Returns
flags in: first page of a tablespace
UNIV_INTERN ulint fsp_header_get_space_id ( const page_t page)

Reads the space id from the first page of a tablespace.

Returns
space id, ULINT UNDEFINED if error in: first page of a tablespace
UNIV_INTERN ulint fsp_header_get_tablespace_size ( void  )

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, this can be smaller.

Returns
size in pages
UNIV_INTERN ulint fsp_header_get_zip_size ( const page_t page)

Reads the compressed page size from the first page of a tablespace.

Returns
compressed page size in bytes, or 0 if uncompressed in: first page of a tablespace
UNIV_INTERN void fsp_header_inc_size ( ulint  space,
ulint  size_inc,
mtr_t mtr 
)

Increases the space size field of a space. in/out: mini-transaction

Parameters
spacein: space id
size_incin: size increment in pages
UNIV_INTERN void fsp_header_init ( ulint  space,
ulint  size,
mtr_t mtr 
)

Initializes the space header of a new created space and creates also the insert buffer tree root if space == 0. in/out: mini-transaction

Parameters
spacein: space id
sizein: current size in blocks
UNIV_INTERN void fsp_header_init_fields ( page_t page,
ulint  space_id,
ulint  flags 
)

Writes the space id and flags to a tablespace header. The flags contain row type, physical/compressed page size, and logical/uncompressed page size of the tablespace. in: tablespace flags (FSP_SPACE_FLAGS): 0, or table->flags if newer than COMPACT

Parameters
pagein/out: first page in the space
space_idin: space id
UNIV_INTERN void fsp_init ( void  )

Initializes the file space system.

UNIV_INTERN byte* fsp_parse_init_file_page ( byte *  ptr,
byte *  end_ptr,
buf_block_t block 
)

Parses a redo log record of a file page init.

Returns
end of log record or NULL in: block or NULL
Parameters
ptrin: buffer
end_ptrin: buffer end
UNIV_INTERN void fsp_print ( ulint  space)

Prints info of a file space. in: space id

UNIV_INTERN ibool fsp_reserve_free_extents ( ulint *  n_reserved,
ulint  space,
ulint  n_ext,
ulint  alloc_type,
mtr_t mtr 
)

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 case, just ensuring that there are 3 free pages available.

Returns
TRUE if we were able to make the reservation in: mini-transaction
Parameters
n_reservedout: number of extents actually reserved; if we return TRUE and the tablespace size is < 64 pages, then this can be 0, otherwise it is n_ext
spacein: space id
n_extin: number of extents to reserve
alloc_typein: FSP_NORMAL, FSP_UNDO, or FSP_CLEANING
UNIV_INTERN ibool fsp_validate ( ulint  space)

Validates the file space system and its segments.

Returns
TRUE if ok in: space id
UNIV_INLINE ulint xdes_calc_descriptor_index ( ulint  zip_size,
ulint  offset 
)

Calculates the descriptor index within a descriptor page.

Returns
descriptor index in: page offset

Calculates the descriptor index within a descriptor page.

Returns
descriptor index
Parameters
zip_sizein: compressed page size in bytes; 0 for uncompressed pages
offsetin: page offset
UNIV_INLINE ulint xdes_calc_descriptor_page ( ulint  zip_size,
ulint  offset 
)

Calculates the page where the descriptor of a page resides.

Returns
descriptor page offset in: page offset

Calculates the page where the descriptor of a page resides.

Returns
descriptor page offset
Parameters
zip_sizein: compressed page size in bytes; 0 for uncompressed pages
offsetin: page offset
UNIV_INLINE ibool xdes_get_bit ( const xdes_t *  descr,
ulint  bit,
ulint  offset 
)

Gets a descriptor bit of a page.

Returns
TRUE if free in: page offset within extent: 0 ... FSP_EXTENT_SIZE - 1

Gets a descriptor bit of a page.

Returns
TRUE if free
Parameters
descrin: descriptor
bitin: XDES_FREE_BIT or XDES_CLEAN_BIT
offsetin: page offset within extent: 0 ... FSP_EXTENT_SIZE - 1