![]() |
MySQL 26.7.0
Source Code Documentation
|
Node of a tablespace encapsulating handle required for any IO operations on this node. More...
#include <fil0fil.h>
Public Types | |
| using | modification_counter_t = int64_t |
| using | List_node = UT_LIST_NODE_T(fil_node_t) |
Public Member Functions | |
| fil_node_t (fil_space_t *space, const char *name, uint32_t node_order, bool is_raw, page_no_t size_in_pages, page_no_t max_pages, uint32_t block_size) | |
| fil_node_t (fil_node_t &&other) | |
| ~fil_node_t () | |
| bool | can_be_closed () const |
| Returns true if the node can be closed. More... | |
| bool | is_flushed () const |
| Returns true if the node is fully flushed, that is it is flushed up to the modification_counter. More... | |
| void | pretend_is_flushed () |
| Sets node to flushed state without actually flushing it. More... | |
| void | increment_modification_counter () |
| Increment modification counter for this node. More... | |
| bool | is_flush_needed () const |
| Determine if flush is needed for the node. More... | |
| void | wait_for_all_flushes_to_finish (class Fil_shard &shard) |
| Waits for any pending flushes. More... | |
| void | flush (class Fil_shard &shard) |
| Assures the node will be flushed at least to m_modification_counter. More... | |
| bool | needs_flushes_for_durability () const |
| dberr_t | post_io_sync (IORequest &type, byte *buf, size_t buffer_len, page_no_t page_no) const |
| Posts a synchronous READ or WRITE IO operation on the node. More... | |
| dberr_t | post_io_async (IORequest &type, byte *buf, size_t buffer_len, page_no_t page_no, std::function< void(dberr_t)> callback) const |
| Posts an asynchronous READ or WRITE IO operation on the node. More... | |
| bool | is_open () const |
| Returns true iff the node is currently opened and allows IO operations. More... | |
| bool | is_read_only () const |
| Must the node be opened only for read only mode? Files can be opened for read and write, unless the srv_read_only_mode is used. More... | |
| bool | open () |
| Opens the node for incoming IO operations. More... | |
| void | close () |
| Closes the node, the IO operations will not be permitted. More... | |
| bool | truncate (page_no_t new_size_in_pages) |
| Truncates the node. More... | |
| dberr_t | fill_range_with_zeros (page_no_t first_page, page_no_t number_of_pages) |
Makes the number_of_pages pages, starting with page number first_page contain all zeros. More... | |
| size_t | get_block_size () const |
| bool | get_punch_hole () const |
| Check if punch_hole is supported by storage. More... | |
| void | set_punch_hole (bool value) |
| page_no_t | get_cached_size_in_pages () const |
| void | set_cached_node_size (size_t new_pages_count_to_cache) |
| In addition to updating. More... | |
Public Attributes | |
| fil_space_t *const | space |
| tablespace containing this node More... | |
| char * | name |
| file name; protected by Fil_shard::m_mutex and log_sys->mutex. More... | |
| const size_t | m_order |
| Number of the file in the tablespace's nodes list. More... | |
| const bool | is_raw_disk |
| whether the node actually is a raw device or disk partition More... | |
| page_no_t | flush_size |
| Size of the node when last flushed, used to force the flush when node grows to keep the filesystem metadata synced when using O_DIRECT_NO_FSYNC. More... | |
| page_no_t | init_size |
| initial size of the node in database pages; FIL_IBD_FILE_INITIAL_SIZE by default More... | |
| const page_no_t | m_max_size_in_pages |
| maximum size of the node in database pages More... | |
| size_t | n_pending_ios {} |
| count of pending I/O's; is_open must be true if nonzero More... | |
| bool | m_is_being_flushed {} |
| Set to true when the node is being flushed. More... | |
| bool | is_being_extended {} |
| Set to true when a node is being extended. More... | |
| List_node | LRU {} |
| link to the fil_system->LRU list (keeping track of open files) More... | |
| const size_t | magic_n {FIL_NODE_MAGIC_N} |
| FIL_NODE_MAGIC_N. More... | |
Private Member Functions | |
| bool | is_flush_needed (modification_counter_t flush_upto) const |
| Determine if flush is needed. More... | |
| void | wait_for_current_flush_to_finish (class Fil_shard &shard, modification_counter_t flush_upto) |
| Waits for the current flush (if any) to finish, unless the file is already flushed up to flush_upto. More... | |
Static Private Member Functions | |
| static dberr_t | map_status_io_to_db_err (ib::fil::Tablespace_node_handle_interface::Status_IO err) |
| Map error code returned from read/write APIs to dberr_t code. More... | |
Private Attributes | |
| ut::unique_ptr< ib::fil::Tablespace_node_handle_interface > | m_handle {} |
| file handle (not null iff is_open) More... | |
| Os_event_t | m_flush_finished_event {} |
| event that groups and serializes calls to fsync More... | |
| bool | m_is_open {false} |
| whether this node is open. More... | |
| modification_counter_t | m_modification_counter {} |
| number of writes to the node since the system was started More... | |
| modification_counter_t | m_flush_counter {} |
| the m_modification_counter of the latest flush to disk More... | |
| size_t | m_n_threads_waiting_for_flush {} |
| number of threads waiting for chance to flush More... | |
| const size_t | m_block_size |
| block size to use for punching holes More... | |
| bool | m_punch_hole {false} |
| whether the file system of this node supports PUNCH HOLE More... | |
| page_no_t | m_cached_size_in_pages |
| Size of the node in physical pages, excluding any partial last page. More... | |
Node of a tablespace encapsulating handle required for any IO operations on this node.
| using fil_node_t::modification_counter_t = int64_t |
|
inline |
|
inline |
|
inline |
| bool fil_node_t::can_be_closed | ( | ) | const |
Returns true if the node can be closed.
| void fil_node_t::close | ( | void | ) |
Closes the node, the IO operations will not be permitted.
It is up to the user to provide synchronization with open(), IO calls and wait for pending IO operations to finish first before calling the close.
Makes the number_of_pages pages, starting with page number first_page contain all zeros.
This can be used to efficiently extend the node size. It may be implemented more efficiently than actually writing buffers with zeros.
| [in] | first_page | ID of first page to be overwritten with zeros. |
| [in] | number_of_pages | Number of pages to overwrite with zeros. |
| void fil_node_t::flush | ( | class Fil_shard & | shard | ) |
Assures the node will be flushed at least to m_modification_counter.
| [in] | shard | Reference to Fil_shard that will be used to release and re-acquire mutex while we are waiting for the pending flushes. |
|
inline |
|
inline |
|
inline |
Check if punch_hole is supported by storage.
| void fil_node_t::increment_modification_counter | ( | ) |
Increment modification counter for this node.
| bool fil_node_t::is_flush_needed | ( | ) | const |
Determine if flush is needed for the node.
|
private |
Determine if flush is needed.
| [in] | flush_upto | expectation up to which flush is to be done |
| bool fil_node_t::is_flushed | ( | ) | const |
Returns true if the node is fully flushed, that is it is flushed up to the modification_counter.
|
inline |
Returns true iff the node is currently opened and allows IO operations.
| bool fil_node_t::is_read_only | ( | ) | const |
Must the node be opened only for read only mode? Files can be opened for read and write, unless the srv_read_only_mode is used.
With srv_read_only_mode all files are read-only, but the temporary tables, as they are not altering the physical database data, they do not generate UNDO etc, so can be used even in the read-only mode.
|
staticprivate |
Map error code returned from read/write APIs to dberr_t code.
| [in] | err | error code returned from read/write APIs |
|
inline |
| bool fil_node_t::open | ( | ) |
Opens the node for incoming IO operations.
The node will be opened for read-only if is_read_only() returns true, and for read-write otherwise.
| dberr_t fil_node_t::post_io_async | ( | IORequest & | type, |
| byte * | buf, | ||
| size_t | buffer_len, | ||
| page_no_t | page_no, | ||
| std::function< void(dberr_t)> | callback | ||
| ) | const |
Posts an asynchronous READ or WRITE IO operation on the node.
The operation may return error code immediately or DB_SUCCESS when the IO was submitted for asynchronous completion. After the asynchronous IO is complete, the os_aio_handler will return a reference to the current node, callback value supplied, the type and status code for the result of the IO operation.
| [in] | type | IO request type, compression and encryption information. |
| [in,out] | buf | A buffer where to store read data or from where to write. Data from this buffer might be first transformed before writing it. It must be aligned in memory to OS block size (UNIV_SECTOR_SIZE). Additionally, for reads, it must be aligned to physical page size, too. The memory pointed is managed by the caller and must remain valid until the callback begins execution. |
| [in] | buffer_len | Size of the buffer. It must not cross the node boundary; It always has to be a multiply of OS block size (UNIV_SECTOR_SIZE). In case of write of an already compressed data, it is a length of the compressed data buffer. Otherwise it should be physical page size. Actual number of bytes written can be smaller if the tablespace has compression enabled and data was not compressed already. |
| [in] | page_no | Page number where to read from or write into. |
| [in] | callback | A callback to be called exactly once when the result of this IO operation is known. It may be a success if the read or write succeeded or a subset of dberr_t errors if the write or read could not be executed or if it failed. It can be called synchronously in this thread before returning from this method, or can be executed asynchronously from another thread, when sync is false, before or after this call returns. |
| dberr_t fil_node_t::post_io_sync | ( | IORequest & | type, |
| byte * | buf, | ||
| size_t | buffer_len, | ||
| page_no_t | page_no | ||
| ) | const |
Posts a synchronous READ or WRITE IO operation on the node.
It is blocking call and returns the status code of the IO operation.
| [in] | type | IO request type, compression and encryption information. |
| [in,out] | buf | A buffer where to store read data or from where to write. Data from this buffer might be first transformed before writing it. It must be aligned in memory to OS block size (UNIV_SECTOR_SIZE). Additionally, for reads, it must be aligned to physical page size, too. The memory pointed is managed by the caller and must remain valid until the call returns. |
| [in] | buffer_len | Size of the buffer. It must not cross the node boundary; It always has to be a multiply of OS block size (UNIV_SECTOR_SIZE). In case of write of an already compressed data, it is a length of the compressed data buffer. Otherwise it should be physical page size. Actual number of bytes written can be smaller if the tablespace has compression enabled and data was not compressed already. |
| [in] | page_no | Page number where to read from or write into. |
| void fil_node_t::pretend_is_flushed | ( | ) |
Sets node to flushed state without actually flushing it.
| void fil_node_t::set_cached_node_size | ( | size_t | new_pages_count_to_cache | ) |
In addition to updating.
|
inline |
| bool fil_node_t::truncate | ( | page_no_t | new_size_in_pages | ) |
Truncates the node.
Sets the truncated node to have size of size bytes, that are all zeroed.
| [in] | new_size_in_pages | Size in pages to set the node size to after the truncation. |
| void fil_node_t::wait_for_all_flushes_to_finish | ( | class Fil_shard & | shard | ) |
Waits for any pending flushes.
| [in] | shard | Reference to Fil_shard that will be used to release and re-acquire mutex while we are waiting for the pending flushes. |
|
private |
Waits for the current flush (if any) to finish, unless the file is already flushed up to flush_upto.
| [in] | shard | Reference to Fil_shard that will be used to release and re-acquire mutex while we are waiting for the current flush to finish. |
| [in] | flush_upto | Wait until current flush finished or until m_flush_counter reached flush_upto |
| page_no_t fil_node_t::flush_size |
Size of the node when last flushed, used to force the flush when node grows to keep the filesystem metadata synced when using O_DIRECT_NO_FSYNC.
| page_no_t fil_node_t::init_size |
initial size of the node in database pages; FIL_IBD_FILE_INITIAL_SIZE by default
| bool fil_node_t::is_being_extended {} |
Set to true when a node is being extended.
| const bool fil_node_t::is_raw_disk |
whether the node actually is a raw device or disk partition
| List_node fil_node_t::LRU {} |
link to the fil_system->LRU list (keeping track of open files)
|
private |
block size to use for punching holes
|
private |
Size of the node in physical pages, excluding any partial last page.
The field is initialized with the fresh result of Tablespace_nodes_interface::get_node_info(), and updated by InnoDB whenever it is performing Fil_shard::space_truncate() or Fil_shard::space_extend(), to match the desired size. The size of the physical page is validated to flags in the tablespace header, i.e. it is impossible to continue if size of the page declared in the header doesn't match the expectation. However, the number of pages declared in the header, and cached in the m_fsp_cache.m_size_in_header, doesn't have to match m_cached_size_in_pages. In other words:
|
private |
the m_modification_counter of the latest flush to disk
|
private |
event that groups and serializes calls to fsync
|
private |
file handle (not null iff is_open)
| bool fil_node_t::m_is_being_flushed {} |
Set to true when the node is being flushed.
|
private |
whether this node is open.
| const page_no_t fil_node_t::m_max_size_in_pages |
maximum size of the node in database pages
|
private |
number of writes to the node since the system was started
|
private |
number of threads waiting for chance to flush
| const size_t fil_node_t::m_order |
Number of the file in the tablespace's nodes list.
|
private |
whether the file system of this node supports PUNCH HOLE
| const size_t fil_node_t::magic_n {FIL_NODE_MAGIC_N} |
FIL_NODE_MAGIC_N.
| size_t fil_node_t::n_pending_ios {} |
count of pending I/O's; is_open must be true if nonzero
| char* fil_node_t::name |
file name; protected by Fil_shard::m_mutex and log_sys->mutex.
| fil_space_t* const fil_node_t::space |
tablespace containing this node