54#include <sys/statvfs.h>
67#define OS_FILE_PREFIX "#"
120typedef HANDLE os_file_dir_t;
127#define UNIV_NON_BUFFERED_IO
137#define OS_FILE_FROM_FD(fd) (HANDLE) _get_osfhandle(fd)
142#define OS_FD_FROM_FILE(file) _open_osfhandle((intptr_t)file, _O_RDONLY)
147#define OS_FILE_CLOSE_FD(fd) _close(fd)
159#define OS_FILE_FROM_FD(fd) fd
164#define OS_FD_FROM_FILE(file) file
169#define OS_FILE_CLOSE_FD(fd) (os_file_close(fd) ? 0 : OS_FD_CLOSED)
272#define IORequestRead IORequest(IORequest::READ)
273#define IORequestWrite IORequest(IORequest::WRITE)
526#if defined(HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE) || defined(_WIN32)
664 "(FN_REFLEN_SE < OS_FILE_MAX_PATH)");
683#ifndef UNIV_HOTBACKUP
755 const char *operation_name);
828#define register_pfs_file_open_begin(state, locker, key, op, name, \
831 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
832 op, name, &locker); \
833 if (locker != nullptr) { \
834 PSI_FILE_CALL(start_file_open_wait) \
835 (locker, src_location.filename, static_cast<uint>(src_location.line)); \
839#define register_pfs_file_open_end(locker, file, result) \
841 if (locker != nullptr) { \
842 file.m_psi = PSI_FILE_CALL(end_file_open_wait)(locker, result); \
846#define register_pfs_file_rename_begin(state, locker, key, op, from, to, \
849 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
850 op, from, &locker); \
851 if (locker != nullptr) { \
852 PSI_FILE_CALL(start_file_rename_wait) \
853 (locker, (size_t)0, from, to, src_location.filename, \
854 static_cast<uint>(src_location.line)); \
858#define register_pfs_file_rename_end(locker, from, to, result) \
860 if (locker != nullptr) { \
861 PSI_FILE_CALL(end_file_rename_wait)(locker, from, to, result); \
865#define register_pfs_file_close_begin(state, locker, key, op, name, \
868 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
869 op, name, &locker); \
870 if (locker != nullptr) { \
871 PSI_FILE_CALL(start_file_close_wait) \
872 (locker, src_location.filename, static_cast<uint>(src_location.line)); \
876#define register_pfs_file_close_end(locker, result) \
878 if (locker != nullptr) { \
879 PSI_FILE_CALL(end_file_close_wait)(locker, result); \
883#define register_pfs_file_io_begin(state, locker, file, count, op, \
887 PSI_FILE_CALL(get_thread_file_stream_locker)(state, file.m_psi, op); \
888 if (locker != nullptr) { \
889 PSI_FILE_CALL(start_file_wait) \
890 (locker, count, src_location.filename, \
891 static_cast<uint>(src_location.line)); \
895#define register_pfs_file_io_end(locker, count) \
897 if (locker != nullptr) { \
898 PSI_FILE_CALL(end_file_wait)(locker, count); \
919#define os_file_create(key, name, create, purpose, type, read_only, success) \
920 pfs_os_file_create_func(key, name, create, purpose, type, read_only, \
921 success, UT_LOCATION_HERE)
923#define os_file_create_simple(key, name, create, access, read_only, success) \
924 pfs_os_file_create_simple_func(key, name, create, access, read_only, \
925 success, UT_LOCATION_HERE)
927#define os_file_create_simple_no_error_handling(key, name, create_mode, \
928 access, read_only, success) \
929 pfs_os_file_create_simple_no_error_handling_func( \
930 key, name, create_mode, access, read_only, success, UT_LOCATION_HERE)
932#define os_file_close_pfs(file) pfs_os_file_close_func(file, UT_LOCATION_HERE)
934#define os_aio(type, mode, name, file, buf, offset, n, read_only, message1, \
936 pfs_os_aio_func(type, mode, name, file, buf, offset, n, read_only, message1, \
937 message2, UT_LOCATION_HERE)
939#define os_file_read_pfs(type, file_name, file, buf, offset, n) \
940 pfs_os_file_read_func(type, file_name, file, buf, offset, n, UT_LOCATION_HERE)
942#define os_file_read_first_page_pfs(type, file_name, file, buf, n) \
943 pfs_os_file_read_first_page_func(type, file_name, file, buf, n, \
946#define os_file_copy_pfs(src, src_offset, dest, dest_offset, size) \
947 pfs_os_file_copy_func(src, src_offset, dest, dest_offset, size, \
950#define os_file_read_no_error_handling_pfs(type, file_name, file, buf, offset, \
952 pfs_os_file_read_no_error_handling_func(type, file_name, file, buf, offset, \
953 n, o, UT_LOCATION_HERE)
955#define os_file_read_no_error_handling_int_fd(type, file_name, file, buf, \
957 pfs_os_file_read_no_error_handling_int_fd_func( \
958 type, file_name, file, buf, offset, n, o, UT_LOCATION_HERE)
960#define os_file_write_pfs(type, name, file, buf, offset, n) \
961 pfs_os_file_write_func(type, name, file, buf, offset, n, UT_LOCATION_HERE)
963#define os_file_write_int_fd(type, name, file, buf, offset, n) \
964 pfs_os_file_write_int_fd_func(type, name, file, buf, offset, n, \
967#define os_file_flush_pfs(file) pfs_os_file_flush_func(file, UT_LOCATION_HERE)
969#define os_file_rename(key, oldpath, newpath) \
970 pfs_os_file_rename_func(key, oldpath, newpath, UT_LOCATION_HERE)
972#define os_file_delete(key, name) \
973 pfs_os_file_delete_func(key, name, UT_LOCATION_HERE)
975#define os_file_delete_if_exists(key, name, exist) \
976 pfs_os_file_delete_if_exists_func(key, name, exist, UT_LOCATION_HERE)
1225 const char *oldpath,
1226 const char *newpath,
1261#define os_file_create(key, name, create, purpose, type, read_only, success) \
1262 os_file_create_func(name, create, purpose, type, read_only, success)
1264#define os_file_create_simple(key, name, create_mode, access, read_only, \
1266 os_file_create_simple_func(name, create_mode, access, read_only, success)
1268#define os_file_create_simple_no_error_handling(key, name, create_mode, \
1269 access, read_only, success) \
1270 os_file_create_simple_no_error_handling_func(name, create_mode, access, \
1273#define os_file_close_pfs(file) os_file_close_func(file)
1275#define os_aio(type, mode, name, file, buf, offset, n, read_only, message1, \
1277 os_aio_func(type, mode, name, file, buf, offset, n, read_only, message1, \
1280#define os_file_read_pfs(type, file_name, file, buf, offset, n) \
1281 os_file_read_func(type, file_name, file, buf, offset, n)
1283#define os_file_read_first_page_pfs(type, file_name, file, buf, n) \
1284 os_file_read_first_page_func(type, file_name, file, buf, n)
1286#define os_file_copy_pfs(src, src_offset, dest, dest_offset, size) \
1287 os_file_copy_func(src, src_offset, dest, dest_offset, size)
1289#define os_file_read_no_error_handling_pfs(type, file_name, file, buf, offset, \
1291 os_file_read_no_error_handling_func(type, file_name, file, buf, offset, n, o)
1293#define os_file_read_no_error_handling_int_fd(type, file_name, file, buf, \
1295 os_file_read_no_error_handling_func(type, file_name, OS_FILE_FROM_FD(file), \
1298#define os_file_write_pfs(type, name, file, buf, offset, n) \
1299 os_file_write_func(type, name, file, buf, offset, n)
1301#define os_file_write_int_fd(type, name, file, buf, offset, n) \
1302 os_file_write_func(type, name, OS_FILE_FROM_FD(file), buf, offset, n)
1304#define os_file_flush_pfs(file) os_file_flush_func(file)
1306#define os_file_rename(key, oldpath, newpath) \
1307 os_file_rename_func(oldpath, newpath)
1309#define os_file_delete(key, name) os_file_delete_func(name)
1311#define os_file_delete_if_exists(key, name, exist) \
1312 os_file_delete_if_exists_func(name, exist)
1317#define os_file_close(file) os_file_close_pfs(file)
1319#define os_file_close(file) os_file_close_pfs((file).m_file)
1323#define os_file_read(type, file_name, file, buf, offset, n) \
1324 os_file_read_pfs(type, file_name, file, buf, offset, n)
1326#define os_file_read(type, file_name, file, buf, offset, n) \
1327 os_file_read_pfs(type, file_name, file.m_file, buf, offset, n)
1331#define os_file_read_first_page(type, file_name, file, buf, n) \
1332 os_file_read_first_page_pfs(type, file_name, file, buf, n)
1334#define os_file_read_first_page(type, file_name, file, buf, n) \
1335 os_file_read_first_page_pfs(type, file_name, file.m_file, buf, n)
1339#define os_file_flush(file) os_file_flush_pfs(file)
1341#define os_file_flush(file) os_file_flush_pfs(file.m_file)
1345#define os_file_write(type, name, file, buf, offset, n) \
1346 os_file_write_pfs(type, name, file, buf, offset, n)
1348#define os_file_write(type, name, file, buf, offset, n) \
1349 os_file_write_pfs(type, name, file.m_file, buf, offset, n)
1353#define os_file_copy(src, src_offset, dest, dest_offset, size) \
1354 os_file_copy_pfs(src, src_offset, dest, dest_offset, size)
1356#define os_file_copy(src, src_offset, dest, dest_offset, size) \
1357 os_file_copy_pfs(src.m_file, src_offset, dest.m_file, dest_offset, size)
1361#define os_file_read_no_error_handling(type, file_name, file, buf, offset, n, \
1363 os_file_read_no_error_handling_pfs(type, file_name, file, buf, offset, n, o)
1365#define os_file_read_no_error_handling(type, file_name, file, buf, offset, n, \
1367 os_file_read_no_error_handling_pfs(type, file_name, file.m_file, buf, \
1371#ifdef UNIV_HOTBACKUP
1550#ifdef UNIV_ENABLE_UNIT_TEST_GET_PARENT_DIR
1552void unit_test_os_file_get_parent_dir();
1555#ifdef UNIV_HOTBACKUP
1557void meb_free_block_cache();
1690#ifndef UNIV_HOTBACKUP
1754 byte *dst,
ulint dst_len);
1765 byte *src,
ulint src_len,
byte *dst,
1799 template <
typename F>
1800 static void walk(
const Path &basedir,
bool recursive, F &&f) {
1802 walk_win32(basedir, recursive, [&](
const Path &
path,
size_t) { f(
path); });
1831 static void walk_win32(
const Path &basedir,
bool recursive,
Function &&f);
1897 m_n(static_cast<ssize_t>(
n)),
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:250
Class to scan the directory hierarchy using a depth first scan.
Definition: os0file.h:1786
std::string Path
Definition: os0file.h:1788
static bool is_directory(const Path &path)
Check if the path is a directory.
Definition: os0file.cc:7917
static void walk_posix(const Path &basedir, bool recursive, Function &&f)
Depth first traversal of the directory starting from basedir.
Definition: os0file.cc:3619
std::function< void(const Path &, size_t)> Function
Definition: os0file.h:1824
static void walk(const Path &basedir, bool recursive, F &&f)
Depth first traversal of the directory starting from basedir.
Definition: os0file.h:1800
Encryption algorithm.
Definition: os0enc.h:53
void set_initial_vector(const byte *iv)
Set initial vector.
Definition: os0enc.cc:1496
@ NONE
No encryption.
Definition: os0enc.h:59
void set_key(const byte *key)
Set encryption key.
Definition: os0enc.cc:1490
void set_key_length(ulint klen)
Set key length.
Definition: os0enc.cc:1494
static const char * to_string(Type type) noexcept
Convert to a "string".
Definition: os0enc.cc:216
void set_type(Type type)
Set encryption type.
Definition: os0enc.cc:1488
Type get_type() const
Get encryption type.
Definition: os0enc.cc:1486
The IO Context that is passed down to the low level IO code.
Definition: os0file.h:277
uint32_t m_original_size
Length of the original IO size.
Definition: os0file.h:586
bool is_punch_hole_optimisation_disabled() const
Definition: os0file.h:401
void compression_algorithm(Compression::Type type)
Set compression algorithm.
Definition: os0file.h:465
bool is_dblwr() const
Definition: os0file.h:517
Compression compression_algorithm() const
Get the compression algorithm.
Definition: os0file.h:477
static std::string type_str(const ulint type)
Definition: os0file.cc:7955
bool is_partial_io_warning_disabled() const
Definition: os0file.h:383
void dblwr()
Note that the IO is for double write buffer page write.
Definition: os0file.h:514
void block_size(ulint block_size)
Set the block size for IO.
Definition: os0file.h:440
void clear_encrypted()
Clear all encryption related flags.
Definition: os0file.h:506
void clear_do_not_wake()
Clear the do not wake flag.
Definition: os0file.h:430
bool is_compression_enabled() const
Definition: os0file.h:487
bool is_encrypted() const
Definition: os0file.h:501
ulint block_size() const
Definition: os0file.h:436
@ UNSET
Definition: os0file.h:281
@ DBLWR
Request for a doublewrite page IO.
Definition: os0file.h:286
@ DISABLE_PARTIAL_IO_WARNINGS
Disable partial read warnings.
Definition: os0file.h:297
@ IGNORE_MISSING
Ignore failed reads of non-existent pages.
Definition: os0file.h:309
@ DO_NOT_WAKE
Do not to wake i/o-handler threads, but the caller will do the waking explicitly later,...
Definition: os0file.h:306
@ ROW_LOG
Row log used in online DDL.
Definition: os0file.h:322
@ LOG
Log file request.
Definition: os0file.h:294
@ DISABLE_PUNCH_HOLE_OPTIMISATION
We optimise cases where punch hole is not done if the compressed length of the page is the same as th...
Definition: os0file.h:327
@ NO_COMPRESSION
Force raw read, do not try to compress/decompress.
Definition: os0file.h:319
@ WRITE
Definition: os0file.h:283
@ READ
Definition: os0file.h:282
@ DATA_FILE
Enumerations below can be ORed to READ/WRITE above.
Definition: os0file.h:291
@ PUNCH_HOLE
Use punch hole if available, only makes sense if compression algorithm != NONE.
Definition: os0file.h:313
void clear_punch_hole()
Clear the punch hole flag.
Definition: os0file.h:433
void disable_partial_io_warnings()
Disable partial read warnings.
Definition: os0file.h:389
const file::Block * get_encrypted_block() const noexcept
Get the encrypted block.
Definition: os0file.h:559
std::string to_string() const
Definition: os0file.h:536
uint32_t get_original_size() const
Returns original size of the IO to make.
Definition: os0file.h:446
bool operator==(const IORequest &rhs) const
Compare two requests.
Definition: os0file.h:461
void disable_compression()
Disable transformations.
Definition: os0file.h:492
bool punch_hole() const
Definition: os0file.h:395
IORequest()
Default constructor.
Definition: os0file.h:331
static bool is_punch_hole_supported()
Definition: os0file.h:520
static bool ignore_missing(int type)
Definition: os0file.h:361
void set_original_size(uint32_t original_size)
Definition: os0file.h:448
uint32_t m_block_size
Definition: os0file.h:565
bool ignore_missing() const
Definition: os0file.h:392
Compression m_compression
Compression algorithm.
Definition: os0file.h:571
void set_punch_hole()
Set the punch hole flag.
Definition: os0file.h:416
IORequest(int type)
Definition: os0file.h:344
Encryption & get_encryption_info() noexcept
Get a reference to the underlying encryption information.
Definition: os0file.h:547
uint32_t m_elen
The length of data in encrypted block.
Definition: os0file.h:580
bool is_write() const
Definition: os0file.h:369
bool validate() const
Definition: os0file.h:409
Encryption encryption_algorithm() const
Get the encryption algorithm.
Definition: os0file.h:496
bool is_row_log() const
Definition: os0file.h:375
void set_encrypted_block(const file::Block *eblock) noexcept
Set the encrypted block to the given value.
Definition: os0file.h:553
bool is_compressed() const
Definition: os0file.h:482
bool is_wake() const
Definition: os0file.h:380
void clear_compressed()
Clear all compression related flags.
Definition: os0file.h:453
void disable_punch_hole_optimisation()
Set the force punch hole flag.
Definition: os0file.h:423
const file::Block * m_eblock
The encrypted block.
Definition: os0file.h:577
int m_type
Request type bit flags.
Definition: os0file.h:568
bool is_read() const
Definition: os0file.h:366
bool is_log() const
Definition: os0file.h:372
Encryption m_encryption
Encryption algorithm.
Definition: os0file.h:574
Helper class for doing synchronous file IO.
Definition: os0file.h:1887
~SyncFileIO()=default
Destructor.
os_file_t m_fh
Open file handle.
Definition: os0file.h:1933
dberr_t execute_with_retry(const IORequest &request, const size_t max_retries=NUM_RETRIES_ON_PARTIAL_IO)
Do the read/write with retry.
Definition: os0file.cc:1992
const size_t m_orig_bytes
The total number of bytes to be read/written.
Definition: os0file.h:1945
SyncFileIO(os_file_t fh, void *buf, ulint n, os_offset_t offset)
Constructor.
Definition: os0file.h:1894
ssize_t m_n
Number of bytes to read/write.
Definition: os0file.h:1939
os_offset_t m_offset
Offset from where to read/write.
Definition: os0file.h:1942
ssize_t execute(const IORequest &request)
Do the read/write.
Definition: os0file.cc:2022
void * m_buf
Buffer to read/write.
Definition: os0file.h:1936
void advance(ssize_t n_bytes)
Move the read/write offset up to where the partial IO succeeded.
Definition: os0file.h:1921
dberr_t
Definition: db0err.h:38
struct PSI_file PSI_file
Definition: psi_file_bits.h:54
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:176
#define free(A)
Definition: lexyy.cc:915
#define DBUG_EXECUTE_IF(keyword, a1)
Definition: my_dbug.h:170
unsigned char uchar
Definition: my_inttypes.h:51
Common #defines and includes for file and socket I/O.
#define FN_REFLEN_SE
Definition: my_io.h:83
static char * path
Definition: mysqldump.cc:148
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1065
Definition: buf0block_hint.cc:29
constexpr value_type read_only
Definition: classic_protocol_constants.h:212
const std::string FILE("FILE")
std::string file_name(Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0pre_8_0_30.cc:93
static mysql_service_status_t flush(reference_caching_cache cache) noexcept
Definition: component.cc:113
mode
Definition: file_handle.h:59
constexpr size_t INNODB_CACHE_LINE_SIZE
CPU cache line size.
Definition: ut0cpu_cache.h:40
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2869
static int exists(node_address *name, node_list const *nodes, u_int with_uid)
Definition: node_list.cc:105
Macros for using atomics.
Page encryption infrastructure.
static const ulint OS_FILE_READ_ONLY
Definition: os0file.h:218
void os_aio_simulated_wake_handler_threads()
Wakes up simulated aio i/o-handler threads if they have something to do.
Definition: os0file.cc:6901
bool os_file_status(const char *path, bool *exists, os_file_type_t *type)
Check the existence and type of a given path.
Definition: os0file.cc:5871
constexpr uint32_t OS_FILE_MAX_PATH
Definition: os0file.h:662
os_file_create_t
Options for os_file_create_func.
Definition: os0file.h:198
@ OS_FILE_ON_ERROR_SILENT
don't print diagnostic messages to the log unless it is a fatal error, this flag is only used if ON_E...
Definition: os0file.h:212
@ OS_FILE_CREATE
to create new file (if exists, error)
Definition: os0file.h:201
@ OS_FILE_ON_ERROR_NO_EXIT
Flags that can be combined with the above values.
Definition: os0file.h:211
@ OS_FILE_OPEN_RETRY
open with retry
Definition: os0file.h:206
@ OS_FILE_CREATE_PATH
to create the directories
Definition: os0file.h:205
@ OS_FILE_OPEN
to open an existing file (if doesn't exist, error)
Definition: os0file.h:199
@ OS_FILE_OPEN_RAW
to open a raw device or disk partition
Definition: os0file.h:203
static const ulint OS_AIO_N_PENDING_IOS_PER_THREAD
Win NT does not allow more than 64.
Definition: os0file.h:602
static bool pfs_os_file_rename_func(mysql_pfs_key_t key, const char *oldpath, const char *newpath, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_rename(), not directly this function!...
bool os_file_scan_directory(const char *path, os_dir_cbk_t scan_cbk, bool is_drop)
This function scans the contents of a directory and invokes the callback for each entry.
Definition: os0file.cc:3104
ulint os_n_file_reads
Definition: os0file.cc:810
bool os_is_o_direct_supported()
Determine if O_DIRECT is supported.
Definition: os0file.cc:128
static const ulint OS_BUFFERED_FILE
Definition: os0file.h:236
void os_free_block(file::Block *block) noexcept
Free a page after sync IO.
Definition: os0file.cc:1014
dberr_t os_file_create_subdirs_if_needed(const char *path)
Create all missing subdirectories along the given path.
Definition: os0file.cc:1801
bool os_file_create_directory(const char *pathname, bool fail_if_exists)
This function attempts to create a directory named pathname.
Definition: os0file.cc:3085
static bool pfs_os_file_flush_func(pfs_os_file_t file, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_flush(), not directly this function!...
bool os_aio_init(ulint n_readers, ulint n_writers)
Initializes the asynchronous io system.
Definition: os0file.cc:6518
static const ulint OS_FILE_AIO_INTERRUPTED
Definition: os0file.h:260
os_file_type_t
Definition: os0file.h:628
@ OS_FILE_TYPE_BLOCK
Block device.
Definition: os0file.h:654
@ OS_FILE_PERMISSION_ERROR
stat() failed with EACCESS
Definition: os0file.h:636
@ OS_FILE_TYPE_MISSING
File doesn't exist.
Definition: os0file.h:639
@ OS_FILE_TYPE_NAME_TOO_LONG
stat() failed, with ENAMETOOLONG
Definition: os0file.h:633
@ OS_FILE_TYPE_UNKNOWN
File exists but type is unknown.
Definition: os0file.h:642
@ OS_FILE_TYPE_DIR
Directory.
Definition: os0file.h:648
@ OS_FILE_TYPE_FAILED
Get status failed.
Definition: os0file.h:630
@ OS_FILE_TYPE_LINK
Symbolic link.
Definition: os0file.h:651
@ OS_FILE_TYPE_FILE
Ordinary file.
Definition: os0file.h:645
dberr_t os_file_read_func(IORequest &type, const char *file_name, os_file_t file, void *buf, os_offset_t offset, ulint n)
NOTE! Use the corresponding macro os_file_read_first_page(), not directly this function!...
Definition: os0file.cc:5668
AIO_mode
Modes for aio operations.
Definition: os0file.h:605
@ SYNC
Asynchronous i/o where the calling thread will itself wait for the i/o to complete,...
@ IBUF
Asynchronous i/o for ibuf pages or ibuf bitmap pages.
static const ulint OS_FILE_NORMAL
Definition: os0file.h:226
ulint os_n_fsyncs
Definition: os0file.cc:813
mysql_pfs_key_t innodb_data_file_key
mysql_pfs_key_t innodb_dblwr_file_key
byte * os_file_compress_page(Compression compression, ulint block_size, byte *src, ulint src_len, byte *dst, ulint *dst_len)
Compress a data page.
Definition: os0file.cc:1290
os_fd_t os_file_t
File handle.
Definition: os0file.h:152
bool os_file_close_func(os_file_t file)
NOTE! Use the corresponding macro os_file_close(), not directly this function! Closes a file handle.
Definition: os0file.cc:3439
static const ulint OS_FILE_AIO
Definition: os0file.h:225
void os_file_read_string(FILE *file, char *str, ulint size)
Rewind file to its start, read at most size - 1 bytes from it to str, and NUL-terminate str.
Definition: os0file.cc:1591
static const ulint OS_DATA_FILE
Types for file create.
Definition: os0file.h:230
constexpr uint32_t OS_FILE_LOG_BLOCK_SIZE
The next value should be smaller or equal to the smallest sector size used on any disk.
Definition: os0file.h:195
static bool pfs_os_file_delete_func(mysql_pfs_key_t key, const char *name, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_delete(), not directly this function!...
void os_aio_free()
Frees the asynchronous io system.
Definition: os0file.cc:6540
mysql_pfs_key_t innodb_log_file_key
bool os_file_set_size(const char *name, pfs_os_file_t file, os_offset_t offset, os_offset_t size, bool flush)
Write the specified number of zeros to a file from specific offset.
Definition: os0file.cc:5517
static const ulint OS_FILE_ERROR_NOT_SPECIFIED
Definition: os0file.h:258
std::function< void(const char *path, const char *name)> os_dir_cbk_t
Callback function type to be implemented by caller.
Definition: os0file.h:706
static const ulint OS_LOG_FILE
Definition: os0file.h:231
std::atomic< ulint > os_n_pending_reads
Number of pending read operations.
Definition: os0file.cc:821
static constexpr os_fd_t OS_FD_CLOSED
Definition: os0file.h:116
bool os_is_sparse_file_supported(pfs_os_file_t fh)
Check if the file system supports sparse files.
Definition: os0file.cc:5905
dberr_t os_file_read_no_error_handling_func(IORequest &type, const char *file_name, os_file_t file, void *buf, os_offset_t offset, ulint n, ulint *o)
NOTE! Use the corresponding macro os_file_read_no_error_handling(), not directly this function!...
Definition: os0file.cc:5833
pfs_os_file_t os_file_create_func(const char *name, ulint create_mode, ulint purpose, ulint type, bool read_only, bool *success)
NOTE! Use the corresponding macro os_file_create(), not directly this function! Opens an existing fil...
Definition: os0file.cc:3138
dberr_t os_file_punch_hole(os_file_t fh, os_offset_t off, os_offset_t len)
Free storage space associated with a section of the file.
Definition: os0file.cc:5892
void os_file_set_umask(ulint umask)
Set the file create umask.
Definition: os0file.cc:7908
int os_fd_t
Raw file handle.
Definition: os0file.h:114
void os_create_block_cache()
Creates and initializes block_cache.
Definition: os0file.cc:6476
static bool pfs_os_file_delete_if_exists_func(mysql_pfs_key_t key, const char *name, bool *exist, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_delete_if_exists(), not directly this function!...
pfs_os_file_t os_file_create_simple_no_error_handling_func(const char *name, ulint create_mode, ulint access_type, bool read_only, bool *success)
NOTE! Use the corresponding macro os_file_create_simple_no_error_handling(), not directly this functi...
Definition: os0file.cc:3296
bool os_file_seek(const char *pathname, os_file_t file, os_offset_t offset)
Set read/write position of a file handle to specific offset.
Definition: os0file.cc:5631
mysql_pfs_key_t innodb_arch_file_key
static const ulint OS_FILE_PATH_ERROR
Definition: os0file.h:252
void os_aio_wait_until_no_pending_writes()
Waits until there are no pending writes in os_aio_write_array.
Definition: os0file.cc:6594
static const ulint OS_DBLWR_FILE
Doublewrite files.
Definition: os0file.h:242
static dberr_t pfs_os_file_read_no_error_handling_int_fd_func(IORequest &type, const char *file_name, int file, void *buf, os_offset_t offset, ulint n, ulint *o, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_read_no_error_handling_int_fd(), not directly this f...
bool os_file_set_size_fast(const char *name, pfs_os_file_t file, os_offset_t offset, os_offset_t size, bool flush)
Allocate a block to file using fallocate from the given offset if fallocate is supported.
Definition: os0file.cc:5486
static const ulint OS_FILE_NOT_FOUND
Error codes from os_file_get_last_error.
Definition: os0file.h:249
static dberr_t pfs_os_file_write_func(IORequest &type, const char *name, pfs_os_file_t file, const void *buf, os_offset_t offset, ulint n, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_write(), not directly this function!...
os_file_t os_file_create_simple_func(const char *name, ulint create_mode, ulint access_type, bool read_only, bool *success)
NOTE! Use the corresponding macro os_file_create_simple(), not directly this function!...
Definition: os0file.cc:2994
dberr_t os_aio_func(IORequest &type, AIO_mode aio_mode, const char *name, pfs_os_file_t file, void *buf, os_offset_t offset, ulint n, bool read_only, fil_node_t *m1, void *m2)
NOTE! Use the corresponding macro os_aio(), not directly this function! Requests an asynchronous i/o ...
Definition: os0file.cc:7076
static const ulint OS_FILE_SHARING_VIOLATION
Definition: os0file.h:257
std::atomic< ulint > os_n_pending_writes
Number of pending write operations.
Definition: os0file.cc:819
static const ulint OS_FILE_READ_ALLOW_DELETE
Used by MySQLBackup.
Definition: os0file.h:222
unsigned long long os_fsync_threshold
Definition: os0file.cc:105
void os_aio_wake_all_threads_at_shutdown()
Wakes up all async i/o threads so that they know to exit themselves in shutdown.
Definition: os0file.cc:6564
static pfs_os_file_t pfs_os_file_create_func(mysql_pfs_key_t key, const char *name, ulint create_mode, ulint purpose, ulint type, bool read_only, bool *success, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_create(), not directly this function!...
static const ulint OS_FILE_NAME_TOO_LONG
Definition: os0file.h:263
mysql_pfs_key_t innodb_tablespace_open_file_key
static dberr_t pfs_os_file_read_func(IORequest &type, const char *file_name, pfs_os_file_t file, void *buf, os_offset_t offset, ulint n, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_read(), not directly this function!...
dberr_t os_file_write_retry(IORequest &type, const char *name, pfs_os_file_t file, const void *buf, os_offset_t offset, ulint n)
This is a wrapper function for the os_file_write() function call.
Definition: os0file.cc:7934
static const ulint OS_FILE_ERROR_MAX
Definition: os0file.h:266
static dberr_t pfs_os_aio_func(IORequest &type, AIO_mode mode, const char *name, pfs_os_file_t file, void *buf, os_offset_t offset, ulint n, bool read_only, fil_node_t *m1, void *m2, ut::Location location)
NOTE! Please use the corresponding macro os_aio(), not directly this function! Performance schema wra...
bool os_file_set_eof(FILE *file)
Truncates a file at its current position.
Definition: os0file.cc:3594
static dberr_t pfs_os_file_copy_func(pfs_os_file_t src, os_offset_t src_offset, pfs_os_file_t dest, os_offset_t dest_offset, uint size, ut::Location src_location)
copy data from one file to another file.
static dberr_t pfs_os_file_write_int_fd_func(IORequest &type, const char *name, int file, const void *buf, os_offset_t offset, ulint n, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_write(), not directly this function!...
bool os_file_exists(const char *path)
Check the existence and usefulness of a given path.
Definition: os0file.cc:5879
bool os_file_flush_func(os_file_t file)
NOTE! Use the corresponding macro os_file_flush(), not directly this function! Flushes the write buff...
Definition: os0file.cc:2956
void os_file_set_nocache(int fd, const char *file_name, const char *operation_name)
Tries to disable OS caching on an opened file descriptor.
Definition: os0file.cc:5440
static const ulint OS_FILE_ALREADY_EXISTS
Definition: os0file.h:251
static const ulint OS_FILE_DISK_FULL
Definition: os0file.h:250
bool os_file_rename_func(const char *oldpath, const char *newpath)
NOTE! Use the corresponding macro os_file_rename(), not directly this function! Renames a file (can a...
Definition: os0file.cc:3410
void os_aio_print(FILE *file)
Prints info of the aio arrays.
Definition: os0file.cc:7766
static bool pfs_os_file_close_func(pfs_os_file_t file, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_close(), not directly this function!...
static const ulint OS_CLONE_LOG_FILE
Definition: os0file.h:239
static const ulint OS_REDO_LOG_ARCHIVE_FILE
Redo log archive file.
Definition: os0file.h:245
bool os_has_said_disk_full
Definition: os0file.cc:824
byte * os_block_get_frame(const file::Block *block) noexcept
Get the sector aligned frame pointer.
Definition: os0file.cc:967
ulint os_n_file_writes
Definition: os0file.cc:812
dberr_t os_aio_handler(ulint segment, fil_node_t **m1, void **m2, IORequest *request)
Waits for an AIO operation to complete.
Definition: os0file.cc:6042
constexpr size_t NUM_RETRIES_ON_PARTIAL_IO
Number of retries for partial I/O's.
Definition: os0file.h:75
dberr_t os_file_read_first_page_func(IORequest &type, const char *file_name, os_file_t file, void *buf, ulint n)
NOTE! Use the corresponding macro os_file_read_first_page(), not directly this function!...
Definition: os0file.cc:5686
dberr_t os_file_get_status(const char *path, os_file_stat_t *stat_info, bool check_rw_perm, bool read_only)
This function returns information about the specified file.
Definition: os0file.cc:5939
mysql_pfs_key_t innodb_temp_file_key
bool os_aio_all_slots_free()
Checks that all slots in the system have been freed, that is, there are no pending io operations.
Definition: os0file.cc:7858
bool os_file_delete_func(const char *name)
Deletes a file.
Definition: os0file.cc:3391
static const ulint OS_FILE_READ_WRITE
Definition: os0file.h:219
static const ulint OS_FILE_ACCESS_VIOLATION
Definition: os0file.h:262
dberr_t os_get_free_space(const char *path, uint64_t &free_space)
Get available free space on disk.
Definition: os0file.cc:5920
file::Block * os_file_encrypt_page(const IORequest &type, void *&buf, ulint n)
Encrypt a page content when write it to disk.
Definition: os0file.cc:1915
void os_aio_refresh_stats()
Refreshes the statistics used to print per-second averages.
Definition: os0file.cc:7839
os_file_size_t os_file_get_size(const char *filename)
Gets a file size.
Definition: os0file.cc:3463
static const ulint OS_FILE_AIO_RESOURCES_RESERVED
wait for OS aio resources to become available again
Definition: os0file.h:255
static const ulint OS_CLONE_DATA_FILE
Definition: os0file.h:238
ulint os_file_get_last_error(bool report_all_errors)
Retrieves the last error number if an error occurs in a file io function.
Definition: os0file.cc:5319
static const ulint OS_FILE_OPERATION_ABORTED
Definition: os0file.h:261
void os_aio_simulated_put_read_threads_to_sleep()
This function can be called if one wants to post a batch of reads and prefers an i/o-handler thread t...
Definition: os0file.cc:3612
file::Block * os_alloc_block() noexcept
Allocate a page for sync IO.
Definition: os0file.cc:971
bool os_file_truncate(const char *pathname, pfs_os_file_t file, os_offset_t size)
Truncates a file to a specified size in bytes.
Definition: os0file.cc:5609
dberr_t os_file_decompress_page(bool dblwr_read, byte *src, byte *dst, ulint dst_len)
Decompress the page data contents.
Definition: file.cc:276
os_fd_t innobase_mysql_tmpfile(const char *path)
Creates a temporary file in the location specified by the parameter path.
Definition: ha_innodb.cc:2490
dberr_t os_file_write_zeros(pfs_os_file_t file, const char *name, ulint page_size, os_offset_t start, ulint len)
Fill the pages with NULs.
Definition: os0file.cc:5967
static const ulint OS_FILE_INSUFFICIENT_RESOURCE
Definition: os0file.h:259
static constexpr os_fd_t OS_FILE_CLOSED
Definition: os0file.h:154
static pfs_os_file_t pfs_os_file_create_simple_func(mysql_pfs_key_t key, const char *name, ulint create_mode, ulint access_type, bool read_only, bool *success, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_create_simple(), not directly this function!...
FILE * os_file_create_tmpfile()
Create a temporary file.
Definition: os0file.cc:1564
bool os_file_check_mode(const char *name, bool read_only)
Check if a file can be opened in read-write mode.
Definition: os0file.cc:6000
static dberr_t pfs_os_file_read_first_page_func(IORequest &type, const char *file_name, pfs_os_file_t file, void *buf, ulint n, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_read_first_page(), not directly this function!...
void os_aio_print_pending_io(FILE *file)
Prints all pending IO.
Definition: os0file.cc:7900
mysql_pfs_key_t innodb_clone_file_key
dberr_t os_file_copy_func(os_file_t src_file, os_offset_t src_offset, os_file_t dest_file, os_offset_t dest_offset, uint size)
Copy data from one file to another file.
Definition: os0file.cc:5822
char * innobase_mysql_tmpdir()
return any of the tmpdir path
Definition: ha_innodb.cc:2488
uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:86
ulint os_file_get_umask()
Get the file create umask.
Definition: os0file.cc:7912
static const ulint OS_FILE_TOO_MANY_OPENED
Definition: os0file.h:264
static pfs_os_file_t pfs_os_file_create_simple_no_error_handling_func(mysql_pfs_key_t key, const char *name, ulint create_mode, ulint access_type, bool read_only, bool *success, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_create_simple_no_error_handling(),...
dberr_t os_file_write_func(IORequest &type, const char *name, os_file_t file, const void *buf, os_offset_t offset, ulint n)
NOTE! Use the corresponding macro os_file_write(), not directly this function! Requests a synchronous...
Definition: os0file.cc:5854
void os_aio_start_threads()
Starts one thread for each segment created in os_aio_init.
Definition: os0file.cc:6537
ulint os_file_original_page_size(const byte *buf)
If it is a compressed page return the original page data + footer size.
Definition: os0file.cc:1126
ulint os_file_compressed_page_size(const byte *buf)
If it is a compressed page return the compressed page data + footer size.
Definition: os0file.cc:1110
static dberr_t pfs_os_file_read_no_error_handling_func(IORequest &type, const char *file_name, pfs_os_file_t file, void *buf, os_offset_t offset, ulint n, ulint *o, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_read_no_error_handling(), not directly this function...
bool os_file_delete_if_exists_func(const char *name, bool *exist)
Deletes a file if it exists.
Definition: os0file.cc:3356
The interface to the operating system file io.
const char * filename
Definition: pfs_example_component_population.cc:66
required string key
Definition: replication_asynchronous_connection_failover.proto:59
required string type
Definition: replication_group_member_actions.proto:33
case opt name
Definition: sslopt-case.h:32
NOTE: The functions in this file should only use functions from other files in library.
Compression algorithm.
Definition: file.h:50
Type
Algorithm types supported.
Definition: file.h:52
@ NONE
No compression.
Definition: file.h:58
Type m_type
Compression type.
Definition: file.h:196
std::string to_string() const
Definition: file.h:104
Directory names for the depth first directory scan.
Definition: os0file.h:1810
Entry(const Path &path, size_t depth)
Constructor.
Definition: os0file.h:1815
Path m_path
Path to the directory.
Definition: os0file.h:1818
size_t m_depth
Relative depth of m_path.
Definition: os0file.h:1821
File node of a tablespace or the log data space.
Definition: fil0fil.h:150
Blocks for doing IO, used in the transparent compression and encryption code.
Definition: os0file.h:91
Block() noexcept
Default constructor.
Definition: os0file.h:93
static void free(file::Block *obj) noexcept
Free the given memory block.
Definition: os0file.h:1850
byte * m_ptr
Pointer to the memory block.
Definition: os0file.h:100
size_t m_size
Size of the data in memory block.
Definition: os0file.h:103
byte pad[ut::INNODB_CACHE_LINE_SIZE]
This padding is needed to avoid false sharing.
Definition: os0file.h:108
std::atomic< bool > m_in_use
Definition: os0file.h:109
Define for performance schema registration key.
Definition: sync0sync.h:50
Sparse file size information.
Definition: os0file.h:592
os_offset_t m_alloc_size
If it is a sparse file then this is the number of bytes actually allocated for the file.
Definition: os0file.h:598
os_offset_t m_total_size
Total size of file in bytes.
Definition: os0file.h:594
Struct used in fetching information of a file in a directory.
Definition: os0file.h:667
uint32_t block_size
Block size to use for IO in bytes.
Definition: os0file.h:673
time_t ctime
creation time
Definition: os0file.h:675
char name[OS_FILE_MAX_PATH]
path to a file
Definition: os0file.h:668
time_t atime
access time
Definition: os0file.h:677
bool rw_perm
true if can be opened in read-write mode.
Definition: os0file.h:678
os_file_type_t type
file type
Definition: os0file.h:669
os_offset_t size
file size in bytes
Definition: os0file.h:670
os_offset_t alloc_size
Allocated size for sparse files in bytes.
Definition: os0file.h:671
time_t mtime
modification time
Definition: os0file.h:676
Common file descriptor for file IO instrumentation with PFS on windows and other platforms.
Definition: os0file.h:175
struct PSI_file * m_psi
Definition: os0file.h:177
os_file_t m_file
Definition: os0file.h:185
Include file for Sun RPC to compile out of the box.
static const size_t UNIV_SECTOR_SIZE
Definition: univ.i:638
unsigned long int ulint
Definition: univ.i:405
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:104
#define HANDLE
Definition: violite.h:158
int n
Definition: xcom_base.cc:508