MySQL 8.0.39
Source Code Documentation
|
File space management. More...
#include "univ.i"
#include "fsp0space.h"
#include "fut0lst.h"
#include "mtr0mtr.h"
#include "mysql/components/services/bits/mysql_cond_bits.h"
#include "mysql/components/services/bits/mysql_mutex_bits.h"
#include "page0types.h"
#include "rem0types.h"
#include "ut0byte.h"
#include <random>
#include "fsp0types.h"
#include "fsp0fsp.ic"
Go to the source code of this file.
Classes | |
struct | xdes_mem_t |
struct | fsp_header_mem_t |
In-memory representation of the fsp_header_t file structure. More... | |
class | File_segment_inode |
A wrapper class to operate on a file segment inode pointer (fseg_inode_t*) More... | |
Macros | |
#define | FSEG_FRAG_ARR_N_SLOTS (FSP_EXTENT_SIZE / 2) |
#define | FSEG_INODE_SIZE (16 + 3 * FLST_BASE_NODE_SIZE + FSEG_FRAG_ARR_N_SLOTS * FSEG_FRAG_SLOT_SIZE) |
#define | FSEG_FRAG_LIMIT FSEG_FRAG_ARR_N_SLOTS |
#define | XDES_SIZE (XDES_BITMAP + UT_BITS_IN_BYTES(FSP_EXTENT_SIZE * XDES_BITS_PER_PAGE)) |
File extent data structure size in bytes. More... | |
#define | XDES_SIZE_MAX (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. More... | |
#define | XDES_SIZE_MIN (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. More... | |
Typedefs | |
typedef byte | fsp_header_t |
typedef byte | xdes_t |
typedef byte | fseg_inode_t |
Enumerations | |
enum | xdes_state_t { XDES_NOT_INITED = 0 , XDES_FREE = 1 , XDES_FREE_FRAG = 2 , XDES_FULL_FRAG = 3 , XDES_FSEG = 4 , XDES_FSEG_FRAG = 5 } |
States of a descriptor. More... | |
Functions | |
bool | xdes_state_is_valid (ulint state) |
Check if the state of extent descriptor is valid. More... | |
std::ostream & | operator<< (std::ostream &out, const xdes_mem_t &obj) |
std::ostream & | operator<< (std::ostream &out, const fsp_header_mem_t &obj) |
static uint32_t | FSP_SEG_INODES_PER_PAGE (page_size_t page_size) |
void | fsp_init (void) |
Initializes the file space system. More... | |
page_no_t | fsp_header_get_tablespace_size (void) |
Gets the size of the system tablespace from the tablespace header. More... | |
page_no_t | fsp_get_pages_to_extend_ibd (const page_size_t &page_size, page_no_t size) |
Calculate the number of pages to extend a datafile. More... | |
static page_no_t | fsp_get_extent_size_in_pages (const page_size_t &page_size) |
Calculate the number of physical pages in an extent for this file. More... | |
space_id_t | fsp_header_get_space_id (const page_t *page) |
Reads the space id from the first page of a tablespace. More... | |
bool | fsp_header_dict_get_server_version (uint *version) |
Read the server version number from the DD tablespace header. More... | |
uint32_t | fsp_header_get_field (const page_t *page, uint32_t field) |
Read a tablespace header field. More... | |
void | fsp_header_set_field (page_t *page, uint32_t field, uint32_t val) |
Update a tablespace header field. More... | |
uint32_t | fsp_header_get_flags (const page_t *page) |
Read the flags from the tablespace header page. More... | |
page_size_t | fsp_header_get_page_size (const page_t *page) |
Reads the page size from the first page of a tablespace. More... | |
bool | fsp_header_get_encryption_key (uint32_t fsp_flags, Encryption_key &e_key, page_t *page) |
Reads the encryption key from the first page of a tablespace. More... | |
Encryption::Progress | fsp_header_encryption_op_type_in_progress (const page_t *page, page_size_t page_size) |
Get encryption operation type in progress from the first page of a tablespace. More... | |
bool | fsp_check_tablespace_size (space_id_t space_id) |
Check if the tablespace size information is valid. More... | |
void | fsp_header_init_fields (page_t *page, space_id_t space_id, uint32_t flags) |
Writes the space id and flags to a tablespace header. More... | |
ulint | fsp_header_get_encryption_offset (const page_size_t &page_size) |
Get the offset of encryption information in page 0. More... | |
bool | fsp_header_write_encryption (space_id_t space_id, uint32_t space_flags, byte *encrypt_info, bool update_fsp_flags, bool rotate_encryption, mtr_t *mtr) |
Write the encryption info into the space header. More... | |
bool | fsp_header_write_encryption_progress (space_id_t space_id, ulint space_flags, ulint progress_info, byte operation_type, bool update_operation_type, mtr_t *mtr) |
Write the encryption progress info into the space header. More... | |
bool | fsp_header_rotate_encryption (fil_space_t *space, byte *encrypt_info, mtr_t *mtr) |
Rotate the encryption info in the space header. More... | |
bool | fsp_header_init (space_id_t space_id, page_no_t size, mtr_t *mtr) |
Initializes the space header of a new created space and creates also the insert buffer tree root if space == 0. More... | |
void | fsp_header_inc_size (space_id_t space_id, page_no_t size_inc, mtr_t *mtr) |
Increases the space size field of a space. More... | |
buf_block_t * | fseg_create (space_id_t space, page_no_t page, ulint byte_offset, mtr_t *mtr) |
Creates a new segment. More... | |
buf_block_t * | fseg_create_general (space_id_t space_id, page_no_t page, ulint byte_offset, bool has_done_reservation, mtr_t *mtr) |
Creates a new segment. More... | |
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. More... | |
buf_block_t * | fseg_alloc_free_page_general (fseg_header_t *seg_header, page_no_t hint, byte direction, bool has_done_reservation, mtr_t *mtr, mtr_t *init_mtr) |
Allocates a single free page from a segment. More... | |
static buf_block_t * | fseg_alloc_free_page (fseg_header_t *seg_header, page_no_t hint, byte direction, mtr_t *mtr) |
Allocates a single free page from a segment. More... | |
bool | fsp_reserve_free_extents (ulint *n_reserved, space_id_t space_id, ulint n_ext, fsp_reserve_t alloc_type, mtr_t *mtr, page_no_t n_pages=2) |
Reserves free pages from a tablespace. More... | |
uintmax_t | fsp_get_available_space_in_free_extents (space_id_t space_id) |
Calculate how many KiB of new data we will be able to insert to the tablespace without running out of space. More... | |
uintmax_t | fsp_get_available_space_in_free_extents (const fil_space_t *space) |
Calculate how many KiB of new data we will be able to insert to the tablespace without running out of space. More... | |
void | fseg_free_page (fseg_header_t *seg_header, space_id_t space_id, page_no_t page, bool ahi, mtr_t *mtr) |
Frees a single page of a segment. More... | |
bool | fseg_page_is_free (fseg_header_t *seg_header, space_id_t space_id, page_no_t page) |
Checks if a single page of a segment is free. More... | |
bool | fseg_free_step (fseg_header_t *header, bool ahi, mtr_t *mtr) |
Frees part of a segment. More... | |
bool | fseg_free_step_not_header (fseg_header_t *header, bool ahi, mtr_t *mtr) |
Frees part of a segment. More... | |
static bool | fsp_descr_page (const page_id_t &page_id, const page_size_t &page_size) |
Checks if a page address is an extent descriptor page address. More... | |
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. More... | |
bool | fsp_is_undo_tablespace (space_id_t space_id) |
Check whether a space id is an undo tablespace ID Undo tablespaces have space_id's starting 1 less than the redo logs. More... | |
static bool | fsp_is_system_tablespace (space_id_t space_id) |
static bool | fsp_is_system_or_temp_tablespace (space_id_t space_id) |
Check if the space_id is for a system-tablespace (shared + temp). More... | |
static bool | fsp_is_ibd_tablespace (space_id_t space_id) |
Determine if the space ID is an IBD tablespace, either file_per_table or a general shared tablespace, where user tables exist. More... | |
static bool | fsp_is_file_per_table (space_id_t space_id, uint32_t fsp_flags) |
Check if tablespace is file-per-table. More... | |
bool | fsp_is_dd_tablespace (space_id_t space_id) |
Check if tablespace is dd tablespace. More... | |
static bool | fsp_flags_is_compressed (uint32_t flags) |
Determine if the tablespace is compressed from tablespace flags. More... | |
static bool | fsp_flags_are_equal (uint32_t flags1, uint32_t flags2) |
Determine if two tablespaces are equivalent or compatible. More... | |
static uint32_t | fsp_flags_init (const page_size_t &page_size, bool atomic_blobs, bool has_data_dir, bool is_shared, bool is_temporary, bool is_encrypted=false) |
Initialize an FSP flags integer. More... | |
uint32_t | fsp_flags_to_dict_tf (uint32_t fsp_flags, bool compact) |
Convert a 32 bit integer tablespace flags to the 32 bit table flags. More... | |
static ulint | xdes_calc_descriptor_index (const page_size_t &page_size, ulint offset) |
Calculates the descriptor index within a descriptor page. More... | |
static bool | xdes_get_bit (const xdes_t *descr, ulint bit, page_no_t offset) |
Gets a descriptor bit of a page. More... | |
static page_no_t | xdes_calc_descriptor_page (const page_size_t &page_size, page_no_t offset) |
Calculates the page where the descriptor of a page resides. More... | |
fsp_header_t * | fsp_get_space_header_block (space_id_t id, const page_size_t &page_size, mtr_t *mtr, buf_block_t **block) |
Gets a pointer to the space header and acquires a SX lock on the page. More... | |
fsp_header_t * | fsp_get_space_header (space_id_t id, const page_size_t &page_size, mtr_t *mtr) |
Gets a pointer to the space header and acquires a SX lock on the page. More... | |
page_no_t | fsp_sdi_get_root_page_num (space_id_t space, const page_size_t &page_size, mtr_t *mtr) |
Retrieve tablespace dictionary index root page number stored in the page 0. More... | |
void | fsp_sdi_write_root_to_page (page_t *page, const page_size_t &page_size, page_no_t root_page_num, mtr_t *mtr) |
Write SDI Index root page num to page 0 of tablespace. More... | |
uint32_t | fsp_header_get_server_version (const page_t *page) |
Reads the server version from the first page of a tablespace. More... | |
uint32_t | fsp_header_get_space_version (const page_t *page) |
Reads the server space version from the first page of a tablespace. More... | |
xdes_state_t | xdes_get_state (const xdes_t *descr, mtr_t *mtr) |
Get the state of an xdes. More... | |
std::ostream & | xdes_page_print (std::ostream &out, const page_t *xdes, page_no_t page_no, mtr_t *mtr) |
Print the extent descriptor page in user-friendly format. More... | |
void | fsp_header_size_update (fsp_header_t *header, ulint size, mtr_t *mtr) |
Update the tablespace size information and generate redo log for it. More... | |
bool | fsp_is_inode_page (page_no_t page) |
Check if a specified page is inode page or not. More... | |
ulint | fsp_header_get_sdi_offset (const page_size_t &page_size) |
Get the offset of SDI root page number in page 0. More... | |
ulint | fsp_header_get_encryption_progress_offset (const page_size_t &page_size) |
Get the offset of encryption progress information in page 0. More... | |
dberr_t | fsp_has_sdi (space_id_t space_id) |
Determine if the tablespace has SDI. More... | |
dberr_t | fsp_alter_encrypt_tablespace (THD *thd, space_id_t space_id, bool to_encrypt, void *dd_space_in) |
Encrypt/Unencrypt a tablespace. More... | |
void | fsp_init_resume_alter_encrypt_tablespace () |
Initiate roll-forward of alter encrypt in background thread. More... | |
std::ostream & | operator<< (std::ostream &out, const File_segment_inode &obj) |
The global output stream operator is overloaded to work with an object of type File_segment_inode. More... | |
fseg_inode_t * | fseg_inode_get (const fseg_header_t *header, space_id_t space, const page_size_t &page_size, mtr_t *mtr, buf_block_t **block=nullptr) |
Returns the file segment inode, page x-latched. More... | |
Variables | |
std::vector< DDL_Record * > | ts_encrypt_ddl_records |
DDL records for tablespace (un)encryption. More... | |
mysql_cond_t | resume_encryption_cond |
mysql_mutex_t | resume_encryption_cond_m |
std::vector< space_id_t > | flag_mismatch_spaces |
constexpr uint32_t | FSP_HEADER_OFFSET = FIL_PAGE_DATA |
Offset of the space header within a file page. More... | |
constexpr uint32_t | FSP_SDI_HEADER_LEN = 8 |
The number of bytes required to store SDI root page number(4) and SDI version(4) at Page 0. More... | |
constexpr uint32_t | FSP_SPACE_ID = 0 |
space id More... | |
constexpr uint32_t | FSP_NOT_USED = 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 More... | |
constexpr uint32_t | FSP_SIZE = 8 |
Current size of the space in pages. More... | |
constexpr uint32_t | FSP_FREE_LIMIT = 12 |
Minimum page number for which the free list has not been initialized: the pages >= this limit are, bydefinition, 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 allocated those pages to thefile. More... | |
constexpr uint32_t | FSP_SPACE_FLAGS = 16 |
fsp_space_t.flags, similar to dict_table_t::flags More... | |
constexpr uint32_t | FSP_FRAG_N_USED = 20 |
number of used pages in the FSP_FREE_FRAG list More... | |
constexpr uint32_t | FSP_FREE = 24 |
list of free extents More... | |
constexpr uint32_t | FSP_FREE_FRAG = 24 + FLST_BASE_NODE_SIZE |
list of partially free extents not belonging to any segment More... | |
constexpr uint32_t | FSP_FULL_FRAG = 24 + 2 * FLST_BASE_NODE_SIZE |
list of full extents not belonging to any segment More... | |
constexpr uint32_t | FSP_SEG_ID = 24 + 3 * FLST_BASE_NODE_SIZE |
8 bytes which give the first unused segment id More... | |
constexpr uint32_t | FSP_SEG_INODES_FULL = 32 + 3 * FLST_BASE_NODE_SIZE |
list of pages containing segment headers, where all the segment inode slots are reserved More... | |
constexpr uint32_t | FSP_SEG_INODES_FREE = 32 + 4 * FLST_BASE_NODE_SIZE |
list of pages containing segment headers, where not all the segment header slots are reserved More... | |
constexpr uint32_t | FSP_HEADER_SIZE = 32 + 5 * FLST_BASE_NODE_SIZE |
constexpr uint32_t | FSP_FREE_ADD = 4 |
This many free extents are added to the free list from above FSP_FREE_LIMIT at a time. More... | |
constexpr uint64_t | FSP_MAX_AUTOEXTEND_SIZE = 4 * 1024 * 1024 * 1024ULL |
constexpr uint32_t | FSEG_INODE_PAGE_NODE = FSEG_PAGE_DATA |
constexpr uint32_t | FSEG_ARR_OFFSET = FSEG_PAGE_DATA + FLST_NODE_SIZE |
constexpr uint32_t | FSEG_ID = 0 |
constexpr uint32_t | FSEG_NOT_FULL_N_USED = 8 |
number of used segment pages in the FSEG_NOT_FULL list More... | |
constexpr uint32_t | FSEG_FREE = 12 |
list of free extents of this segment More... | |
constexpr uint32_t | FSEG_NOT_FULL = 12 + FLST_BASE_NODE_SIZE |
list of partially free extents More... | |
constexpr uint32_t | FSEG_FULL = 12 + 2 * FLST_BASE_NODE_SIZE |
list of full extents More... | |
constexpr uint32_t | FSEG_MAGIC_N = 12 + 3 * FLST_BASE_NODE_SIZE |
magic number used in debugging More... | |
constexpr uint32_t | FSEG_FRAG_ARR = 16 + 3 * FLST_BASE_NODE_SIZE |
array of individual pages belonging to this segment in fsp fragment extent lists More... | |
constexpr uint32_t | FSEG_FRAG_SLOT_SIZE = 4 |
a fragment page slot contains its page number within space, FIL_NULL means that the slot is not in use More... | |
constexpr uint32_t | FSEG_MAGIC_N_VALUE = 97937874 |
double | fseg_reserve_pct |
The segment_reserve_factor is the ratio x/y expressed in percentage, where x is the number of free pages in the segment, and y is the total number of pages in the segment. More... | |
constexpr double | FSEG_RESERVE_PCT_DFLT = 12.50 |
constexpr double | FSEG_RESERVE_PCT_MIN = 0.03 |
constexpr double | FSEG_RESERVE_PCT_MAX = 40.00 |
constexpr uint32_t | FSEG_FREE_LIST_LIMIT = 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. More... | |
constexpr uint32_t | FSEG_FREE_LIST_MAX_LEN = 4 |
constexpr uint32_t | XDES_ID = 0 |
The identifier of the segment to which this extent belongs. More... | |
constexpr uint32_t | XDES_FLST_NODE = 8 |
The list node data structure for the descriptors. More... | |
constexpr uint32_t | XDES_STATE = FLST_NODE_SIZE + 8 |
contains state information of the extent More... | |
constexpr uint32_t | XDES_BITMAP = FLST_NODE_SIZE + 12 |
Descriptor bitmap of the pages in the extent. More... | |
constexpr uint32_t | XDES_BITS_PER_PAGE = 2 |
How many bits are there per page. More... | |
constexpr uint32_t | XDES_FREE_BIT = 0 |
Index of the bit which tells if the page is free. More... | |
constexpr uint32_t | XDES_CLEAN_BIT = 1 |
NOTE: currently not used! Index of the bit which tells if there are old versions of tuples on the page. More... | |
constexpr uint32_t | XDES_ARR_OFFSET = FSP_HEADER_OFFSET + FSP_HEADER_SIZE |
Offset of the descriptor array on a descriptor page. More... | |
const ulint | XDES_FRAG_N_USED = 2 |
The number of reserved pages in a fragment extent. More... | |
File space management.
Created 12/18/1995 Heikki Tuuri
|
inlinestatic |
Allocates a single free page from a segment.
This function implements the intelligent allocation strategy which tries to minimize file space fragmentation.
[in,out] | seg_header | Segment header |
[in] | hint | Hint of which page would be desirable |
[in] | direction | 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 |
[in,out] | mtr | Mini-transaction |
buf_block_t * fseg_alloc_free_page_general | ( | fseg_header_t * | seg_header, |
page_no_t | hint, | ||
byte | direction, | ||
bool | 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.
[in,out] | seg_header | Segment header |
[in] | hint | Hint of which page would be desirable |
[in,out] | direction | 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 |
[in] | has_done_reservation | 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 |
[in,out] | mtr | Mini-transaction |
[in,out] | init_mtr | 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. |
NULL | if 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), returned block is not allocated nor initialized otherwise |
buf_block_t * fseg_create | ( | space_id_t | space, |
page_no_t | page, | ||
ulint | byte_offset, | ||
mtr_t * | mtr | ||
) |
Creates a new segment.
space | in: space id |
page | in: 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_offset | in: byte offset of the created segment header on the page |
mtr | in/out: mini-transaction |
buf_block_t * fseg_create_general | ( | space_id_t | space_id, |
page_no_t | page, | ||
ulint | byte_offset, | ||
bool | has_done_reservation, | ||
mtr_t * | mtr | ||
) |
Creates a new segment.
[in] | space_id | Space id |
[in,out] | page | 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 |
[in] | byte_offset | Byte offset of the created segment header on the page |
[in,out] | has_done_reservation | 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 |
[in,out] | mtr | Mini-transaction |
space_id | in: space id |
page | in: 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_offset | in: byte offset of the created segment header on the page |
has_done_reservation | in: 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 |
mtr | in/out: mini-transaction |
void fseg_free_page | ( | fseg_header_t * | seg_header, |
space_id_t | space_id, | ||
page_no_t | page, | ||
bool | ahi, | ||
mtr_t * | mtr | ||
) |
Frees a single page of a segment.
[in] | seg_header | Segment header |
[in] | space_id | Space id |
[in] | page | Page offset |
[in] | ahi | Whether we may need to drop the adaptive hash index |
[in,out] | mtr | Mini-transaction |
bool fseg_free_step | ( | fseg_header_t * | header, |
bool | ahi, | ||
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.
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.
header | in, 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 |
ahi | in: whether we may need to drop the adaptive hash index |
mtr | in/out: mini-transaction |
bool fseg_free_step_not_header | ( | fseg_header_t * | header, |
bool | ahi, | ||
mtr_t * | mtr | ||
) |
Frees part of a segment.
Differs from fseg_free_step because this function leaves the header page unfreed.
Differs from fseg_free_step because this function leaves the header page unfreed.
header | in: segment header which must reside on the first fragment page of the segment |
ahi | in: whether we may need to drop the adaptive hash index |
mtr | in/out: mini-transaction |
fseg_inode_t * fseg_inode_get | ( | const fseg_header_t * | header, |
space_id_t | space, | ||
const page_size_t & | page_size, | ||
mtr_t * | mtr, | ||
buf_block_t ** | block = nullptr |
||
) |
Returns the file segment inode, page x-latched.
[in] | header | Segment header |
[in] | space | Space id |
[in] | page_size | Page size |
[in,out] | mtr | Mini-transaction |
[out] | block | Inode block |
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.
header | in: segment header |
used | out: number of pages used (<= reserved) |
mtr | in/out: mini-transaction |
bool fseg_page_is_free | ( | fseg_header_t * | seg_header, |
space_id_t | space_id, | ||
page_no_t | page | ||
) |
Checks if a single page of a segment is free.
seg_header | in: segment header |
space_id | in: space id |
page | in: page offset |
dberr_t fsp_alter_encrypt_tablespace | ( | THD * | thd, |
space_id_t | space_id, | ||
bool | to_encrypt, | ||
void * | dd_space_in | ||
) |
Encrypt/Unencrypt a tablespace.
[in] | thd | current thread |
[in] | space_id | Tablespace id |
[in] | to_encrypt | true if to encrypt, false if to decrypt |
[in,out] | dd_space_in | dd tablespace object |
bool fsp_check_tablespace_size | ( | space_id_t | space_id | ) |
Check if the tablespace size information is valid.
[in] | space_id | the tablespace identifier |
|
inlinestatic |
Checks if a page address is an extent descriptor page address.
[in] | page_id | page id |
[in] | page_size | page size |
|
inlinestatic |
Determine if two tablespaces are equivalent or compatible.
[in] | flags1 | First tablespace flags |
[in] | flags2 | Second tablespace flags |
|
inlinestatic |
Initialize an FSP flags integer.
[in] | page_size | page sizes in bytes and compression flag. |
[in] | atomic_blobs | Used by Dynamic and Compressed. |
[in] | has_data_dir | This tablespace is in a remote location. |
[in] | is_shared | This tablespace can be shared by many tables. |
[in] | is_temporary | This tablespace is temporary. |
[in] | is_encrypted | This tablespace is encrypted. |
|
inlinestatic |
Determine if the tablespace is compressed from tablespace flags.
[in] | flags | Tablespace flags |
uint32_t fsp_flags_to_dict_tf | ( | uint32_t | fsp_flags, |
bool | compact | ||
) |
Convert a 32 bit integer tablespace flags to the 32 bit table flags.
This can only be done for a tablespace that was built as a file-per-table tablespace. Note that the fsp_flags cannot show the difference between a Compact and Redundant table, so an extra Compact boolean must be supplied. Low order bit | REDUNDANT | COMPACT | COMPRESSED | DYNAMIC fil_space_t::flags | 0 | 0 | 1 | 1 dict_table_t::flags | 0 | 1 | 1 | 1
[in] | fsp_flags | fil_space_t::flags |
[in] | compact | true if not Redundant row format |
uintmax_t fsp_get_available_space_in_free_extents | ( | const fil_space_t * | space | ) |
Calculate how many KiB of new data we will be able to insert to the tablespace without running out of space.
Start with a space object that has been acquired by the caller who holds it for the calculation,
[in] | space | tablespace object from fil_space_acquire() |
uintmax_t fsp_get_available_space_in_free_extents | ( | space_id_t | space_id | ) |
Calculate how many KiB of new data we will be able to insert to the tablespace without running out of space.
[in] | space_id | tablespace ID |
UINTMAX_MAX | if unknown |
|
inlinestatic |
Calculate the number of physical pages in an extent for this file.
[in] | page_size | page_size of the datafile |
page_no_t fsp_get_pages_to_extend_ibd | ( | const page_size_t & | page_size, |
page_no_t | size | ||
) |
Calculate the number of pages to extend a datafile.
We extend single-table and general tablespaces first one extent at a time, but 4 at a time for bigger tablespaces. It is not enough to extend always by one extent, because we need to add at least one extent to FSP_FREE. A single extent descriptor page will track many extents. And the extent that uses its extent descriptor page is put onto the FSP_FREE_FRAG list. Extents that do not use their extent descriptor page are added to FSP_FREE. The physical page size is used to determine how many extents are tracked on one extent descriptor page. See xdes_calc_descriptor_page().
[in] | page_size | page_size of the datafile |
[in] | size | current number of pages in the datafile |
fsp_header_t * fsp_get_space_header | ( | space_id_t | id, |
const page_size_t & | page_size, | ||
mtr_t * | mtr | ||
) |
Gets a pointer to the space header and acquires a SX lock on the page.
[in] | id | Space id |
[in] | page_size | Page size |
[in,out] | mtr | Mini-transaction |
fsp_header_t * fsp_get_space_header_block | ( | space_id_t | id, |
const page_size_t & | page_size, | ||
mtr_t * | mtr, | ||
buf_block_t ** | block | ||
) |
Gets a pointer to the space header and acquires a SX lock on the page.
[in] | id | Space id |
[in] | page_size | Page size |
[in,out] | mtr | Mini-transaction |
[out] | block | Block |
dberr_t fsp_has_sdi | ( | space_id_t | space_id | ) |
Determine if the tablespace has SDI.
[in] | space_id | Tablespace id |
bool fsp_header_dict_get_server_version | ( | uint * | version | ) |
Read the server version number from the DD tablespace header.
[out] | version | server version from tablespace header |
Encryption::Progress fsp_header_encryption_op_type_in_progress | ( | const page_t * | page, |
page_size_t | page_size | ||
) |
Get encryption operation type in progress from the first page of a tablespace.
[in] | page | first page of a tablespace |
[in] | page_size | tablespace page size |
bool fsp_header_get_encryption_key | ( | uint32_t | fsp_flags, |
Encryption_key & | e_key, | ||
page_t * | page | ||
) |
Reads the encryption key from the first page of a tablespace.
[in] | fsp_flags | tablespace flags |
[in,out] | e_key | tablespace key, iv |
[in] | page | first page of a tablespace |
ulint fsp_header_get_encryption_offset | ( | const page_size_t & | page_size | ) |
Get the offset of encryption information in page 0.
[in] | page_size | page size. |
|
inline |
Get the offset of encryption progress information in page 0.
[in] | page_size | page size. |
|
inline |
Read a tablespace header field.
[in] | page | first page of a tablespace |
[in] | field | the header field |
|
inline |
Read the flags from the tablespace header page.
[in] | page | first page of a tablespace |
page_size_t fsp_header_get_page_size | ( | const page_t * | page | ) |
Reads the page size from the first page of a tablespace.
[in] | page | first page of a tablespace |
|
inline |
Get the offset of SDI root page number in page 0.
[in] | page_size | Page size. |
|
inline |
Reads the server version from the first page of a tablespace.
[in] | page | first page of a tablespace |
space_id_t fsp_header_get_space_id | ( | const page_t * | page | ) |
Reads the space id from the first page of a tablespace.
page | in: first page of a tablespace |
|
inline |
Reads the server space version from the first page of a tablespace.
[in] | page | first page of a tablespace |
page_no_t 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.
void fsp_header_inc_size | ( | space_id_t | space_id, |
page_no_t | size_inc, | ||
mtr_t * | mtr | ||
) |
Increases the space size field of a space.
[in] | space_id | Space id |
[in] | size_inc | Size increment in pages |
[in,out] | mtr | Mini-transaction |
bool fsp_header_init | ( | space_id_t | space_id, |
page_no_t | 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] | space_id | Space id |
[in] | size | Current size in blocks |
[in,out] | mtr | Mini-transaction |
void fsp_header_init_fields | ( | page_t * | page, |
space_id_t | space_id, | ||
uint32_t | 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
The flags contain row type, physical/compressed page size, and logical/uncompressed page size of the tablespace.
page | in/out: first page in the space |
space_id | in: space id |
flags | in: tablespace flags (FSP_SPACE_FLAGS) |
bool fsp_header_rotate_encryption | ( | fil_space_t * | space, |
byte * | encrypt_info, | ||
mtr_t * | mtr | ||
) |
Rotate the encryption info in the space header.
[in] | space | Tablespace |
[in] | encrypt_info | Buffer for re-encrypt key. |
[in,out] | mtr | Mini-transaction |
|
inline |
Update a tablespace header field.
[in] | page | first page of a tablespace |
[in] | field | the header field |
[in] | val | field value |
|
inline |
Update the tablespace size information and generate redo log for it.
[in] | header | Tablespace header. |
[in] | size | New tablespace size in pages. |
[in] | mtr | Mini-transaction context. |
bool fsp_header_write_encryption | ( | space_id_t | space_id, |
uint32_t | space_flags, | ||
byte * | encrypt_info, | ||
bool | update_fsp_flags, | ||
bool | rotate_encryption, | ||
mtr_t * | mtr | ||
) |
Write the encryption info into the space header.
[in] | space_id | Tablespace id |
[in] | space_flags | Tablespace flags |
[in] | encrypt_info | Buffer for re-encrypt key |
[in] | update_fsp_flags | If it need to update the space flags |
[in] | rotate_encryption | If it is called during key rotation |
[in,out] | mtr | Mini-transaction |
bool fsp_header_write_encryption_progress | ( | space_id_t | space_id, |
ulint | space_flags, | ||
ulint | progress_info, | ||
byte | operation_type, | ||
bool | update_operation_type, | ||
mtr_t * | mtr | ||
) |
Write the encryption progress info into the space header.
[in] | space_id | Tablespace id |
[in] | space_flags | Tablespace flags |
[in] | progress_info | Max pages (un)encrypted |
[in] | operation_type | Type of operation |
[in] | update_operation_type | Is operation to be updated |
[in,out] | mtr | Mini-transaction |
void fsp_init | ( | void | ) |
Initializes the file space system.
Initializes the file space system.
void fsp_init_resume_alter_encrypt_tablespace | ( | ) |
Initiate roll-forward of alter encrypt in background thread.
bool fsp_is_dd_tablespace | ( | space_id_t | space_id | ) |
Check if tablespace is dd tablespace.
[in] | space_id | tablespace ID |
|
inlinestatic |
Check if tablespace is file-per-table.
[in] | space_id | tablespace ID |
[in] | fsp_flags | tablespace flags |
|
inlinestatic |
Determine if the space ID is an IBD tablespace, either file_per_table or a general shared tablespace, where user tables exist.
[in] | space_id | tablespace ID |
|
inline |
Check if a specified page is inode page or not.
This is used for index root pages of hard-coded DD tables, we can safely assume that the passed in page number is in the range of pages which are only either index root page or inode page
[in] | page | Page number to check |
|
inlinestatic |
Check if the space_id is for a system-tablespace (shared + temp).
[in] | space_id | tablespace ID |
|
inlinestatic |
bool fsp_is_undo_tablespace | ( | space_id_t | space_id | ) |
Check whether a space id is an undo tablespace ID Undo tablespaces have space_id's starting 1 less than the redo logs.
They are numbered down from this. Since rseg_id=0 always refers to the system tablespace, undo_space_num values start at 1. The current limit is 127. The translation from an undo_space_num is: undo space_id = log_first_space_id - undo_space_num
[in] | space_id | space id to check |
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.
[in] | ptr | Buffer. |
[in] | end_ptr | Buffer end. |
[in] | block | Block or nullptr. |
bool fsp_reserve_free_extents | ( | ulint * | n_reserved, |
space_id_t | space_id, | ||
ulint | n_ext, | ||
fsp_reserve_t | alloc_type, | ||
mtr_t * | mtr, | ||
page_no_t | n_pages | ||
) |
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 < FSP_EXTENT_SIZE pages are a special case. In this function we would liberally reserve several 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 < FSP_EXTENT_SIZE pages. That is why we apply different rules in that special case, just ensuring that there are n_pages free pages available.
[out] | n_reserved | Number of extents actually reserved; if we return true and the tablespace size is < FSP_EXTENT_SIZE pages, then this can be 0, otherwise it is n_ext |
[in] | space_id | Tablespace identifier |
[in] | n_ext | Number of extents to reserve |
[in] | alloc_type | Page reservation type (FSP_BLOB, etc) |
[in,out] | mtr | Mini-transaction |
[in] | n_pages | For small tablespaces (tablespace size is less than FSP_EXTENT_SIZE), number of free pages to reserve. |
page_no_t fsp_sdi_get_root_page_num | ( | space_id_t | space, |
const page_size_t & | page_size, | ||
mtr_t * | mtr | ||
) |
Retrieve tablespace dictionary index root page number stored in the page 0.
[in] | space | Tablespace id |
[in] | page_size | Page size |
[in,out] | mtr | Mini-transaction |
void fsp_sdi_write_root_to_page | ( | page_t * | page, |
const page_size_t & | page_size, | ||
page_no_t | root_page_num, | ||
mtr_t * | mtr | ||
) |
Write SDI Index root page num to page 0 of tablespace.
[in,out] | page | Page 0 frame |
[in] | page_size | Size of page |
[in] | root_page_num | Root page number of SDI |
[in,out] | mtr | Mini-transaction |
|
inline |
The global output stream operator is overloaded to work with an object of type File_segment_inode.
[in] | out | the output stream. |
[in] | obj | an object of type File_segment_inode. |
|
inlinestatic |
Calculates the descriptor index within a descriptor page.
[in] | page_size | page size |
[in] | offset | page offset |
|
inlinestatic |
Calculates the page where the descriptor of a page resides.
[in] | page_size | page size |
[in] | offset | page offset |
Gets a descriptor bit of a page.
[in] | descr | descriptor |
[in] | bit | XDES_FREE_BIT or XDES_CLEAN_BIT |
[in] | offset | page offset within extent: 0 ... FSP_EXTENT_SIZE - 1 |
|
inline |
Get the state of an xdes.
[in] | descr | extent descriptor |
[in,out] | mtr | Mini-transaction. |
std::ostream & xdes_page_print | ( | std::ostream & | out, |
const page_t * | xdes, | ||
page_no_t | page_no, | ||
mtr_t * | mtr | ||
) |
Print the extent descriptor page in user-friendly format.
[in] | out | The output file stream |
[in] | xdes | The extent descriptor page |
[in] | page_no | The page number of xdes page |
[in] | mtr | Mini-transaction. |
|
constexpr |
|
extern |
|
extern |
|
extern |
DDL records for tablespace (un)encryption.