55#include <sys/statvfs.h>
68#define OS_FILE_PREFIX "#"
121typedef HANDLE os_file_dir_t;
124#define UNIV_NON_BUFFERED_IO
134#define OS_FILE_FROM_FD(fd) (HANDLE) _get_osfhandle(fd)
139#define OS_FD_FROM_FILE(file) _open_osfhandle((intptr_t)file, _O_RDONLY)
144#define OS_FILE_CLOSE_FD(fd) _close(fd)
156#define OS_FILE_FROM_FD(fd) fd
161#define OS_FD_FROM_FILE(file) file
166#define OS_FILE_CLOSE_FD(fd) (os_file_close(fd) ? 0 : OS_FD_CLOSED)
543#if defined(HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE) || defined(_WIN32)
564#define PRINT_MASK_ELEMENT(flag) \
565 if ((m_type & Type::flag) == Type::flag) { \
580#undef PRINT_MASK_ELEMENT
633 static_cast<uint16_t
>(b));
638 static_cast<uint16_t
>(b));
714 "(FN_REFLEN_SE < OS_FILE_MAX_PATH)");
730#ifndef UNIV_HOTBACKUP
801 const
char *operation_name,
802 bool on_error_silent = false);
868#define register_pfs_file_open_begin(state, locker, key, op, name, \
871 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
872 op, name, &locker); \
873 if (locker != nullptr) { \
874 PSI_FILE_CALL(start_file_open_wait) \
875 (locker, src_location.filename, static_cast<uint>(src_location.line)); \
879#define register_pfs_file_open_end(locker, file, result) \
881 if (locker != nullptr) { \
882 file.m_psi = PSI_FILE_CALL(end_file_open_wait)(locker, result); \
886#define register_pfs_file_rename_begin(state, locker, key, op, from, to, \
889 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
890 op, from, &locker); \
891 if (locker != nullptr) { \
892 PSI_FILE_CALL(start_file_rename_wait) \
893 (locker, (size_t)0, from, to, src_location.filename, \
894 static_cast<uint>(src_location.line)); \
898#define register_pfs_file_rename_end(locker, from, to, result) \
900 if (locker != nullptr) { \
901 PSI_FILE_CALL(end_file_rename_wait)(locker, from, to, result); \
905#define register_pfs_file_close_begin(state, locker, key, op, name, \
908 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
909 op, name, &locker); \
910 if (locker != nullptr) { \
911 PSI_FILE_CALL(start_file_close_wait) \
912 (locker, src_location.filename, static_cast<uint>(src_location.line)); \
916#define register_pfs_file_close_end(locker, result) \
918 if (locker != nullptr) { \
919 PSI_FILE_CALL(end_file_close_wait)(locker, result); \
923#define register_pfs_file_io_begin(state, locker, file, count, op, \
927 PSI_FILE_CALL(get_thread_file_stream_locker)(state, file.m_psi, op); \
928 if (locker != nullptr) { \
929 PSI_FILE_CALL(start_file_wait) \
930 (locker, count, src_location.filename, \
931 static_cast<uint>(src_location.line)); \
935#define register_pfs_file_io_end(locker, count) \
937 if (locker != nullptr) { \
938 PSI_FILE_CALL(end_file_wait)(locker, count); \
958#define os_file_create(key, name, create, purpose, read_only, success) \
959 pfs_os_file_create_func(key, name, create, purpose, read_only, success, \
963#define os_file_create_simple_no_error_handling(key, name, create_mode, \
965 pfs_os_file_create_simple_no_error_handling_func( \
966 key, name, create_mode, access, os_innodb_umask_default, success, \
969#define os_file_create_simple_no_error_handling_with_umask( \
970 key, name, create_mode, access, umask, success) \
971 pfs_os_file_create_simple_no_error_handling_func( \
972 key, name, create_mode, access, umask, success, UT_LOCATION_HERE)
974#define os_file_create_simple_no_error_handling(key, name, create_mode, \
976 pfs_os_file_create_simple_no_error_handling_func( \
977 key, name, create_mode, access, success, UT_LOCATION_HERE)
980#define os_file_close_pfs(file) pfs_os_file_close_func(file, UT_LOCATION_HERE)
982#define os_aio(type, mode, name, file, buf, offset, n, callback) \
983 pfs_os_aio_func(type, mode, name, file, buf, offset, n, callback, \
986#define os_file_read_pfs(type, file_name, file, buf, offset, n) \
987 pfs_os_file_read_func(type, file_name, file, buf, offset, n, UT_LOCATION_HERE)
989#define os_file_read_first_page_pfs(type, file_name, file, buf, n_pages) \
990 pfs_os_file_read_first_page_func(type, file_name, file, buf, n_pages, \
993#define os_file_copy_pfs(src, src_offset, dest, dest_offset, size) \
994 pfs_os_file_copy_func(src, src_offset, dest, dest_offset, size, \
997#define os_file_read_no_error_handling_pfs(type, file_name, file, buf, offset, \
999 pfs_os_file_read_no_error_handling_func(type, file_name, file, buf, offset, \
1000 n, o, UT_LOCATION_HERE)
1002#define os_file_read_no_error_handling_int_fd(type, file_name, file, buf, \
1004 pfs_os_file_read_no_error_handling_int_fd_func( \
1005 type, file_name, file, buf, offset, n, o, UT_LOCATION_HERE)
1007#define os_file_write_pfs(type, name, file, buf, offset, n) \
1008 pfs_os_file_write_func(type, name, file, buf, offset, n, UT_LOCATION_HERE)
1010#define os_file_write_int_fd(type, name, file, buf, offset, n) \
1011 pfs_os_file_write_int_fd_func(type, name, file, buf, offset, n, \
1014#define os_file_flush_pfs(file) pfs_os_file_flush_func(file, UT_LOCATION_HERE)
1016#define os_file_rename(key, oldpath, newpath) \
1017 pfs_os_file_rename_func(key, oldpath, newpath, UT_LOCATION_HERE)
1019#define os_file_delete(key, name) \
1020 pfs_os_file_delete_func(key, name, UT_LOCATION_HERE)
1022#define os_file_delete_if_exists(key, name, exist) \
1023 pfs_os_file_delete_if_exists_func(key, name, exist, UT_LOCATION_HERE)
1201 std::function<
void(
dberr_t)> callback,
1264 const char *oldpath,
1265 const char *newpath,
1301#define os_file_create(key, name, create, purpose, read_only, success) \
1302 os_file_create_func(name, create, purpose, read_only, success)
1306#define os_file_create_simple_no_error_handling(key, name, create_mode, \
1308 os_file_create_simple_no_error_handling_func( \
1309 name, create_mode, access, os_innodb_umask_default, success)
1311#define os_file_create_simple_no_error_handling_with_umask( \
1312 key, name, create_mode, access, umask, success) \
1313 os_file_create_simple_no_error_handling_func(name, create_mode, access, \
1318#define os_file_create_simple_no_error_handling(key, name, create_mode, \
1320 os_file_create_simple_no_error_handling_func(name, create_mode, access, \
1325#define os_file_close_pfs(file) os_file_close_func(file)
1327#define os_aio(type, mode, name, file, buf, offset, n, callback) \
1328 os_aio_func(type, mode, name, file, buf, offset, n, callback)
1330#define os_file_read_pfs(type, file_name, file, buf, offset, n) \
1331 os_file_read_func(type, file_name, file, buf, offset, n)
1333#define os_file_read_first_page_pfs(type, file_name, file, buf, n_pages) \
1334 os_file_read_first_page_func(type, file_name, file, buf, n_pages)
1336#define os_file_copy_pfs(src, src_offset, dest, dest_offset, size) \
1337 os_file_copy_func(src, src_offset, dest, dest_offset, size)
1339#define os_file_read_no_error_handling_pfs(type, file_name, file, buf, offset, \
1341 os_file_read_no_error_handling_func(type, file_name, file, buf, offset, n, o)
1343#define os_file_read_no_error_handling_int_fd(type, file_name, file, buf, \
1345 os_file_read_no_error_handling_func(type, file_name, OS_FILE_FROM_FD(file), \
1348#define os_file_write_pfs(type, name, file, buf, offset, n) \
1349 os_file_write_func(type, name, file, buf, offset, n)
1351#define os_file_write_int_fd(type, name, file, buf, offset, n) \
1352 os_file_write_func(type, name, OS_FILE_FROM_FD(file), buf, offset, n)
1354#define os_file_flush_pfs(file) os_file_flush_func(file)
1356#define os_file_rename(key, oldpath, newpath) \
1357 os_file_rename_func(oldpath, newpath)
1359#define os_file_delete(key, name) os_file_delete_func(name)
1361#define os_file_delete_if_exists(key, name, exist) \
1362 os_file_delete_if_exists_func(name, exist)
1367#define os_file_close(file) os_file_close_pfs(file)
1369#define os_file_close(file) os_file_close_pfs((file).m_file)
1373#define os_file_read(type, file_name, file, buf, offset, n) \
1374 os_file_read_pfs(type, file_name, file, buf, offset, n)
1376#define os_file_read(type, file_name, file, buf, offset, n) \
1377 os_file_read_pfs(type, file_name, (file).m_file, buf, offset, n)
1381#define os_file_read_first_page(type, file_name, file, buf, n_pages) \
1382 os_file_read_first_page_pfs(type, file_name, file, buf, n_pages)
1384#define os_file_read_first_page(type, file_name, file, buf, n_pages) \
1385 os_file_read_first_page_pfs(type, file_name, (file).m_file, buf, n_pages)
1389#define os_file_flush(file) os_file_flush_pfs(file)
1391#define os_file_flush(file) os_file_flush_pfs((file).m_file)
1395#define os_file_write(type, name, file, buf, offset, n) \
1396 os_file_write_pfs(type, name, file, buf, offset, n)
1398#define os_file_write(type, name, file, buf, offset, n) \
1399 os_file_write_pfs(type, name, (file).m_file, buf, offset, n)
1403#define os_file_copy(src, src_offset, dest, dest_offset, size) \
1404 os_file_copy_pfs(src, src_offset, dest, dest_offset, size)
1406#define os_file_copy(src, src_offset, dest, dest_offset, size) \
1407 os_file_copy_pfs(src.m_file, src_offset, (dest).m_file, dest_offset, size)
1411#define os_file_read_no_error_handling(type, file_name, file, buf, offset, n, \
1413 os_file_read_no_error_handling_pfs(type, file_name, file, buf, offset, n, o)
1415#define os_file_read_no_error_handling(type, file_name, file, buf, offset, n, \
1417 os_file_read_no_error_handling_pfs(type, file_name, (file).m_file, buf, \
1421#ifdef UNIV_HOTBACKUP
1640#ifdef UNIV_ENABLE_UNIT_TEST_GET_PARENT_DIR
1642void unit_test_os_file_get_parent_dir();
1645#ifdef UNIV_HOTBACKUP
1647void meb_free_block_cache();
1659#ifndef UNIV_HOTBACKUP
1702 std::function<
void(
dberr_t)> callback);
1745 std::function<
void(
dberr_t)> &callback,
1788 bool is_raw_device);
1807#ifndef UNIV_HOTBACKUP
1862 byte *dst,
ulint dst_len);
1873 ulint block_size,
byte *src,
1874 ulint src_len,
byte *dst,
1897 template <
typename F>
1898 static void walk(
const Path &basedir,
bool recursive,
F &&f) {
1900 walk_win32(basedir, recursive, [&](
const Path &
path,
size_t) { f(
path); });
1929 static void walk_win32(
const Path &basedir,
bool recursive,
Function &&f);
1995 m_n(static_cast<ssize_t>(
n)),
uint32_t page_no_t
Page number.
Definition: api0api.h:47
Class to scan the directory hierarchy using a depth first scan.
Definition: os0file.h:1884
std::string Path
Definition: os0file.h:1886
static bool is_directory(const Path &path)
Check if the path is a directory.
Definition: os0file.cc:7315
static void walk_posix(const Path &basedir, bool recursive, Function &&f)
Depth first traversal of the directory starting from basedir.
Definition: os0file.cc:3468
std::function< void(const Path &, size_t)> Function
Definition: os0file.h:1922
static void walk(const Path &basedir, bool recursive, F &&f)
Depth first traversal of the directory starting from basedir.
Definition: os0file.h:1898
Encryption algorithm.
Definition: os0enc.h:54
void set_initial_vector(const byte *iv)
Set initial vector.
Definition: os0enc.cc:1510
@ NONE
No encryption.
Definition: os0enc.h:60
void set_key(const byte *key)
Set encryption key.
Definition: os0enc.cc:1504
void set_key_length(ulint klen)
Set key length.
Definition: os0enc.cc:1508
static const char * to_string(Type type) noexcept
Convert to a "string".
Definition: os0enc.cc:218
void set_type(Type type)
Set encryption type.
Definition: os0enc.cc:1502
Type get_type() const
Get encryption type.
Definition: os0enc.cc:1500
Types for AIO operations.
Definition: os0file.h:262
void set_ibuf()
Definition: os0file.h:430
uint32_t m_original_size
Length of the original IO size.
Definition: os0file.h:613
bool is_punch_hole_optimisation_disabled() const
Definition: os0file.h:402
void compression_algorithm(Compression::Type type)
Set compression algorithm.
Definition: os0file.h:468
bool is_dblwr() const
Definition: os0file.h:532
bool is_encryption_requested() const
Definition: os0file.h:517
Compression compression_algorithm() const
Get the compression algorithm.
Definition: os0file.h:480
bool is_partial_io_warning_disabled() const
Definition: os0file.h:380
void block_size(ulint block_size)
Set the block size for IO.
Definition: os0file.h:443
void clear_encrypted()
Clear all encryption related flags.
Definition: os0file.h:523
void clear_do_not_wake()
Clear the do not wake flag.
Definition: os0file.h:433
bool is_compression_enabled() const
Definition: os0file.h:492
ulint block_size() const
Definition: os0file.h:439
bool is_punch_hole_requested() const
Definition: os0file.h:396
void clear_punch_hole()
Clear the punch hole flag.
Definition: os0file.h:436
void disable_partial_io_warnings()
Disable partial read warnings.
Definition: os0file.h:386
Type m_type
Request type bit flags.
Definition: os0file.h:598
std::string to_string() const
Definition: os0file.h:551
uint32_t get_original_size() const
Returns original size of the IO to make.
Definition: os0file.h:449
bool operator==(const IORequest &rhs) const
Compare two requests.
Definition: os0file.h:464
void disable_compression()
Disable transformations.
Definition: os0file.h:497
static bool is_punch_hole_supported()
Definition: os0file.h:537
void set_original_size(uint32_t original_size)
Definition: os0file.h:451
uint32_t m_block_size
Definition: os0file.h:595
bool ignore_missing() const
Definition: os0file.h:391
constexpr friend IORequest::Type operator~(const IORequest::Type type)
Definition: os0file.h:626
Compression m_compression
Compression algorithm.
Definition: os0file.h:601
bool is_compression_requested() const
Definition: os0file.h:485
constexpr friend IORequest::Type & operator|=(IORequest::Type &a, const IORequest::Type b)
Definition: os0file.h:640
void set_punch_hole()
Set the punch hole flag.
Definition: os0file.h:417
Encryption & get_encryption_info() noexcept
Get a reference to the underlying encryption information.
Definition: os0file.h:589
IORequest(Type type)
Definition: os0file.h:334
uint32_t m_elen
The length of data in encrypted block.
Definition: os0file.h:607
constexpr friend IORequest::Type operator&(const IORequest::Type a, const IORequest::Type b)
Definition: os0file.h:635
bool is_write() const
Definition: os0file.h:360
bool validate() const
Definition: os0file.h:410
Encryption encryption_algorithm() const
Get the encryption algorithm.
Definition: os0file.h:514
bool is_row_log() const
Definition: os0file.h:370
bool is_wake() const
Definition: os0file.h:375
constexpr friend IORequest::Type & operator&=(IORequest::Type &a, const IORequest::Type b)
Definition: os0file.h:644
void clear_compressed()
Clear all compression related flags.
Definition: os0file.h:456
void disable_punch_hole_optimisation()
Set the force punch hole flag.
Definition: os0file.h:424
void disable_write_transformations()
Disable transformations.
Definition: os0file.h:508
bool are_write_transformations_enabled() const
Definition: os0file.h:502
bool is_read() const
Definition: os0file.h:355
bool is_log() const
Definition: os0file.h:365
Type
Flags that can be used to specify the IORequest mode and additional options, to be used as bitmask ty...
Definition: os0file.h:266
@ IGNORE_MISSING
Ignore failed reads of non-existent pages.
@ DBLWR
Enumerations below can be ORed to READ/WRITE above.
@ DO_NOT_WAKE
Do not to wake i/o-handler threads, but the caller will do the waking explicitly later,...
@ PUNCH_HOLE
Use punch hole if available, only makes sense if compression algorithm != NONE.
@ NO_COMPRESSION
Force raw read, do not try to compress/decompress.
@ ROW_LOG
Row log used in online DDL.
@ 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...
@ IBUF
We want async ibuf requests to be performed on a separate IO queue as the default one might get satur...
@ DISABLE_PARTIAL_IO_WARNINGS
Disable partial read warnings.
@ NO_WRITE_TRANSFORMATIONS
Force raw write, do not try to compress or encrypt.
IORequest()=delete
Default constructor.
Encryption m_encryption
Encryption algorithm.
Definition: os0file.h:604
bool is_ibuf() const
Definition: os0file.h:350
Helper class for doing synchronous file IO.
Definition: os0file.h:1985
~SyncFileIO()=default
Destructor.
os_file_t m_fh
Open file handle.
Definition: os0file.h:2031
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:2001
const size_t m_orig_bytes
The total number of bytes to be read/written.
Definition: os0file.h:2043
SyncFileIO(os_file_t fh, void *buf, ulint n, os_offset_t offset)
Constructor.
Definition: os0file.h:1992
ssize_t m_n
Number of bytes to read/write.
Definition: os0file.h:2037
os_offset_t m_offset
Offset from where to read/write.
Definition: os0file.h:2040
ssize_t execute(const IORequest &request)
Do the read/write.
Definition: os0file.cc:2031
void * m_buf
Buffer to read/write.
Definition: os0file.h:2034
void advance(ssize_t n_bytes)
Move the read/write offset up to where the partial IO succeeded.
Definition: os0file.h:2019
Node of a tablespace encapsulating handle required for any IO operations on this node.
Definition: fil0fil.h:177
dberr_t
Definition: db0err.h:39
struct PSI_file PSI_file
Definition: psi_file_bits.h:55
#define F
Definition: jit_executor_value.cc:374
#define free(A)
Definition: lexyy.cc:915
#define MY_COMPILER_DIAGNOSTIC_PUSH()
save the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:277
#define MY_COMPILER_DIAGNOSTIC_POP()
restore the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:278
#define DBUG_EXECUTE_IF(keyword, a1)
Definition: my_dbug.h:171
unsigned char uchar
Definition: my_inttypes.h:52
Common #defines and includes for file and socket I/O.
#define FN_REFLEN_SE
Definition: my_io.h:88
static char * path
Definition: mysqldump.cc:151
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1077
Definition: buf0block_hint.cc:30
constexpr value_type read_only
Definition: classic_protocol_constants.h:213
const std::string FILE("FILE")
ulong n_pages
Number of pages per doublewrite thread/segment of the dblwr file.
Definition: buf0dblwr.cc:87
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
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:45
ValueType max(X &&first)
Definition: gtid.h:103
noexcept
The return type for any call_and_catch(f, args...) call where f(args...) returns Type.
Definition: call_and_catch.h:76
size_t size(const char *const c)
Definition: base64.h:46
static mysql_service_status_t flush(reference_caching_cache cache) noexcept
Definition: component.cc:114
mode
Definition: file_handle.h:61
constexpr size_t INNODB_CACHE_LINE_SIZE
CPU cache line size.
Definition: ut0cpu_cache.h:41
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2720
Macros for using atomics.
Page encryption infrastructure.
static const ulint OS_FILE_READ_ONLY
Definition: os0file.h:215
void os_aio_simulated_wake_handler_threads()
Wakes up simulated aio i/o-handler threads if they have something to do.
Definition: os0file.cc:6340
static dberr_t pfs_os_file_read_no_error_handling_func(IORequest &type, const char *file_name, pfs_os_file_t file, byte *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...
constexpr uint32_t OS_FILE_MAX_PATH
Definition: os0file.h:712
dberr_t os_file_fill_range_with_zeros(const char *name, pfs_os_file_t file, os_offset_t offset, os_offset_t length, bool flush, bool force_raw_writes)
Write the specified number of zeros to a file from specific offset, if the end offset is beyond the e...
Definition: os0file.cc:5111
os_file_create_t
Options for os_file_create_func.
Definition: os0file.h:195
@ 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:209
@ OS_FILE_CREATE
to create new file (if exists, error)
Definition: os0file.h:198
@ OS_FILE_ON_ERROR_NO_EXIT
Flags that can be combined with the above values.
Definition: os0file.h:208
@ OS_FILE_OPEN_RETRY
open with retry
Definition: os0file.h:203
@ OS_FILE_CREATE_PATH
to create the directories
Definition: os0file.h:202
@ OS_FILE_OPEN
to open an existing file (if doesn't exist, error)
Definition: os0file.h:196
@ OS_FILE_OPEN_RAW
to open a raw device or disk partition
Definition: os0file.h:200
static const ulint OS_AIO_N_PENDING_IOS_PER_THREAD
Win NT does not allow more than 64.
Definition: os0file.h:660
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:2964
ulint os_n_file_reads
Definition: os0file.cc:832
static dberr_t pfs_os_file_write_int_fd_func(IORequest &type, const char *name, int file, const byte *buf, os_offset_t offset, ulint n, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_write(), not directly this function!...
constexpr IORequest::Type & operator&=(IORequest::Type &a, const IORequest::Type b)
Definition: os0file.h:644
bool os_is_o_direct_supported()
Determine if O_DIRECT is supported.
Definition: os0file.cc:137
dberr_t os_file_read_first_page_func(IORequest &type, const char *file_name, os_file_t file, byte *buf, page_no_t n_pages)
NOTE! Use the corresponding macro os_file_read_first_page(), not directly this function!...
Definition: os0file.cc:5283
pfs_os_file_t os_file_create_simple_no_error_handling_func(const char *name, ulint create_mode, ulint access_type, mode_t umask, bool *success)
Clang on Windows warns about umask not found.
Definition: os0file.cc:3166
static const ulint OS_BUFFERED_FILE
Definition: os0file.h:230
bool os_file_is_missing(os_file_type_t type)
A helper method that usually is feed the file_type returned by the os_file_type() method.
Definition: os0file.cc:5478
void os_free_block(file::Block *block) noexcept
Free a page after sync IO.
Definition: os0file.cc:1048
dberr_t os_file_create_subdirs_if_needed(const char *path)
Create all missing subdirectories along the given path.
Definition: os0file.cc:1822
bool os_file_create_directory(const char *pathname, bool fail_if_exists)
This function attempts to create a directory named pathname.
Definition: os0file.cc:2941
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:5970
static dberr_t pfs_os_file_read_no_error_handling_int_fd_func(IORequest &type, const char *file_name, int file, byte *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...
dberr_t os_file_get_status(const char *path, os_file_stat_t *stat_info)
This function returns information about the specified file.
Definition: os0file.cc:5539
static const ulint OS_FILE_AIO_INTERRUPTED
Definition: os0file.h:249
os_file_type_t
Definition: os0file.h:678
@ OS_FILE_TYPE_BLOCK
Block device.
Definition: os0file.h:704
@ OS_FILE_PERMISSION_ERROR
stat() failed with EACCESS
Definition: os0file.h:686
@ OS_FILE_TYPE_MISSING
File doesn't exist.
Definition: os0file.h:689
@ OS_FILE_TYPE_NAME_TOO_LONG
stat() failed, with ENAMETOOLONG
Definition: os0file.h:683
@ OS_FILE_TYPE_UNKNOWN
File exists but type is unknown.
Definition: os0file.h:692
@ OS_FILE_TYPE_DIR
Directory.
Definition: os0file.h:698
@ OS_FILE_TYPE_FAILED
Get status failed.
Definition: os0file.h:680
@ OS_FILE_TYPE_LINK
Symbolic link.
Definition: os0file.h:701
@ OS_FILE_TYPE_FILE
Ordinary file.
Definition: os0file.h:695
AIO_mode
Modes for aio operations.
Definition: os0file.h:663
@ IBUF
Asynchronous i/o for ibuf pages or ibuf bitmap pages.
dberr_t os_file_write_retry(IORequest &type, const char *name, pfs_os_file_t file, const byte *buf, os_offset_t offset, ulint n)
This is a wrapper function for the os_file_write() function call.
Definition: os0file.cc:7330
ulint os_n_fsyncs
Definition: os0file.cc:835
mysql_pfs_key_t innodb_data_file_key
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, mode_t umask, bool *success, ut::Location src_location)
Clang on Windows warns about umask not found.
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:1315
os_fd_t os_file_t
File handle.
Definition: os0file.h:149
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:3305
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:1613
static const ulint OS_DATA_FILE
Types for file create.
Definition: os0file.h:223
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:192
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!...
constexpr IORequest::Type operator~(const IORequest::Type type)
Definition: os0file.h:626
void os_aio_free()
Frees the asynchronous io system.
Definition: os0file.cc:5986
mysql_pfs_key_t innodb_log_file_key
static dberr_t pfs_os_file_read_first_page_func(IORequest &type, const char *file_name, pfs_os_file_t file, byte *buf, page_no_t n_pages, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_read_first_page(), not directly this function!...
dberr_t os_aio_func(IORequest &type, AIO_mode aio_mode, const char *name, pfs_os_file_t file, byte *buf, os_offset_t offset, ulint n, std::function< void(dberr_t)> callback)
NOTE! Use the corresponding macro os_aio(), not directly this function! Requests an asynchronous i/o ...
Definition: os0file.cc:6511
static const ulint OS_FILE_ERROR_NOT_SPECIFIED
Definition: os0file.h:247
pfs_os_file_t os_file_create_func(const char *name, ulint create_mode, ulint purpose, bool read_only, bool *success)
NOTE! Use the corresponding macro os_file_create(), not directly this function! Opens an existing fil...
Definition: os0file.cc:2998
std::function< void(const char *path, const char *name)> os_dir_cbk_t
Callback function type to be implemented by caller.
Definition: os0file.h:753
void os_file_set_nocache(int fd, const char *file_name, const char *operation_name, bool on_error_silent=false)
Tries to disable OS caching on an opened file descriptor.
Definition: os0file.cc:5064
static const ulint OS_LOG_FILE
Definition: os0file.h:224
std::atomic< ulint > os_n_pending_reads
Number of pending read operations.
Definition: os0file.cc:843
static constexpr os_fd_t OS_FD_CLOSED
Definition: os0file.h:117
Access_permissions os_file_check_access(const char *path, bool is_raw_device)
This function checks if we have read and/or write permissions at the time of checking.
Definition: os0file.cc:5512
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:5487
int os_fd_t
Raw file handle.
Definition: os0file.h:115
void os_create_block_cache()
Creates and initializes block_cache.
Definition: os0file.cc:5933
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!...
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:5247
mysql_pfs_key_t innodb_arch_file_key
static const ulint OS_FILE_PATH_ERROR
Definition: os0file.h:241
void os_aio_wait_until_no_pending_writes()
Waits until there are no pending writes in os_aio_write_array.
Definition: os0file.cc:6040
static const ulint OS_DBLWR_FILE
Definition: os0file.h:233
static const ulint OS_FILE_NOT_FOUND
Error codes from os_file_get_and_log_last_error.
Definition: os0file.h:238
void os_file_log_last_error()
Logs the last error number if an OS error occurs in a file IO function.
Definition: os0file.cc:4949
void os_file_set_umask(mode_t umask)
Set the global file create umask.
Definition: os0file.cc:7304
dberr_t os_aio_handler(ulint segment, std::function< void(dberr_t)> &callback, IORequest *request)
Waits for an AIO operation to complete.
Definition: os0file.cc:5604
static const ulint OS_FILE_SHARING_VIOLATION
Definition: os0file.h:246
static pfs_os_file_t pfs_os_file_create_func(mysql_pfs_key_t key, const char *name, ulint create_mode, ulint purpose, bool read_only, bool *success, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_create(), not directly this function!...
std::atomic< ulint > os_n_pending_writes
Number of pending write operations.
Definition: os0file.cc:841
static dberr_t pfs_os_file_write_func(IORequest &type, const char *name, pfs_os_file_t file, const byte *buf, os_offset_t offset, ulint n, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_write(), not directly this function!...
static const ulint OS_FILE_READ_ALLOW_DELETE
Used by MySQLBackup.
Definition: os0file.h:219
bool os_was_file_write_error_reported
Definition: os0file.cc:846
unsigned long long os_fsync_threshold
Definition: os0file.cc:120
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:6010
constexpr mode_t os_innodb_umask_default
A magic constant for the umask parameter that indicates caller wants the os_innodb_umask value to be ...
Definition: os0file.h:1839
#define PRINT_MASK_ELEMENT(flag)
static const ulint OS_FILE_NAME_TOO_LONG
Definition: os0file.h:252
dberr_t os_file_read_func(const IORequest &type, const char *file_name, os_file_t file, byte *buf, os_offset_t offset, ulint n)
NOTE! Use the corresponding macro os_file_read(), not directly this function! Requests a synchronous ...
Definition: os0file.cc:5274
file::Block * os_file_encrypt_page(const IORequest &type, byte *&buf, ulint n)
Encrypt a page content when write it to disk.
Definition: os0file.cc:1928
static const ulint OS_FILE_ERROR_MAX
Definition: os0file.h:255
bool os_file_check_mode(const char *name, bool is_raw_device, bool read_only)
Check if a file can be opened in read-write mode.
Definition: os0file.cc:5564
bool os_file_set_eof(FILE *file)
Truncates a file at its current position.
Definition: os0file.cc:3443
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.
bool os_file_exists(const char *path)
Check the existence and usefulness of a given path.
Definition: os0file.cc:5465
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:2904
static const ulint OS_FILE_ALREADY_EXISTS
Definition: os0file.h:240
static const ulint OS_FILE_DISK_FULL
Definition: os0file.h:239
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:3285
void os_aio_print(FILE *file)
Prints info of the aio arrays.
Definition: os0file.cc:7169
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:232
byte * os_block_get_frame(const file::Block *block) noexcept
Get the sector aligned frame pointer.
Definition: os0file.cc:1000
static dberr_t pfs_os_aio_func(IORequest &type, AIO_mode mode, const char *name, pfs_os_file_t file, byte *buf, os_offset_t offset, ulint n, std::function< void(dberr_t)> callback, ut::Location location)
NOTE! Please use the corresponding macro os_aio(), not directly this function! Performance schema wra...
ulint os_n_file_writes
Definition: os0file.cc:834
constexpr size_t NUM_RETRIES_ON_PARTIAL_IO
Number of retries for partial I/O's.
Definition: os0file.h:76
static dberr_t pfs_os_file_read_func(const IORequest &type, const char *file_name, pfs_os_file_t file, byte *buf, os_offset_t offset, ulint n, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_read(), not directly this function!...
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:7256
bool os_file_delete_func(const char *name)
Deletes a file.
Definition: os0file.cc:3264
static const ulint OS_FILE_READ_WRITE
Definition: os0file.h:216
bool os_file_status_is_conclusive(os_file_type_t type)
A helper method that usually is feed the file_type returned by the os_file_type() method.
Definition: os0file.cc:5469
static const ulint OS_FILE_ACCESS_VIOLATION
Definition: os0file.h:251
dberr_t os_get_free_space(const char *path, uint64_t &free_space)
Get available free space on disk.
Definition: os0file.cc:5500
constexpr IORequest::Type & operator|=(IORequest::Type &a, const IORequest::Type b)
Definition: os0file.h:640
void os_aio_refresh_stats()
Refreshes the statistics used to print per-second averages.
Definition: os0file.cc:7237
os_file_type_t os_file_type(const char *path)
Checks the existence and type (dir, file, link, unknown) of given path.
Definition: os0file.cc:2866
os_file_size_t os_file_get_size(const char *filename)
Gets a file size.
Definition: os0file.cc:3329
static const ulint OS_FILE_AIO_RESOURCES_RESERVED
wait for OS aio resources to become available again
Definition: os0file.h:244
static const ulint OS_CLONE_DATA_FILE
Definition: os0file.h:231
static const ulint OS_FILE_OPERATION_ABORTED
Definition: os0file.h:250
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:3461
constexpr IORequest::Type operator|(const IORequest::Type a, const IORequest::Type b)
Definition: os0file.h:630
file::Block * os_alloc_block() noexcept
Allocate a page for sync IO.
Definition: os0file.cc:1004
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:5225
dberr_t os_file_decompress_page(bool dblwr_read, byte *src, byte *dst, ulint dst_len)
Decompress the page data contents.
Definition: file.cc:277
dberr_t os_file_write_func(IORequest &type, const char *name, os_file_t file, const byte *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:5449
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:2491
static const ulint OS_DATA_FILE_FOR_SPACE_ID_READ
Definition: os0file.h:234
static const ulint OS_FILE_INSUFFICIENT_RESOURCE
Definition: os0file.h:248
ulint os_file_get_and_log_last_error()
Retrieves the last error number if an OS error occurs in a file IO function.
Definition: os0file.cc:4945
static constexpr os_fd_t OS_FILE_CLOSED
Definition: os0file.h:151
FILE * os_file_create_tmpfile()
Create a temporary file.
Definition: os0file.cc:1586
void os_aio_print_pending_io(FILE *file)
Prints all pending IO.
Definition: os0file.cc:7298
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:5417
char * innobase_mysql_tmpdir()
return any of the tmpdir path
Definition: ha_innodb.cc:2489
uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:87
constexpr IORequest::Type operator&(const IORequest::Type a, const IORequest::Type b)
Definition: os0file.h:635
static const ulint OS_FILE_TOO_MANY_OPENED
Definition: os0file.h:253
static const ulint OS_LOG_FILE_RESIZING
Definition: os0file.h:225
void os_aio_start_threads()
Starts one thread for each segment created in os_aio_init.
Definition: os0file.cc:5983
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:1164
bool os_file_delete_if_exists_func(const char *name, bool *exist)
Deletes a file if it exists.
Definition: os0file.cc:3228
dberr_t os_file_read_no_error_handling_func(IORequest &type, const char *file_name, os_file_t file, byte *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:5428
The interface to the operating system file io.
const char * filename
Definition: pfs_example_component_population.cc:67
MY_COMPILER_CLANG_DIAGNOSTIC_IGNORE("-Winconsistent-missing-destructor-override") static Scope_guard static_guard([]()
Definition: protobuf_plugin.cc:33
required string key
Definition: replication_asynchronous_connection_failover.proto:60
required string type
Definition: replication_group_member_actions.proto:34
case opt name
Definition: sslopt-case.h:29
NOTE: The functions in this file should only use functions from other files in library.
Stores information about access modes to the resource permitted to the caller at the moment of checki...
Definition: os0file.h:1776
bool has_read_access
Definition: os0file.h:1777
bool has_write_access
Definition: os0file.h:1778
Compression algorithm.
Definition: file.h:51
Type
Algorithm types supported.
Definition: file.h:53
@ NONE
No compression.
Definition: file.h:59
Type m_type
Compression type.
Definition: file.h:197
std::string to_string() const
Definition: file.h:105
Directory names for the depth first directory scan.
Definition: os0file.h:1908
Entry(const Path &path, size_t depth)
Constructor.
Definition: os0file.h:1913
Path m_path
Path to the directory.
Definition: os0file.h:1916
size_t m_depth
Relative depth of m_path.
Definition: os0file.h:1919
Blocks for doing IO, used in the transparent compression and encryption code.
Definition: os0file.h:92
Block() noexcept
Default constructor.
Definition: os0file.h:94
static void free(file::Block *obj) noexcept
Free the given memory block.
Definition: os0file.h:1948
byte * m_ptr
Pointer to the memory block.
Definition: os0file.h:101
size_t m_size
Size of the data in memory block.
Definition: os0file.h:104
byte pad[ut::INNODB_CACHE_LINE_SIZE]
This padding is needed to avoid false sharing.
Definition: os0file.h:109
std::atomic< bool > m_in_use
Definition: os0file.h:110
Define for performance schema registration key.
Definition: sync0sync.h:51
Sparse file size information.
Definition: os0file.h:650
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:656
os_offset_t m_total_size
Total size of file in bytes.
Definition: os0file.h:652
Struct used in fetching information of a file in a directory.
Definition: os0file.h:717
uint32_t block_size
Block size to use for IO in bytes.
Definition: os0file.h:723
time_t ctime
creation time
Definition: os0file.h:725
char name[OS_FILE_MAX_PATH]
path to a file
Definition: os0file.h:718
time_t atime
access time
Definition: os0file.h:727
os_file_type_t type
file type
Definition: os0file.h:719
os_offset_t size
file size in bytes
Definition: os0file.h:720
os_offset_t alloc_size
Allocated size for sparse files in bytes.
Definition: os0file.h:721
time_t mtime
modification time
Definition: os0file.h:726
Common file descriptor for file IO instrumentation with PFS on windows and other platforms.
Definition: os0file.h:172
struct PSI_file * m_psi
Definition: os0file.h:174
os_file_t m_file
Definition: os0file.h:182
#define LOG(ARGS)
Definition: test_trace_plugin.cc:163
static const size_t UNIV_SECTOR_SIZE
Definition: univ.i:642
unsigned long int ulint
Definition: univ.i:403
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:109
#define HANDLE
Definition: violite.h:159
int n
Definition: xcom_base.cc:509