![]() |
MySQL 26.7.0
Source Code Documentation
|
#include <fil0innodb_tablespace_node_handle.h>
Public Member Functions | |
| Tablespace_node_handle (pfs_os_file_t handle, const std::string &file_name, space_id_t space_id, size_t page_size, size_t node_order) | |
| ~Tablespace_node_handle () override | |
| bool | needs_flushes_for_durability () const override |
| Returns true if the node must be flushed in general to ensure data durability. More... | |
| Status | flush () override |
| Ensures any data written so far to this tablespace node before this call will be made durable and will survive either software or hardware crash. More... | |
| Status | truncate (Page_number size) override |
| Truncate the node storage to the given size. More... | |
| Status | fill_range_with_zeros (Page_number first_page, Page_number number_of_pages, bool optimize_writes) override |
Makes the number_of_pages pages, starting with page number first_page contain all zeros. More... | |
| Status_IO | read_page (IORequest req, byte *buffer, Page_number page_no) override |
| Reads a requested page synchronously. More... | |
| Status_IO | read_page_async (IORequest req, byte *buffer, Page_number page_no, Callback callback) override |
| Reads a requested page asynchronously. More... | |
| Status_IO | write_page (IORequest req, byte *buffer, size_t buffer_len, Page_number page_no) override |
| Writes a requested page synchronously. More... | |
| Status_IO | write_page_async (IORequest req, byte *buffer, size_t buffer_len, Page_number page_no, Callback callback) override |
| Writes a requested page asynchronously. More... | |
Public Member Functions inherited from ib::fil::Tablespace_node_handle_interface | |
| virtual | ~Tablespace_node_handle_interface ()=default |
| Closes the opened node handle. More... | |
Private Member Functions | |
| void | retry_read_a_few_times_if_page_id_seems_wrong (IORequest req, uint64_t offset, byte *buffer, page_no_t page_no, dberr_t &io_result) |
| Checks if the page read by a successful asynchronous read contains the space and page IDs that were meant to be read and in case they are not, try a few times to read them synchronously from disk. More... | |
Static Private Member Functions | |
| static Status_IO | map_db_err_to_status_io (dberr_t err) |
| Maps DB error code to Status_IO error code. More... | |
Private Attributes | |
| const pfs_os_file_t | m_handle |
| Opened tablespace file handle. More... | |
| const std::string | m_file_name |
| Tablespace file name. More... | |
| const space_id_t | m_space_id |
| Tablespace ID. More... | |
| const size_t | m_physical_page_size |
| Physical size of a page. More... | |
| const size_t | m_node_order |
| Number of the node in the tablespace. More... | |
Additional Inherited Members | |
Public Types inherited from ib::fil::Tablespace_node_handle_interface | |
| enum class | Status { SUCCESS = 0 , IO_ERROR } |
| enum class | Status_IO { SUCCESS = 0 , IO_DECRYPT_FAIL , CORRUPTION , IO_OVERFLOW , OUT_OF_MEMORY , IO_DECOMPRESS_FAIL , IO_NO_PUNCH_HOLE , UNSUPPORTED , IO_ERROR } |
| using | byte = unsigned char |
| using | Page_number = uint32_t |
| Type used for numbering the pages in the node. More... | |
| using | Callback = std::function< void(dberr_t io_result)> |
| ib::fil::Tablespace_node_handle::Tablespace_node_handle | ( | pfs_os_file_t | handle, |
| const std::string & | file_name, | ||
| space_id_t | space_id, | ||
| size_t | page_size, | ||
| size_t | node_order | ||
| ) |
|
override |
|
overridevirtual |
Makes the number_of_pages pages, starting with page number first_page contain all zeros.
This can be use to efficiently extend the node size. It may be implemented more efficiently than actually writing buffers with zeros, but only if optimize_writes is set to true.
| [in] | first_page | Number of page in node from to be overwritten with zeros. |
| [in] | number_of_pages | Number of pages to overwrite with zeros. |
| [in] | optimize_writes | If true the implementation can use faster and possibly less robust way to zero the range. |
Implements ib::fil::Tablespace_node_handle_interface.
|
overridevirtual |
Ensures any data written so far to this tablespace node before this call will be made durable and will survive either software or hardware crash.
Implements ib::fil::Tablespace_node_handle_interface.
|
staticprivate |
Maps DB error code to Status_IO error code.
|
overridevirtual |
Returns true if the node must be flushed in general to ensure data durability.
Implements ib::fil::Tablespace_node_handle_interface.
|
overridevirtual |
Reads a requested page synchronously.
Before the page is returned, the page will be decrypted and decompressed, depending on information present in the page header.
The size of the buffer in bytes should be at least the tablespace physical page size which was passed to tablespaces_nodes::open() or calculated from flags passed to tablespaces_nodes::create().
| [in] | req | IO request type, compression and encryption information. |
| [out] | buffer | A buffer where to read the data in. It must be aligned in memory to physical page size. It must be able to store physical page size bytes. The memory pointed is managed by the caller and must remain valid until the call finishes. TODO : buffer to be replaced with std::span. |
| [in] | page_no | Offset from the first page in the node to read from. |
Implements ib::fil::Tablespace_node_handle_interface.
|
overridevirtual |
Reads a requested page asynchronously.
After the operation is completed, successfully or not, the callback is called with the result error code, probably in a different thread. If the request is successful, it will always be called from a different thread in context that has no latches taken.
Before the page is returned, the page will be decrypted and decompressed, depending on information present in the page header.
The size of the buffer in bytes should be at least the tablespace physical page size which was passed to tablespaces_nodes::open() or calculated from flags passed to tablespaces_nodes::create().
| [in] | req | IO request type, compression and encryption information. |
| [out] | buffer | A buffer where to read the data in. It must be aligned in memory to physical page size. It must be able to store physical page size bytes. The memory pointed is managed by the caller and must remain valid until the callback is being called. TODO : buffer to be replaced with std::span. |
| [in] | page_no | Offset from the first page in the node to read from. |
| [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 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. |
Implements ib::fil::Tablespace_node_handle_interface.
|
private |
Checks if the page read by a successful asynchronous read contains the space and page IDs that were meant to be read and in case they are not, try a few times to read them synchronously from disk.
| [in] | req | IO request. |
| [in] | offset | An offset in bytes in the tablespace the read was requested for. |
| [out] | buffer | A buffer where to read the data in. |
| [in] | page_no | Offset from the first page in the node to read from. |
| [in,out] | io_result | Reference to the error code of the IO operation, it will be have the value changed to result of last read IO operation executed. |
|
overridevirtual |
Truncate the node storage to the given size.
| [in] | size | Expected size in pages of node after truncation. If the size provided is more than or equal to the current size of the node storage, return success. |
Implements ib::fil::Tablespace_node_handle_interface.
|
overridevirtual |
Writes a requested page synchronously.
The page will be encrypted and compressed, below this implementation depending on information present in the page header.
If punch hole is supported and requested, this API implementation punches the hole depending on input buffer compression metadata (check Punch Hole Optimization), the capability of Implementation and settings in IORequest.
If compression/encryption is to be done, the input buffer may be modified accordingly with post encryption/compression metadata (eg : Page type, compression info).
The size of the buffer in bytes should be at most the tablespaces physical page size which was passed to tablespaces_nodes::open() or calculated from flags passed to tablespaces_nodes::create(). In other words, buffer_len must not be greater than the tablespace physical page size. In case of punch hole, the buffer_len can be less than physical page size but it must be divisible by 512. And the buffer will be written out and rest of the page will be hole-punched.
| [in] | req | IO request type, compression and encryption information. |
| [out] | buffer | A buffer containing the data to be written. Data from this buffer might be copied and the copy transformed before writing it. It must be aligned in memory to the OS block size (UNIV_SECTOR_SIZE). The memory pointed is managed by the caller and must remain valid until the call returns. |
| [in] | buffer_len | Size of the buffer to be written. 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. TODO : buffer and buffer_len to be replaced with std::span. |
| [in] | page_no | Offset from the first page in the node to write to. |
Implements ib::fil::Tablespace_node_handle_interface.
|
overridevirtual |
Writes a requested page asynchronously.
After the operation is completed, successfully or not, the callback is called with the result error code, probably in a different thread. If the request is successful, it will always be called from a different thread in context that has no latches taken.
The page will be encrypted and compressed, below this implementation depending on information present in the page header.
If punch hole is supported and requested, this API implementation punches the hole depending on input buffer compression metadata (check Punch Hole Optimization), the capability of Implementation and settings in IORequest.
If compression/encryption is to be done, the input buffer may be modified accordingly with post encryption/compression metadata (eg : Page type, compression info).
The size of the buffer in bytes should be at most the tablespaces physical page size which was passed to tablespaces_nodes::open() or calculated from flags passed to tablespaces_nodes::create(). In other words, buffer_len must not be greater than the tablespace physical page size. In case of punch hole, the buffer_len can be less than physical page size but it must be divisible by 512. And the buffer will be written out and rest of the page will be hole-punched.
| [in] | req | IO request type, compression and encryption information. |
| [out] | buffer | A buffer containing the data to be written. Data from this buffer might be copied and the copy transformed before writing it. It must be aligned in memory to the OS block size (UNIV_SECTOR_SIZE). The memory pointed is managed by the caller and must remain valid until the callback is being called. |
| [out] | buffer_len | Size of the buffer to be written. It must be aligned to 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. TODO : buffer and buffer_len to be replaced with std::span. |
| [in] | page_no | Offset from the first page in the node to write to. |
| [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 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. |
Implements ib::fil::Tablespace_node_handle_interface.
|
private |
Tablespace file name.
|
private |
Opened tablespace file handle.
|
private |
Number of the node in the tablespace.
|
private |
Physical size of a page.
Needed to calculate the file offset for I/O.
|
private |
Tablespace ID.