MySQL 8.0.39
Source Code Documentation
|
Handle which allows to do reads / writes for the opened file. More...
#include <log0types.h>
Static Public Member Functions | |
static uint64_t | fsyncs_in_progress () |
static uint64_t | total_fsyncs () |
Private Member Functions | |
Log_file_handle (const Log_file_handle &other)=delete | |
Log_file_handle & | operator= (const Log_file_handle &rhs)=delete |
Private Attributes | |
Log_file_id | m_file_id |
Id of the redo log file (part of its file name) More... | |
Log_file_access_mode | m_access_mode |
Access mode allowed for this handle (if not yet closed). More... | |
Encryption_metadata & | m_encryption_metadata |
Encryption metadata to be used for all IO operations on this file except those related to the first LOG_FILE_HDR_SIZE bytes. More... | |
Log_file_type | m_file_type |
Type of redo log file. More... | |
bool | m_is_open |
Whether file is opened. More... | |
bool | m_is_modified |
Whether file has been modified using this handle since it was opened. More... | |
std::string | m_file_path |
File name. More... | |
pfs_os_file_t | m_raw_handle |
OS handle for file (if opened) More... | |
os_offset_t | m_block_size |
Size of single physical block (if opened) More... | |
os_offset_t | m_file_size |
Size of file in bytes (if opened) More... | |
Friends | |
struct | Log_file |
Log_file_handle implementation | |
static Log_file_io_callback | s_on_before_read |
Callback called on each read operation. More... | |
static Log_file_io_callback | s_on_before_write |
Callback called on each write operation. More... | |
static bool | s_skip_fsyncs = false |
True iff all fsyncs should be no-op. More... | |
static std::atomic< size_t > | s_n_open {0} |
Number of all opened Log_file_handle existing currently. More... | |
static std::atomic< uint64_t > | s_fsyncs_in_progress {0} |
Number of fsyncs in-progress. More... | |
static std::atomic< uint64_t > | s_total_fsyncs {0} |
Total number of fsyncs that have been started since the server has started. More... | |
Log_file_handle (Encryption_metadata &encryption_metadata) | |
Log_file_handle (Log_file_handle &&other) | |
Log_file_handle & | operator= (Log_file_handle &&rhs) |
~Log_file_handle () | |
Closes handle if was opened (calling fsync if was modified). More... | |
bool | is_open () const |
void | close () |
Closes file represented by this handle (must be opened). More... | |
Log_file_id | file_id () const |
const std::string & | file_path () const |
os_offset_t | file_size () const |
dberr_t | read (os_offset_t read_offset, os_offset_t read_size, byte *buf) |
Reads from the log file at the given offset (to the provided buffer). More... | |
dberr_t | write (os_offset_t write_offset, os_offset_t write_size, const byte *buf) |
Writes the provided buffer to the log file at the given offset. More... | |
void | fsync () |
Executes fsync operation for this redo log file. More... | |
Log_file_handle (const Log_files_context &files_ctx, Log_file_id id, Log_file_access_mode access_mode, Encryption_metadata &encryption_metadata, Log_file_type file_type) | |
Tries to open a given redo log file with with a given access mode. More... | |
dberr_t | open () |
Open the log file with the configured access mode. More... | |
IORequest | prepare_io_request (int req_type, os_offset_t offset, os_offset_t size, bool can_use_encryption) |
Creates and configures an io request object according to currently configured encryption metadata (m_encryption_*) and m_block_size. More... | |
Handle which allows to do reads / writes for the opened file.
For particular kind of reads or writes (for checkpoint headers, data blocks, main file header or encryption header) there are helper functions defined outside this class. Unless you wanted to transfer the whole file as-is, you should rather use those functions for read/write operations.
|
explicit |
Log_file_handle::Log_file_handle | ( | Log_file_handle && | other | ) |
Log_file_handle::~Log_file_handle | ( | ) |
Closes handle if was opened (calling fsync if was modified).
Destructs the handle object.
|
private |
Tries to open a given redo log file with with a given access mode.
If succeeded then this handle represents the opened file and allows to performs reads and/or writes (depends on the requested access mode). If encountered error during the attempt to open, error message is emitted to the error log, in which case this handle remains closed.
[in] | files_ctx | context within which files exist |
[in] | id | id of the log file |
[in] | access_mode | access mode for the opened file |
[in] | encryption_metadata | encryption metadata |
[in] | file_type | type of redo file |
|
privatedelete |
void Log_file_handle::close | ( | void | ) |
Closes file represented by this handle (must be opened).
Log_file_id Log_file_handle::file_id | ( | ) | const |
const std::string & Log_file_handle::file_path | ( | ) | const |
os_offset_t Log_file_handle::file_size | ( | ) | const |
void Log_file_handle::fsync | ( | ) |
Executes fsync operation for this redo log file.
|
inlinestatic |
bool Log_file_handle::is_open | ( | ) | const |
|
private |
Open the log file with the configured access mode.
|
privatedelete |
Log_file_handle & Log_file_handle::operator= | ( | Log_file_handle && | rhs | ) |
|
private |
Creates and configures an io request object according to currently configured encryption metadata (m_encryption_*) and m_block_size.
[in] | req_type | defines type of IO operation (read or write) |
[in] | offset | offset in bytes from the beginning of the file |
[in] | size | number of bytes to write or read |
[in] | can_use_encryption | e.g. whether newly blocks should be encrypted |
dberr_t Log_file_handle::read | ( | os_offset_t | read_offset, |
os_offset_t | read_size, | ||
byte * | buf | ||
) |
Reads from the log file at the given offset (to the provided buffer).
[in] | read_offset | offset in bytes from the beginning of the file |
[in] | read_size | number of bytes to read |
[out] | buf | allocated buffer to fill when reading |
|
inlinestatic |
dberr_t Log_file_handle::write | ( | os_offset_t | write_offset, |
os_offset_t | write_size, | ||
const byte * | buf | ||
) |
Writes the provided buffer to the log file at the given offset.
[in] | write_offset | offset in bytes from the beginning of the file |
[in] | write_size | number of bytes to write |
[in] | buf | buffer to write |
|
friend |
|
private |
Access mode allowed for this handle (if not yet closed).
|
private |
Size of single physical block (if opened)
|
private |
Encryption metadata to be used for all IO operations on this file except those related to the first LOG_FILE_HDR_SIZE bytes.
|
private |
Id of the redo log file (part of its file name)
|
private |
File name.
|
private |
Size of file in bytes (if opened)
|
private |
Type of redo log file.
|
private |
Whether file has been modified using this handle since it was opened.
|
private |
Whether file is opened.
|
private |
OS handle for file (if opened)
|
staticprivate |
Number of fsyncs in-progress.
|
staticprivate |
Number of all opened Log_file_handle existing currently.
|
static |
Callback called on each read operation.
|
static |
Callback called on each write operation.
|
static |
True iff all fsyncs should be no-op.
|
staticprivate |
Total number of fsyncs that have been started since the server has started.