MySQL 9.1.0
Source Code Documentation
os0file.h
Go to the documentation of this file.
1/***********************************************************************
2
3Copyright (c) 1995, 2024, Oracle and/or its affiliates.
4Copyright (c) 2009, Percona Inc.
5
6Portions of this file contain modifications contributed and copyrighted
7by Percona Inc.. Those modifications are
8gratefully acknowledged and are described briefly in the InnoDB
9documentation. The contributions by Percona Inc. are incorporated with
10their permission, and subject to the conditions contained in the file
11COPYING.Percona.
12
13This program is free software; you can redistribute it and/or modify
14it under the terms of the GNU General Public License, version 2.0,
15as published by the Free Software Foundation.
16
17This program is designed to work with certain software (including
18but not limited to OpenSSL) that is licensed under separate terms,
19as designated in a particular file or component or in included license
20documentation. The authors of MySQL hereby grant you an additional
21permission to link the program and your derivative works with the
22separately licensed software that they have either included with
23the program or referenced in the documentation.
24
25This program is distributed in the hope that it will be useful,
26but WITHOUT ANY WARRANTY; without even the implied warranty of
27MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28GNU General Public License, version 2.0, for more details.
29
30You should have received a copy of the GNU General Public License
31along with this program; if not, write to the Free Software
32Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33
34***********************************************************************/
35
36/** @file include/os0file.h
37 The interface to the operating system file io
38
39 Created 10/21/1995 Heikki Tuuri
40 *******************************************************/
41
42#ifndef os0file_h
43#define os0file_h
44
45#include "my_dbug.h"
46#include "my_io.h"
47
48#include "os/file.h"
49#include "os0atomic.h"
50#include "os0enc.h"
51
52#ifndef _WIN32
53#include <dirent.h>
54#include <sys/stat.h>
55#include <sys/statvfs.h>
56#include <time.h>
57#else
58#include <Strsafe.h>
59#include <locale>
60#include <string>
61#endif /* !_WIN32 */
62
63#include <functional>
64#include <stack>
65
66/** Prefix all files and directory created under data directory with special
67string so that it never conflicts with MySQL schema directory. */
68#define OS_FILE_PREFIX "#"
69
70/** File node of a tablespace or the log data space */
71struct fil_node_t;
72
73extern bool os_has_said_disk_full;
74
75/** Number of retries for partial I/O's */
76constexpr size_t NUM_RETRIES_ON_PARTIAL_IO = 10;
77
78/** Number of pending read operations */
79extern std::atomic<ulint> os_n_pending_reads;
80/** Number of pending write operations */
81extern std::atomic<ulint> os_n_pending_writes;
82
83/* Flush after each os_fsync_threshold bytes */
84extern unsigned long long os_fsync_threshold;
85
86/** File offset in bytes */
87typedef uint64_t os_offset_t;
88
89namespace file {
90/** Blocks for doing IO, used in the transparent compression
91and encryption code. */
92struct Block {
93 /** Default constructor */
94 Block() noexcept : m_ptr(nullptr), m_in_use() {}
95
96 /** Free the given memory block.
97 @param[in] obj the memory block to be freed. */
98 static void free(file::Block *obj) noexcept;
99
100 /** Pointer to the memory block. */
101 byte *m_ptr;
102 /** Size of the data in memory block. This may be not UNIV_PAGE_SIZE if the
103 data was compressed before encryption. */
104 size_t m_size;
105 /** This padding is needed to avoid false sharing. TBD: of what exactly? We
106 can't use alignas because std::vector<Block> uses std::allocator which in
107 C++14 doesn't have to handle overaligned types. (see ยง 20.7.9.1.5 of N4140
108 draft) */
110 std::atomic<bool> m_in_use;
111};
112} // namespace file
113
114/** Raw file handle. */
115using os_fd_t = int;
116
117static constexpr os_fd_t OS_FD_CLOSED = -1;
118
119#ifdef _WIN32
120
121typedef HANDLE os_file_dir_t; /*!< directory stream */
122
123/** Use unbuffered I/O */
124#define UNIV_NON_BUFFERED_IO
125
126/** Windows file handle */
127using os_file_t = HANDLE;
128
129static const os_file_t OS_FILE_CLOSED = INVALID_HANDLE_VALUE;
130
131/** Convert a C file descriptor to a native file handle
132@param fd file descriptor
133@return native file handle */
134#define OS_FILE_FROM_FD(fd) (HANDLE) _get_osfhandle(fd)
135
136/** Associates a C file descriptor with an existing native file handle
137@param[in] file native file handle
138@return C file descriptor */
139#define OS_FD_FROM_FILE(file) _open_osfhandle((intptr_t)file, _O_RDONLY)
140
141/** Closes the file associated with C file descriptor fd
142@param[in] fd C file descriptor
143@return 0 if success */
144#define OS_FILE_CLOSE_FD(fd) _close(fd)
145
146#else /* _WIN32 */
147
148/** File handle */
150
152
153/** Convert a C file descriptor to a native file handle
154@param fd file descriptor
155@return native file handle */
156#define OS_FILE_FROM_FD(fd) fd
157
158/** C file descriptor from an existing native file handle
159@param[in] file native file handle
160@return C file descriptor */
161#define OS_FD_FROM_FILE(file) file
162
163/** Closes the file associated with C file descriptor fd
164@param[in] fd C file descriptor
165@return 0 if success */
166#define OS_FILE_CLOSE_FD(fd) (os_file_close(fd) ? 0 : OS_FD_CLOSED)
167
168#endif /* _WIN32 */
169
170/** Common file descriptor for file IO instrumentation with PFS
171on windows and other platforms */
173#ifdef UNIV_PFS_IO
175#else /* UNIV_PFS_IO */
176 pfs_os_file_t &operator=(os_file_t file) {
177 m_file = file;
178 return (*this);
179 }
180#endif /* UNIV_PFS_IO */
181
183};
184
185/** The next value should be smaller or equal to the smallest sector size used
186on any disk. A log block is required to be a portion of disk which is written
187so that if the start and the end of a block get written to disk, then the
188whole block gets written. This should be true even in most cases of a crash:
189if this fails for a log block, then it is equivalent to a media failure in the
190log. */
191
192constexpr uint32_t OS_FILE_LOG_BLOCK_SIZE = 512;
193
194/** Options for os_file_create_func @{ */
196 OS_FILE_OPEN = 51, /*!< to open an existing file (if
197 doesn't exist, error) */
198 OS_FILE_CREATE, /*!< to create new file (if
199 exists, error) */
200 OS_FILE_OPEN_RAW, /*!< to open a raw device or disk
201 partition */
202 OS_FILE_CREATE_PATH, /*!< to create the directories */
203 OS_FILE_OPEN_RETRY, /*!< open with retry */
204
205 /** Flags that can be combined with the above values. Please ensure
206 that the above values stay below 128. */
207
208 OS_FILE_ON_ERROR_NO_EXIT = 128, /*!< do not exit on unknown errors */
209 OS_FILE_ON_ERROR_SILENT = 256 /*!< don't print diagnostic messages to
210 the log unless it is a fatal error,
211 this flag is only used if
212 ON_ERROR_NO_EXIT is set */
214
215static const ulint OS_FILE_READ_ONLY = 333;
216static const ulint OS_FILE_READ_WRITE = 444;
217
218/** Used by MySQLBackup */
220/** @} */
221
222/** Types for file create @{ */
223static const ulint OS_DATA_FILE = 100;
224static const ulint OS_LOG_FILE = 101;
225static const ulint OS_LOG_FILE_RESIZING = 102;
226/* Don't use this for Data files, Log files. Use it for smaller files
227or if number of bytes to write are not multiple of sector size.
228With this flag, writes to file will be always buffered and ignores the value
229of innodb_flush_method. */
230static const ulint OS_BUFFERED_FILE = 103;
231static const ulint OS_CLONE_DATA_FILE = 104;
232static const ulint OS_CLONE_LOG_FILE = 105;
233static const ulint OS_DBLWR_FILE = 106;
234/** @} */
235
236/** Error codes from os_file_get_last_error @{ */
237static const ulint OS_FILE_NOT_FOUND = 71;
238static const ulint OS_FILE_DISK_FULL = 72;
240static const ulint OS_FILE_PATH_ERROR = 74;
241
242/** wait for OS aio resources to become available again */
244
251static const ulint OS_FILE_NAME_TOO_LONG = 82;
253
254static const ulint OS_FILE_ERROR_MAX = 100;
255/** @} */
256
257/** Types for AIO operations @{ */
258
259/** No transformations during read/write, write as is. */
260#define IORequestRead IORequest(IORequest::READ)
261#define IORequestWrite IORequest(IORequest::WRITE)
262
263/**
264The IO Context that is passed down to the low level IO code */
266 public:
267 /** Flags passed in the request, they can be ORred together. */
268 enum {
269 UNSET = 0,
270 READ = 1,
271 WRITE = 2,
272
273 /** Request for a doublewrite page IO */
274 DBLWR = 4,
275
276 /** Enumerations below can be ORed to READ/WRITE above*/
277
278 /** Data file */
280
281 /** Log file request*/
282 LOG = 16,
283
284 /** Disable partial read warnings */
286
287 /** Do not to wake i/o-handler threads, but the caller will do
288 the waking explicitly later, in this way the caller can post
289 several requests in a batch; NOTE that the batch must not be
290 so big that it exhausts the slots in AIO arrays! NOTE that
291 a simulated batch may introduce hidden chances of deadlocks,
292 because I/Os are not actually handled until all
293 have been posted: use with great caution! */
295
296 /** Ignore failed reads of non-existent pages */
298
299 /** Use punch hole if available, only makes sense if
300 compression algorithm != NONE. Ignored if not set */
302
303 /** Force raw read, do not try to compress/decompress.
304 This can be used to force a read and write without any
305 compression e.g., for redo log, merge sort temporary files
306 and the truncate redo log. */
308
309 /** Row log used in online DDL */
310 ROW_LOG = 1024,
311
312 /** We optimise cases where punch hole is not done if the compressed length
313 of the page is the same as the original size of the page. Ignore such
314 optimisations if this flag is set. */
316 };
317
318 /** Default constructor */
321 m_type(READ),
323 m_encryption(),
325 m_elen(0) {
326 /* No op */
327 }
328
329 /**
330 @param[in] type Request type, can be a value that is
331 ORed from the above enum */
332 explicit IORequest(int type)
334 m_type(type),
336 m_encryption(),
338 m_elen(0) {
339 if (is_log() || is_row_log()) {
341 }
342
345 }
346 }
347
348 /** @return true if ignore missing flag is set */
349 [[nodiscard]] static bool ignore_missing(int type) {
350 return ((type & IGNORE_MISSING) == IGNORE_MISSING);
351 }
352
353 /** @return true if it is a read request */
354 [[nodiscard]] bool is_read() const { return ((m_type & READ) == READ); }
355
356 /** @return true if it is a write request */
357 [[nodiscard]] bool is_write() const { return ((m_type & WRITE) == WRITE); }
358
359 /** @return true if it is a redo log write */
360 [[nodiscard]] bool is_log() const { return ((m_type & LOG) == LOG); }
361
362 /** @return true if it is a row log entry used in online DDL */
363 [[nodiscard]] bool is_row_log() const {
364 return ((m_type & ROW_LOG) == ROW_LOG);
365 }
366
367 /** @return true if the simulated AIO thread should be woken up */
368 [[nodiscard]] bool is_wake() const { return ((m_type & DO_NOT_WAKE) == 0); }
369
370 /** @return true if partial read warning disabled */
371 [[nodiscard]] bool is_partial_io_warning_disabled() const {
374 }
375
376 /** Disable partial read warnings */
378
379 /** @return true if missing files should be ignored */
380 [[nodiscard]] bool ignore_missing() const { return (ignore_missing(m_type)); }
381
382 /** @return true if punch hole should be used */
383 [[nodiscard]] bool punch_hole() const {
384 return ((m_type & PUNCH_HOLE) == PUNCH_HOLE);
385 }
386
387 /** @return true if punch hole needs to be done always if it's supported and
388 if the page is to be compressed. */
389 [[nodiscard]] bool is_punch_hole_optimisation_disabled() const {
391
394 }
395
396 /** @return true if the read should be validated */
397 [[nodiscard]] bool validate() const {
398 ut_ad(is_read() ^ is_write());
399
400 return (!is_read() || !punch_hole());
401 }
402
403 /** Set the punch hole flag */
407 }
408 }
409
410 /** Set the force punch hole flag */
414 }
415 }
416
417 /** Clear the do not wake flag */
418 void clear_do_not_wake() { m_type &= ~DO_NOT_WAKE; }
419
420 /** Clear the punch hole flag */
421 void clear_punch_hole() { m_type &= ~PUNCH_HOLE; }
422
423 /** @return the block size to use for IO */
424 [[nodiscard]] ulint block_size() const { return (m_block_size); }
425
426 /** Set the block size for IO
427 @param[in] block_size Block size to set */
429 m_block_size = static_cast<uint32_t>(block_size);
430 }
431
432 /** Returns original size of the IO to make. If one was not specified, then 0
433 is returned. */
434 uint32_t get_original_size() const { return m_original_size; }
435
436 void set_original_size(uint32_t original_size) {
437 m_original_size = original_size;
438 }
439
440 /** Clear all compression related flags */
443
445 }
446
447 /** Compare two requests
448 @return true if the are equal */
449 bool operator==(const IORequest &rhs) const { return (m_type == rhs.m_type); }
450
451 /** Set compression algorithm
452 @param[in] type The compression algorithm to use */
454 if (type == Compression::NONE) {
455 return;
456 }
457
459
461 }
462
463 /** Get the compression algorithm.
464 @return the compression algorithm */
465 [[nodiscard]] Compression compression_algorithm() const {
466 return (m_compression);
467 }
468
469 /** @return true if the page should be compressed */
470 [[nodiscard]] bool is_compressed() const {
472 }
473
474 /** @return true if the page read should not be transformed. */
475 [[nodiscard]] bool is_compression_enabled() const {
476 return ((m_type & NO_COMPRESSION) == 0);
477 }
478
479 /** Disable transformations. */
481
482 /** Get the encryption algorithm.
483 @return the encryption algorithm */
484 [[nodiscard]] Encryption encryption_algorithm() const {
485 return (m_encryption);
486 }
487
488 /** @return true if the page should be encrypted. */
489 [[nodiscard]] bool is_encrypted() const {
491 }
492
493 /** Clear all encryption related flags */
495 m_encryption.set_key(nullptr);
499 }
500
501 /** Note that the IO is for double write buffer page write. */
502 void dblwr() { m_type |= DBLWR; }
503
504 /** @return true if the request is for a dblwr page. */
505 [[nodiscard]] bool is_dblwr() const { return ((m_type & DBLWR) == DBLWR); }
506
507 /** @return true if punch hole is supported */
509 /* In this debugging mode, we act as if punch hole is supported,
510 and then skip any calls to actually punch a hole here.
511 In this way, Transparent Page Compression is still being tested. */
512 DBUG_EXECUTE_IF("ignore_punch_hole", return (true););
513
514#if defined(HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE) || defined(_WIN32)
515 return (true);
516#else
517 return (false);
518#endif /* HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE || _WIN32 */
519 }
520
521 static std::string type_str(const ulint type);
522
523 /** @return string representation. */
524 std::string to_string() const {
526 os << "bs: " << m_block_size << " flags:";
527 os << type_str(m_type);
528 os << ", comp: " << m_compression.to_string();
529 os << ", enc: " << m_encryption.to_string(m_encryption.get_type());
530 return (os.str());
531 }
532
533 /** Get a reference to the underlying encryption information.
534 @return reference to the encryption information. */
535 [[nodiscard]] Encryption &get_encryption_info() noexcept {
536 return m_encryption;
537 }
538
539 /** Set the encrypted block to the given value.
540 @param[in] eblock the encrypted block. */
541 void set_encrypted_block(const file::Block *eblock) noexcept {
542 m_eblock = eblock;
543 }
544
545 /** Get the encrypted block.
546 @return the encrypted block. */
547 [[nodiscard]] const file::Block *get_encrypted_block() const noexcept {
548 return m_eblock;
549 }
550
551 private:
552 /* File system best block size */
553 uint32_t m_block_size{};
554
555 /** Request type bit flags */
556 int m_type{};
557
558 /** Compression algorithm */
560
561 /** Encryption algorithm */
563
564 /** The encrypted block. */
566
567 /** The length of data in encrypted block. */
568 uint32_t m_elen{};
569
570 /** Length of the original IO size.
571 For reads it is an expected uncompressed length.
572 For writes it is a length up to which the write is to be extended with a punch
573 hole, if supported. */
574 uint32_t m_original_size{};
575};
576
577/** @} */
578
579/** Sparse file size information. */
581 /** Total size of file in bytes */
583
584 /** If it is a sparse file then this is the number of bytes
585 actually allocated for the file. */
587};
588
589/** Win NT does not allow more than 64 */
591
592/** Modes for aio operations @{ */
593enum class AIO_mode : size_t {
594 /** Normal asynchronous i/o not for ibuf pages or ibuf bitmap pages */
595 NORMAL = 21,
596
597 /** Asynchronous i/o for ibuf pages or ibuf bitmap pages */
598 IBUF = 22,
599
600 /** Asynchronous i/o where the calling thread will itself wait for
601 the i/o to complete, doing also the job of the i/o-handler thread;
602 can be used for any pages, ibuf or non-ibuf. This is used to save
603 CPU time, as we can do with fewer thread switches. Plain synchronous
604 I/O is not as good, because it must serialize the file seek and read
605 or write, causing a bottleneck for parallelism. */
606 SYNC = 24
607};
608/** @} */
609
612extern ulint os_n_fsyncs;
613
614/* File types for directory entry data type */
615
617 /** Get status failed. */
619
620 /** stat() failed, with ENAMETOOLONG */
622
623 /** stat() failed with EACCESS */
625
626 /** File doesn't exist. */
628
629 /** File exists but type is unknown. */
631
632 /** Ordinary file. */
634
635 /** Directory. */
637
638 /** Symbolic link. */
640
641 /** Block device. */
644
645/* Maximum path string length in bytes when referring to tables with in the
646'./databasename/tablename.ibd' path format; we can allocate at least 2 buffers
647of this size from the thread stack; that is why this should not be made much
648bigger than 4000 bytes. The maximum path length used by any storage engine
649in the server must be at least this big. */
650constexpr uint32_t OS_FILE_MAX_PATH = 4000;
651static_assert(FN_REFLEN_SE >= OS_FILE_MAX_PATH,
652 "(FN_REFLEN_SE < OS_FILE_MAX_PATH)");
653
654/** Struct used in fetching information of a file in a directory */
656 char name[OS_FILE_MAX_PATH]; /*!< path to a file */
657 os_file_type_t type; /*!< file type */
658 os_offset_t size; /*!< file size in bytes */
659 os_offset_t alloc_size; /*!< Allocated size for
660 sparse files in bytes */
661 uint32_t block_size; /*!< Block size to use for IO
662 in bytes*/
663 time_t ctime; /*!< creation time */
664 time_t mtime; /*!< modification time */
665 time_t atime; /*!< access time */
666 bool rw_perm; /*!< true if can be opened
667 in read-write mode. Only valid
668 if type == OS_FILE_TYPE_FILE */
669};
670
671#ifndef UNIV_HOTBACKUP
672/** Create a temporary file. This function is like tmpfile(3). It will create
673the file in the MySQL server configuration parameter (--tmpdir).
674@return temporary file handle, or NULL on error */
676#endif /* !UNIV_HOTBACKUP */
677
678/** This function attempts to create a directory named pathname. The new
679directory gets default permissions. On Unix the permissions are
680(0770 & ~umask). If the directory exists already, nothing is done and
681the call succeeds, unless the fail_if_exists arguments is true.
682If another error occurs, such as a permission error, this does not crash,
683but reports the error and returns false.
684@param[in] pathname directory name as null-terminated string
685@param[in] fail_if_exists if true, pre-existing directory is treated as
686 an error.
687@return true if call succeeds, false on error */
688bool os_file_create_directory(const char *pathname, bool fail_if_exists);
689
690/** Callback function type to be implemented by caller. It is called for each
691entry in directory.
692@param[in] path path to the file
693@param[in] name name of the file */
694typedef std::function<void(const char *path, const char *name)> os_dir_cbk_t;
695
696/** This function scans the contents of a directory and invokes the callback
697for each entry.
698@param[in] path directory name as null-terminated string
699@param[in] scan_cbk use callback to be called for each entry
700@param[in] is_drop attempt to drop the directory after scan
701@return true if call succeeds, false on error */
702bool os_file_scan_directory(const char *path, os_dir_cbk_t scan_cbk,
703 bool is_drop);
704
705/** Clang on Windows warns about umask not found. */
707#ifdef _WIN32
709#endif
710
711/** NOTE! Use the corresponding macro
712os_file_create_simple_no_error_handling(), not directly this function!
713A simple function to open or create a file.
714@param[in] name name of the file or path as a
715null-terminated string
716@param[in] create_mode create mode
717@param[in] access_type OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or
718 OS_FILE_READ_ALLOW_DELETE; the last option
719 is used by a backup program reading the file
720@param[in] read_only if true read only mode checks are enforced
721@param[in] umask UNIX access permission to be set when creating a
722 file. Use os_umask_default to use global default
723 umask.
724@param[out] success true if succeeded
725@return own: handle to the file, not defined if error, error number
726 can be retrieved with os_file_get_last_error */
728 const char *name, ulint create_mode, ulint access_type, bool read_only,
729#ifndef _WIN32
730 mode_t umask,
731#endif
732 bool *success);
734
735/** Tries to disable OS caching on an opened file descriptor.
736@param[in] fd file descriptor to alter
737@param[in] file_name file name, used in the diagnostic message
738@param[in] operation_name "open" or "create"; used in the diagnostic
739 message */
740void os_file_set_nocache(int fd, const char *file_name,
741 const char *operation_name);
742
743/** NOTE! Use the corresponding macro os_file_create(), not directly
744this function!
745Opens an existing file or creates a new.
746@param[in] name name of the file or path as a null-terminated
747 string
748@param[in] create_mode create mode
749@param[in] purpose OS_DATA_FILE, OS_LOG_FILE etc.
750@param[in] read_only if true read only mode checks are enforced
751@param[out] success true if succeeded
752@return own: handle to the file, not defined if error, error number
753 can be retrieved with os_file_get_last_error */
754[[nodiscard]] pfs_os_file_t os_file_create_func(const char *name,
755 ulint create_mode,
756 ulint purpose, bool read_only,
757 bool *success);
758
759/** Deletes a file. The file has to be closed before calling this.
760@param[in] name file path as a null-terminated string
761@return true if success */
762bool os_file_delete_func(const char *name);
763
764/** Deletes a file if it exists. The file has to be closed before calling this.
765@param[in] name file path as a null-terminated string
766@param[out] exist indicate if file pre-exist
767@return true if success */
768bool os_file_delete_if_exists_func(const char *name, bool *exist);
769
770/** NOTE! Use the corresponding macro os_file_rename(), not directly
771this function!
772Renames a file (can also move it to another directory). It is safest that the
773file is closed before calling this function.
774@param[in] oldpath old file path as a null-terminated string
775@param[in] newpath new file path
776@return true if success */
777bool os_file_rename_func(const char *oldpath, const char *newpath);
778
779/** NOTE! Use the corresponding macro os_file_close(), not directly
780this function!
781Closes a file handle. In case of error, error number can be retrieved with
782os_file_get_last_error.
783@param[in] file Handle to a file
784@return true if success */
786
787#ifdef UNIV_PFS_IO
788
789/* Keys to register InnoDB I/O with performance schema */
797
798/* Following four macros are instumentations to register
799various file I/O operations with performance schema.
8001) register_pfs_file_open_begin() and register_pfs_file_open_end() are
801used to register file creation, opening and closing.
8022) register_pfs_file_rename_begin() and register_pfs_file_rename_end()
803are used to register file renaming.
8043) register_pfs_file_io_begin() and register_pfs_file_io_end() are
805used to register actual file read, write and flush
8064) register_pfs_file_close_begin() and register_pfs_file_close_end()
807are used to register file deletion operations*/
808#define register_pfs_file_open_begin(state, locker, key, op, name, \
809 src_location) \
810 do { \
811 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
812 op, name, &locker); \
813 if (locker != nullptr) { \
814 PSI_FILE_CALL(start_file_open_wait) \
815 (locker, src_location.filename, static_cast<uint>(src_location.line)); \
816 } \
817 } while (0)
818
819#define register_pfs_file_open_end(locker, file, result) \
820 do { \
821 if (locker != nullptr) { \
822 file.m_psi = PSI_FILE_CALL(end_file_open_wait)(locker, result); \
823 } \
824 } while (0)
825
826#define register_pfs_file_rename_begin(state, locker, key, op, from, to, \
827 src_location) \
828 do { \
829 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
830 op, from, &locker); \
831 if (locker != nullptr) { \
832 PSI_FILE_CALL(start_file_rename_wait) \
833 (locker, (size_t)0, from, to, src_location.filename, \
834 static_cast<uint>(src_location.line)); \
835 } \
836 } while (0)
837
838#define register_pfs_file_rename_end(locker, from, to, result) \
839 do { \
840 if (locker != nullptr) { \
841 PSI_FILE_CALL(end_file_rename_wait)(locker, from, to, result); \
842 } \
843 } while (0)
844
845#define register_pfs_file_close_begin(state, locker, key, op, name, \
846 src_location) \
847 do { \
848 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
849 op, name, &locker); \
850 if (locker != nullptr) { \
851 PSI_FILE_CALL(start_file_close_wait) \
852 (locker, src_location.filename, static_cast<uint>(src_location.line)); \
853 } \
854 } while (0)
855
856#define register_pfs_file_close_end(locker, result) \
857 do { \
858 if (locker != nullptr) { \
859 PSI_FILE_CALL(end_file_close_wait)(locker, result); \
860 } \
861 } while (0)
862
863#define register_pfs_file_io_begin(state, locker, file, count, op, \
864 src_location) \
865 do { \
866 locker = \
867 PSI_FILE_CALL(get_thread_file_stream_locker)(state, file.m_psi, op); \
868 if (locker != nullptr) { \
869 PSI_FILE_CALL(start_file_wait) \
870 (locker, count, src_location.filename, \
871 static_cast<uint>(src_location.line)); \
872 } \
873 } while (0)
874
875#define register_pfs_file_io_end(locker, count) \
876 do { \
877 if (locker != nullptr) { \
878 PSI_FILE_CALL(end_file_wait)(locker, count); \
879 } \
880 } while (0)
881
882/* Following macros/functions are file I/O APIs that would be performance
883schema instrumented if "UNIV_PFS_IO" is defined. They would point to
884wrapper functions with performance schema instrumentation in such case.
885
886os_file_create
887os_file_create_simple_no_error_handling
888os_file_close
889os_file_rename
890os_aio
891os_file_read
892os_file_read_no_error_handling
893os_file_read_no_error_handling_int_fd
894os_file_write
895
896The wrapper functions have the prefix of "innodb_". */
897
898#define os_file_create(key, name, create, purpose, read_only, success) \
899 pfs_os_file_create_func(key, name, create, purpose, read_only, success, \
900 UT_LOCATION_HERE)
901
902#ifndef _WIN32
903#define os_file_create_simple_no_error_handling(key, name, create_mode, \
904 access, read_only, success) \
905 pfs_os_file_create_simple_no_error_handling_func( \
906 key, name, create_mode, access, read_only, os_innodb_umask_default, \
907 success, UT_LOCATION_HERE)
908
909#define os_file_create_simple_no_error_handling_with_umask( \
910 key, name, create_mode, access, read_only, umask, success) \
911 pfs_os_file_create_simple_no_error_handling_func(key, name, create_mode, \
912 access, read_only, umask, \
913 success, UT_LOCATION_HERE)
914#else
915#define os_file_create_simple_no_error_handling(key, name, create_mode, \
916 access, read_only, success) \
917 pfs_os_file_create_simple_no_error_handling_func( \
918 key, name, create_mode, access, read_only, success, UT_LOCATION_HERE)
919#endif
920
921#define os_file_close_pfs(file) pfs_os_file_close_func(file, UT_LOCATION_HERE)
922
923#define os_aio(type, mode, name, file, buf, offset, n, read_only, message1, \
924 message2) \
925 pfs_os_aio_func(type, mode, name, file, buf, offset, n, read_only, message1, \
926 message2, UT_LOCATION_HERE)
927
928#define os_file_read_pfs(type, file_name, file, buf, offset, n) \
929 pfs_os_file_read_func(type, file_name, file, buf, offset, n, UT_LOCATION_HERE)
930
931#define os_file_read_first_page_pfs(type, file_name, file, buf, n) \
932 pfs_os_file_read_first_page_func(type, file_name, file, buf, n, \
933 UT_LOCATION_HERE)
934
935#define os_file_copy_pfs(src, src_offset, dest, dest_offset, size) \
936 pfs_os_file_copy_func(src, src_offset, dest, dest_offset, size, \
937 UT_LOCATION_HERE)
938
939#define os_file_read_no_error_handling_pfs(type, file_name, file, buf, offset, \
940 n, o) \
941 pfs_os_file_read_no_error_handling_func(type, file_name, file, buf, offset, \
942 n, o, UT_LOCATION_HERE)
943
944#define os_file_read_no_error_handling_int_fd(type, file_name, file, buf, \
945 offset, n, o) \
946 pfs_os_file_read_no_error_handling_int_fd_func( \
947 type, file_name, file, buf, offset, n, o, UT_LOCATION_HERE)
948
949#define os_file_write_pfs(type, name, file, buf, offset, n) \
950 pfs_os_file_write_func(type, name, file, buf, offset, n, UT_LOCATION_HERE)
951
952#define os_file_write_int_fd(type, name, file, buf, offset, n) \
953 pfs_os_file_write_int_fd_func(type, name, file, buf, offset, n, \
954 UT_LOCATION_HERE)
955
956#define os_file_flush_pfs(file) pfs_os_file_flush_func(file, UT_LOCATION_HERE)
957
958#define os_file_rename(key, oldpath, newpath) \
959 pfs_os_file_rename_func(key, oldpath, newpath, UT_LOCATION_HERE)
960
961#define os_file_delete(key, name) \
962 pfs_os_file_delete_func(key, name, UT_LOCATION_HERE)
963
964#define os_file_delete_if_exists(key, name, exist) \
965 pfs_os_file_delete_if_exists_func(key, name, exist, UT_LOCATION_HERE)
966
967/** Clang on Windows warns about umask not found. */
969#ifdef _WIN32
971#endif
972
973/** NOTE! Please use the corresponding macro
974os_file_create_simple_no_error_handling(), not directly this function!
975A performance schema instrumented wrapper function for
976os_file_create_simple_no_error_handling(). Add instrumentation to
977monitor file creation/open.
978@param[in] key Performance Schema Key
979@param[in] name name of the file or path as a null-terminated
980 string
981@param[in] create_mode create mode
982@param[in] access_type OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or
983 OS_FILE_READ_ALLOW_DELETE; the last option is
984 used by a backup program reading the file
985@param[in] read_only if true read only mode checks are enforced
986@param[in] umask UNIX access permission to be set when creating a
987 file. Use os_umask_default to use global default
988 umask.
989@param[out] success true if succeeded
990@param[in] src_location location where func invoked
991@return own: handle to the file, not defined if error, error number
992 can be retrieved with os_file_get_last_error */
993[[nodiscard]] static inline pfs_os_file_t
995 mysql_pfs_key_t key, const char *name, ulint create_mode, ulint access_type,
996 bool read_only,
997#ifndef _WIN32
998 mode_t umask,
999#endif
1000 bool *success, ut::Location src_location);
1002
1003/** NOTE! Please use the corresponding macro os_file_create(), not directly
1004this function!
1005A performance schema wrapper function for os_file_create().
1006Add instrumentation to monitor file creation/open.
1007@param[in] key Performance Schema Key
1008@param[in] name name of the file or path as a null-terminated
1009 string
1010@param[in] create_mode create mode
1011@param[in] purpose OS_DATA_FILE, OS_LOG_FILE etc.
1012@param[in] read_only if true read only mode checks are enforced
1013@param[out] success true if succeeded
1014@param[in] src_location location where func invoked
1015@return own: handle to the file, not defined if error, error number
1016 can be retrieved with os_file_get_last_error */
1017[[nodiscard]] static inline pfs_os_file_t pfs_os_file_create_func(
1018 mysql_pfs_key_t key, const char *name, ulint create_mode, ulint purpose,
1019 bool read_only, bool *success, ut::Location src_location);
1020
1021/** NOTE! Please use the corresponding macro os_file_close(), not directly
1022this function!
1023A performance schema instrumented wrapper function for os_file_close().
1024@param[in] file handle to a file
1025@param[in] src_location location where func invoked
1026@return true if success */
1028 ut::Location src_location);
1029
1030/** NOTE! Please use the corresponding macro os_file_read(), not directly
1031this function!
1032This is the performance schema instrumented wrapper function for
1033os_file_read() which requests a synchronous read operation.
1034@param[in, out] type IO request context
1035@param[in] file_name file name
1036@param[in] file Open file handle
1037@param[out] buf buffer where to read
1038@param[in] offset file offset where to read
1039@param[in] n number of bytes to read
1040@param[in] src_location location where func invoked
1041@return DB_SUCCESS if request was successful */
1043 const char *file_name,
1044 pfs_os_file_t file, void *buf,
1045 os_offset_t offset, ulint n,
1046 ut::Location src_location);
1047
1048/** NOTE! Please use the corresponding macro os_file_read_first_page(),
1049not directly this function!
1050This is the performance schema instrumented wrapper function for
1051os_file_read_first_page() which requests a synchronous read operation
1052of page 0 of IBD file
1053@param[in, out] type IO request context
1054@param[in] file_name file name
1055@param[in] file Open file handle
1056@param[out] buf buffer where to read
1057@param[in] n number of bytes to read
1058@param[in] src_location location where func invoked
1059@return DB_SUCCESS if request was successful */
1061 IORequest &type, const char *file_name, pfs_os_file_t file, void *buf,
1062 ulint n, ut::Location src_location);
1063
1064/** copy data from one file to another file. Data is read/written
1065at current file offset.
1066@param[in] src file handle to copy from
1067@param[in] src_offset offset to copy from
1068@param[in] dest file handle to copy to
1069@param[in] dest_offset offset to copy to
1070@param[in] size number of bytes to copy
1071@param[in] src_location location where func invoked
1072@return DB_SUCCESS if successful */
1074 os_offset_t src_offset,
1075 pfs_os_file_t dest,
1076 os_offset_t dest_offset, uint size,
1077 ut::Location src_location);
1078
1079/** NOTE! Please use the corresponding macro os_file_read_no_error_handling(),
1080not directly this function!
1081This is the performance schema instrumented wrapper function for
1082os_file_read_no_error_handling_func() which requests a synchronous
1083read operation.
1084@param[in, out] type IO request context
1085@param[in] file_name file name
1086@param[in] file Open file handle
1087@param[out] buf buffer where to read
1088@param[in] offset file offset where to read
1089@param[in] n number of bytes to read
1090@param[out] o number of bytes actually read
1091@param[in] src_location location where func invoked
1092@return DB_SUCCESS if request was successful */
1094 IORequest &type, const char *file_name, pfs_os_file_t file, void *buf,
1095 os_offset_t offset, ulint n, ulint *o, ut::Location src_location);
1096
1097/** NOTE! Please use the corresponding macro
1098os_file_read_no_error_handling_int_fd(), not directly this function!
1099This is the performance schema instrumented wrapper function for
1100os_file_read_no_error_handling_int_fd_func() which requests a
1101synchronous read operation on files with int type descriptors.
1102@param[in, out] type IO request context
1103@param[in] file_name file name
1104@param[in] file Open file handle
1105@param[out] buf buffer where to read
1106@param[in] offset file offset where to read
1107@param[in] n number of bytes to read
1108@param[out] o number of bytes actually read
1109@param[in] src_location location where func invoked
1110@return DB_SUCCESS if request was successful */
1111
1113 IORequest &type, const char *file_name, int file, void *buf,
1114 os_offset_t offset, ulint n, ulint *o, ut::Location src_location);
1115
1116/** NOTE! Please use the corresponding macro os_aio(), not directly this
1117function!
1118Performance schema wrapper function of os_aio() which requests
1119an asynchronous I/O operation.
1120@param[in] type IO request context
1121@param[in] mode IO mode
1122@param[in] name Name of the file or path as NUL terminated
1123 string
1124@param[in] file Open file handle
1125@param[out] buf buffer where to read
1126@param[in] offset file offset where to read
1127@param[in] n how many bytes to read or write; this
1128must not cross a file boundary; in AIO this must be a block size multiple
1129@param[in] read_only if true read only mode checks are enforced
1130@param[in,out] m1 Message for the AIO handler, (can be used to
1131 identify a completed AIO operation); ignored
1132 if mode is OS_AIO_SYNC
1133@param[in,out] m2 message for the AIO handler (can be used to
1134 identify a completed AIO operation); ignored
1135 if mode is OS_AIO_SYNC
1136@param[in] location location where func invoked
1137@return DB_SUCCESS if request was queued successfully, false if fail */
1139 const char *name, pfs_os_file_t file,
1140 void *buf, os_offset_t offset, ulint n,
1141 bool read_only, fil_node_t *m1, void *m2,
1142 ut::Location location);
1143
1144/** NOTE! Please use the corresponding macro os_file_write(), not directly
1145this function!
1146This is the performance schema instrumented wrapper function for
1147os_file_write() which requests a synchronous write operation.
1148@param[in, out] type IO request context
1149@param[in] name Name of the file or path as NUL terminated
1150 string
1151@param[in] file Open file handle
1152@param[out] buf buffer where to read
1153@param[in] offset file offset where to read
1154@param[in] n number of bytes to read
1155@param[in] src_location location where func invoked
1156@return DB_SUCCESS if request was successful */
1159 const void *buf,
1160 os_offset_t offset, ulint n,
1161 ut::Location src_location);
1162
1163/** NOTE! Please use the corresponding macro os_file_write(), not
1164directly this function!
1165This is the performance schema instrumented wrapper function for
1166os_file_write() which requests a synchronous write operation
1167on files with int type descriptors.
1168@param[in, out] type IO request context
1169@param[in] name Name of the file or path as NUL terminated
1170 string
1171@param[in] file Open file handle
1172@param[out] buf buffer where to read
1173@param[in] offset file offset where to read
1174@param[in] n number of bytes to read
1175@param[in] src_location location where func invoked
1176@return DB_SUCCESS if request was successful */
1178 const char *name, int file,
1179 const void *buf,
1180 os_offset_t offset, ulint n,
1181 ut::Location src_location);
1182
1183/** NOTE! Please use the corresponding macro os_file_flush(), not directly
1184this function!
1185This is the performance schema instrumented wrapper function for
1186os_file_flush() which flushes the write buffers of a given file to the disk.
1187Flushes the write buffers of a given file to the disk.
1188@param[in] file Open file handle
1189@param[in] src_location location where func invoked
1190@return true if success */
1192 ut::Location src_location);
1193
1194/** NOTE! Please use the corresponding macro os_file_rename(), not directly
1195this function!
1196This is the performance schema instrumented wrapper function for
1197os_file_rename()
1198@param[in] key Performance Schema Key
1199@param[in] oldpath old file path as a null-terminated string
1200@param[in] newpath new file path
1201@param[in] src_location location where func invoked
1202@return true if success */
1204 const char *oldpath,
1205 const char *newpath,
1206 ut::Location src_location);
1207
1208/**
1209NOTE! Please use the corresponding macro os_file_delete(), not directly
1210this function!
1211This is the performance schema instrumented wrapper function for
1212os_file_delete()
1213@param[in] key Performance Schema Key
1214@param[in] name old file path as a null-terminated string
1215@param[in] src_location location where func invoked
1216@return true if success */
1218 const char *name,
1219 ut::Location src_location);
1220
1221/**
1222NOTE! Please use the corresponding macro os_file_delete_if_exists(), not
1223directly this function!
1224This is the performance schema instrumented wrapper function for
1225os_file_delete_if_exists()
1226@param[in] key Performance Schema Key
1227@param[in] name old file path as a null-terminated string
1228@param[in] exist indicate if file pre-exist
1229@param[in] src_location location where func invoked
1230@return true if success */
1232 const char *name,
1233 bool *exist,
1234 ut::Location src_location);
1235
1236#else /* UNIV_PFS_IO */
1237
1238/* If UNIV_PFS_IO is not defined, these I/O APIs point
1239to original un-instrumented file I/O APIs */
1240#define os_file_create(key, name, create, purpose, read_only, success) \
1241 os_file_create_func(name, create, purpose, read_only, success)
1242
1243#ifndef _WIN32
1244
1245#define os_file_create_simple_no_error_handling(key, name, create_mode, \
1246 access, read_only, success) \
1247 os_file_create_simple_no_error_handling_func( \
1248 name, create_mode, access, read_only, os_innodb_umask_default, success)
1249
1250#define os_file_create_simple_no_error_handling_with_umask( \
1251 key, name, create_mode, access, read_only, umask, success) \
1252 os_file_create_simple_no_error_handling_func(name, create_mode, access, \
1253 read_only, umask, success)
1254
1255#else
1256
1257#define os_file_create_simple_no_error_handling(key, name, create_mode, \
1258 access, read_only, success) \
1259 os_file_create_simple_no_error_handling_func(name, create_mode, access, \
1260 read_only, success)
1261
1262#endif
1263
1264#define os_file_close_pfs(file) os_file_close_func(file)
1265
1266#define os_aio(type, mode, name, file, buf, offset, n, read_only, message1, \
1267 message2) \
1268 os_aio_func(type, mode, name, file, buf, offset, n, read_only, message1, \
1269 message2)
1270
1271#define os_file_read_pfs(type, file_name, file, buf, offset, n) \
1272 os_file_read_func(type, file_name, file, buf, offset, n)
1273
1274#define os_file_read_first_page_pfs(type, file_name, file, buf, n) \
1275 os_file_read_first_page_func(type, file_name, file, buf, n)
1276
1277#define os_file_copy_pfs(src, src_offset, dest, dest_offset, size) \
1278 os_file_copy_func(src, src_offset, dest, dest_offset, size)
1279
1280#define os_file_read_no_error_handling_pfs(type, file_name, file, buf, offset, \
1281 n, o) \
1282 os_file_read_no_error_handling_func(type, file_name, file, buf, offset, n, o)
1283
1284#define os_file_read_no_error_handling_int_fd(type, file_name, file, buf, \
1285 offset, n, o) \
1286 os_file_read_no_error_handling_func(type, file_name, OS_FILE_FROM_FD(file), \
1287 buf, offset, n, o)
1288
1289#define os_file_write_pfs(type, name, file, buf, offset, n) \
1290 os_file_write_func(type, name, file, buf, offset, n)
1291
1292#define os_file_write_int_fd(type, name, file, buf, offset, n) \
1293 os_file_write_func(type, name, OS_FILE_FROM_FD(file), buf, offset, n)
1294
1295#define os_file_flush_pfs(file) os_file_flush_func(file)
1296
1297#define os_file_rename(key, oldpath, newpath) \
1298 os_file_rename_func(oldpath, newpath)
1299
1300#define os_file_delete(key, name) os_file_delete_func(name)
1301
1302#define os_file_delete_if_exists(key, name, exist) \
1303 os_file_delete_if_exists_func(name, exist)
1304
1305#endif /* UNIV_PFS_IO */
1306
1307#ifdef UNIV_PFS_IO
1308#define os_file_close(file) os_file_close_pfs(file)
1309#else
1310#define os_file_close(file) os_file_close_pfs((file).m_file)
1311#endif
1312
1313#ifdef UNIV_PFS_IO
1314#define os_file_read(type, file_name, file, buf, offset, n) \
1315 os_file_read_pfs(type, file_name, file, buf, offset, n)
1316#else
1317#define os_file_read(type, file_name, file, buf, offset, n) \
1318 os_file_read_pfs(type, file_name, file.m_file, buf, offset, n)
1319#endif
1320
1321#ifdef UNIV_PFS_IO
1322#define os_file_read_first_page(type, file_name, file, buf, n) \
1323 os_file_read_first_page_pfs(type, file_name, file, buf, n)
1324#else
1325#define os_file_read_first_page(type, file_name, file, buf, n) \
1326 os_file_read_first_page_pfs(type, file_name, file.m_file, buf, n)
1327#endif
1328
1329#ifdef UNIV_PFS_IO
1330#define os_file_flush(file) os_file_flush_pfs(file)
1331#else
1332#define os_file_flush(file) os_file_flush_pfs(file.m_file)
1333#endif
1334
1335#ifdef UNIV_PFS_IO
1336#define os_file_write(type, name, file, buf, offset, n) \
1337 os_file_write_pfs(type, name, file, buf, offset, n)
1338#else
1339#define os_file_write(type, name, file, buf, offset, n) \
1340 os_file_write_pfs(type, name, file.m_file, buf, offset, n)
1341#endif
1342
1343#ifdef UNIV_PFS_IO
1344#define os_file_copy(src, src_offset, dest, dest_offset, size) \
1345 os_file_copy_pfs(src, src_offset, dest, dest_offset, size)
1346#else
1347#define os_file_copy(src, src_offset, dest, dest_offset, size) \
1348 os_file_copy_pfs(src.m_file, src_offset, dest.m_file, dest_offset, size)
1349#endif
1350
1351#ifdef UNIV_PFS_IO
1352#define os_file_read_no_error_handling(type, file_name, file, buf, offset, n, \
1353 o) \
1354 os_file_read_no_error_handling_pfs(type, file_name, file, buf, offset, n, o)
1355#else
1356#define os_file_read_no_error_handling(type, file_name, file, buf, offset, n, \
1357 o) \
1358 os_file_read_no_error_handling_pfs(type, file_name, file.m_file, buf, \
1359 offset, n, o)
1360#endif
1361
1362#ifdef UNIV_HOTBACKUP
1363/** Closes a file handle.
1364@param[in] file handle to a file
1365@return true if success */
1366bool os_file_close_no_error_handling(os_file_t file);
1367#endif /* UNIV_HOTBACKUP */
1368
1369/** Gets a file size.
1370@param[in] filename Full path to the filename to check
1371@return file size if OK, else set m_total_size to ~0 and m_alloc_size to
1372 errno. */
1373[[nodiscard]] os_file_size_t os_file_get_size(const char *filename);
1374
1375/** Gets a file size.
1376@param[in] file Handle to a file
1377@return file size, or (os_offset_t) -1 on failure */
1379
1380/** Allocate a block to file using fallocate from the given offset if
1381fallocate is supported. Falls back to the old slower method of writing
1382zeros otherwise.
1383@param[in] name name of the file
1384@param[in] file handle to the file
1385@param[in] offset file offset
1386@param[in] size file size
1387@param[in] flush flush file content to disk
1388@return true if success */
1389[[nodiscard]] bool os_file_set_size_fast(const char *name, pfs_os_file_t file,
1391 bool flush);
1392
1393/** Write the specified number of zeros to a file from specific offset.
1394@param[in] name name of the file or path as a null-terminated
1395 string
1396@param[in] file handle to a file
1397@param[in] offset file offset
1398@param[in] size file size
1399@param[in] flush flush file content to disk
1400@return true if success */
1401[[nodiscard]] bool os_file_set_size(const char *name, pfs_os_file_t file,
1403 bool flush);
1404
1405/** Truncates a file at its current position.
1406@param[in,out] file file to be truncated
1407@return true if success */
1408bool os_file_set_eof(FILE *file); /*!< in: file to be truncated */
1409
1410/** Truncates a file to a specified size in bytes.
1411Do nothing if the size to preserve is greater or equal to the current
1412size of the file.
1413@param[in] pathname file path
1414@param[in] file file to be truncated
1415@param[in] size size to preserve in bytes
1416@return true if success */
1417bool os_file_truncate(const char *pathname, pfs_os_file_t file,
1419
1420/** Set read/write position of a file handle to specific offset.
1421@param[in] pathname file path
1422@param[in] file file handle
1423@param[in] offset read/write offset
1424@return true if success */
1425bool os_file_seek(const char *pathname, os_file_t file, os_offset_t offset);
1426
1427/** NOTE! Use the corresponding macro os_file_flush(), not directly this
1428function!
1429Flushes the write buffers of a given file to the disk.
1430@param[in] file handle to a file
1431@return true if success */
1433
1434/** Retrieves the last error number if an error occurs in a file io function.
1435The number should be retrieved before any other OS calls (because they may
1436overwrite the error number). If the number is not known to this program,
1437the OS error number + 100 is returned.
1438@param[in] report_all_errors true if we want an error message printed
1439 for all errors
1440@return error number, or OS error number + 100 */
1441ulint os_file_get_last_error(bool report_all_errors);
1442
1443/** NOTE! Use the corresponding macro os_file_read_first_page(), not directly
1444this function!
1445Requests a synchronous read operation of page 0 of IBD file.
1446@param[in] type IO request context
1447@param[in] file_name file name
1448@param[in] file Open file handle
1449@param[out] buf buffer where to read
1450@param[in] offset file offset where to read
1451@param[in] n number of bytes to read
1452@return DB_SUCCESS if request was successful, DB_IO_ERROR on failure */
1453[[nodiscard]] dberr_t os_file_read_func(IORequest &type, const char *file_name,
1454 os_file_t file, void *buf,
1455 os_offset_t offset, ulint n);
1456
1457/** NOTE! Use the corresponding macro os_file_read_first_page(),
1458not directly this function!
1459Requests a synchronous read operation of page 0 of IBD file
1460@param[in] type IO request context
1461@param[in] file_name file name
1462@param[in] file Open file handle
1463@param[out] buf buffer where to read
1464@param[in] n number of bytes to read
1465@return DB_SUCCESS if request was successful, DB_IO_ERROR on failure */
1467 const char *file_name,
1468 os_file_t file, void *buf,
1469 ulint n);
1470
1471/** Copy data from one file to another file. Data is read/written
1472at current file offset.
1473@param[in] src_file file handle to copy from
1474@param[in] src_offset offset to copy from
1475@param[in] dest_file file handle to copy to
1476@param[in] dest_offset offset to copy to
1477@param[in] size number of bytes to copy
1478@return DB_SUCCESS if successful */
1479[[nodiscard]] dberr_t os_file_copy_func(os_file_t src_file,
1480 os_offset_t src_offset,
1481 os_file_t dest_file,
1482 os_offset_t dest_offset, uint size);
1483
1484/** Rewind file to its start, read at most size - 1 bytes from it to str, and
1485NUL-terminate str. All errors are silently ignored. This function is
1486mostly meant to be used with temporary files.
1487@param[in,out] file File to read from
1488@param[in,out] str Buffer where to read
1489@param[in] size Size of buffer */
1490void os_file_read_string(FILE *file, char *str, ulint size);
1491
1492/** NOTE! Use the corresponding macro os_file_read_no_error_handling(),
1493not directly this function!
1494Requests a synchronous positioned read operation. This function does not do
1495any error handling. In case of error it returns false.
1496@param[in] type IO request context
1497@param[in] file_name file name
1498@param[in] file Open file handle
1499@param[out] buf buffer where to read
1500@param[in] offset file offset where to read
1501@param[in] n number of bytes to read
1502@param[out] o number of bytes actually read
1503@return DB_SUCCESS or error code */
1505 IORequest &type, const char *file_name, os_file_t file, void *buf,
1506 os_offset_t offset, ulint n, ulint *o);
1507
1508/** NOTE! Use the corresponding macro os_file_write(), not directly this
1509function!
1510Requests a synchronous write operation.
1511@param[in,out] type IO request context
1512@param[in] name name of the file or path as a null-terminated
1513 string
1514@param[in] file Open file handle
1515@param[out] buf buffer where to read
1516@param[in] offset file offset where to read
1517@param[in] n number of bytes to read
1518@return DB_SUCCESS if request was successful */
1519[[nodiscard]] dberr_t os_file_write_func(IORequest &type, const char *name,
1520 os_file_t file, const void *buf,
1521 os_offset_t offset, ulint n);
1522
1523/** Check the existence and type of a given path.
1524@param[in] path pathname of the file
1525@param[out] exists true if file exists
1526@param[out] type type of the file (if it exists)
1527@return true if call succeeded */
1528bool os_file_status(const char *path, bool *exists, os_file_type_t *type);
1529
1530/** Check the existence and usefulness of a given path.
1531@param[in] path path name
1532@retval true if the path exists and can be used
1533@retval false if the path does not exist or if the path is
1534unusable to get to a possibly existing file or directory. */
1535bool os_file_exists(const char *path);
1536
1537/** Create all missing subdirectories along the given path.
1538@return DB_SUCCESS if OK, otherwise error code. */
1540
1541#ifdef UNIV_ENABLE_UNIT_TEST_GET_PARENT_DIR
1542/* Test the function os_file_get_parent_dir. */
1543void unit_test_os_file_get_parent_dir();
1544#endif /* UNIV_ENABLE_UNIT_TEST_GET_PARENT_DIR */
1545
1546#ifdef UNIV_HOTBACKUP
1547/** Deallocates the "Blocks" in block_cache */
1548void meb_free_block_cache();
1549#endif /* UNIV_HOTBACKUP */
1550
1551/** Creates and initializes block_cache. Creates array of MAX_BLOCKS
1552and allocates the memory in each block to hold BUFFER_BLOCK_SIZE
1553of data.
1554
1555This function is called by InnoDB during srv_start().
1556It is also called by MEB while applying the redo logs on TDE tablespaces,
1557the "Blocks" allocated in this block_cache are used to hold the decrypted
1558page data. */
1560
1561/** Initializes the asynchronous io system.
1562Creates an array for ibuf i/o (if not in read-only mode).
1563Also creates one array each for read and write where each
1564array is divided logically into n_readers and n_writers
1565respectively. The caller must create an i/o handler thread for each
1566segment in these arrays by calling os_aio_start_threads().
1567
1568@param[in] n_readers number of reader threads
1569@param[in] n_writers number of writer threads */
1570bool os_aio_init(ulint n_readers, ulint n_writers);
1571
1572/** Starts one thread for each segment created in os_aio_init */
1574
1575/**
1576Frees the asynchronous io system. */
1577void os_aio_free();
1578
1579/**
1580NOTE! Use the corresponding macro os_aio(), not directly this function!
1581Requests an asynchronous i/o operation.
1582@param[in] type IO request context
1583@param[in] aio_mode IO mode
1584@param[in] name Name of the file or path as NUL terminated
1585string
1586@param[in] file Open file handle
1587@param[out] buf buffer where to read
1588@param[in] offset file offset where to read
1589@param[in] n how many bytes to read or write; this
1590must not cross a file boundary; in AIO this must be a block size multiple
1591@param[in] read_only if true read only mode checks are enforced
1592@param[in,out] m1 Message for the AIO handler, (can be used to
1593identify a completed AIO operation); ignored if mode is OS_AIO_SYNC
1594@param[in,out] m2 message for the AIO handler (can be used to
1595identify a completed AIO operation); ignored if mode is OS_AIO_SYNC
1596@return DB_SUCCESS or error code */
1597dberr_t os_aio_func(IORequest &type, AIO_mode aio_mode, const char *name,
1598 pfs_os_file_t file, void *buf, os_offset_t offset, ulint n,
1599 bool read_only, fil_node_t *m1, void *m2);
1600
1601/** Wakes up all async i/o threads so that they know to exit themselves in
1602shutdown. */
1604
1605/** Waits until there are no pending writes in os_aio_write_array. There can
1606be other, synchronous, pending writes. */
1608
1609/** Wakes up simulated aio i/o-handler threads if they have something to do. */
1611
1612/** This function can be called if one wants to post a batch of reads and
1613prefers an i/o-handler thread to handle them all at once later. You must
1614call os_aio_simulated_wake_handler_threads later to ensure the threads
1615are not left sleeping! */
1617
1618/** Waits for an AIO operation to complete. This function is used to wait the
1619for completed requests. The AIO array of pending requests is divided
1620into segments. The thread specifies which segment or slot it wants to wait
1621for. NOTE: this function will also take care of freeing the AIO slot,
1622therefore no other thread is allowed to do the freeing!
1623@param[in] segment The number of the segment in the AIO arrays to
1624 wait for; segment 0 is the ibuf I/O thread,
1625 then follow the non-ibuf read threads,
1626 and as the last are the non-ibuf write threads
1627@param[out] m1 the messages passed with the AIO request; note
1628 that also in the case where the AIO operation
1629 failed, these output parameters are valid and
1630 can be used to restart the operation,
1631 for example
1632@param[out] m2 callback message
1633@param[out] request OS_FILE_WRITE or ..._READ
1634@return DB_SUCCESS or error code */
1635dberr_t os_aio_handler(ulint segment, fil_node_t **m1, void **m2,
1636 IORequest *request);
1637
1638/** Prints info of the aio arrays.
1639@param[in,out] file file where to print */
1640void os_aio_print(FILE *file);
1641
1642/** Refreshes the statistics used to print per-second averages. */
1644
1645/** Checks that all slots in the system have been freed, that is, there are
1646no pending io operations. */
1648
1649#ifdef UNIV_DEBUG
1650
1651/** Prints all pending IO
1652@param[in] file File where to print */
1654
1655#endif /* UNIV_DEBUG */
1656
1657/** Get available free space on disk
1658@param[in] path pathname of a directory or file in disk
1659@param[out] free_space free space available in bytes
1660@return DB_SUCCESS if all OK */
1661dberr_t os_get_free_space(const char *path, uint64_t &free_space);
1662
1663/** This function returns information about the specified file
1664@param[in] path pathname of the file
1665@param[out] stat_info information of a file in a directory
1666@param[in] check_rw_perm for testing whether the file can be opened
1667 in RW mode
1668@param[in] read_only true if file is opened in read-only mode
1669@return DB_SUCCESS if all OK */
1670dberr_t os_file_get_status(const char *path, os_file_stat_t *stat_info,
1671 bool check_rw_perm, bool read_only);
1672
1673/** Check if a file can be opened in read-write mode.
1674 @param[in] name filename to check
1675 @param[in] read_only true if check for read-only mode only
1676 @retval true if file can be opened in the specified mode (rw or ro);
1677 or file does not exist
1678 @retval false if file exists and can't be opened in the specified mode */
1679bool os_file_check_mode(const char *name, bool read_only);
1680
1681#ifndef UNIV_HOTBACKUP
1682
1683/** return any of the tmpdir path */
1684char *innobase_mysql_tmpdir();
1685
1686/** Creates a temporary file in the location specified by the parameter
1687path. If the path is NULL, then it will be created in --tmpdir.
1688@param[in] path location for creating temporary file
1689@return temporary file descriptor, or OS_FD_CLOSED on error */
1691
1692#endif /* !UNIV_HOTBACKUP */
1693
1694/** If it is a compressed page return the compressed page data + footer size
1695@param[in] buf Buffer to check, must include header + 10 bytes
1696@return ULINT_UNDEFINED if the page is not a compressed page or length
1697 of the compressed data (including footer) if it is a compressed page */
1699
1700/** If it is a compressed page return the original page data + footer size
1701@param[in] buf Buffer to check, must include header + 10 bytes
1702@return ULINT_UNDEFINED if the page is not a compressed page or length
1703 of the original data + footer if it is a compressed page */
1705
1706#ifndef _WIN32
1707/** Set the global file create umask. This value is to be set once, at startup
1708and never modified.
1709@param[in] umask The umask to use for all InnoDB file creation.
1710*/
1711void os_file_set_umask(mode_t umask);
1712
1713/** A magic constant for the umask parameter that indicates caller wants the
1714`os_innodb_umask` value to be used. The `os_innodb_umask` is a static value,
1715private to this module, and to the file creation methods, so it should not be
1716used directly. */
1717constexpr mode_t os_innodb_umask_default = std::numeric_limits<mode_t>::max();
1718
1719#endif
1720
1721/** Free storage space associated with a section of the file.
1722@param[in] fh Open file handle
1723@param[in] off Starting offset (SEEK_SET)
1724@param[in] len Size of the hole
1725@return DB_SUCCESS or error code */
1726[[nodiscard]] dberr_t os_file_punch_hole(os_file_t fh, os_offset_t off,
1727 os_offset_t len);
1728
1729/** Check if the file system supports sparse files.
1730
1731Warning: On POSIX systems we try and punch a hole from offset 0 to
1732the system configured page size. This should only be called on an empty
1733file.
1734
1735Note: On Windows we use the name and on Unices we use the file handle.
1736
1737@param[in] fh File handle for the file - if opened
1738@return true if the file system supports sparse files */
1739[[nodiscard]] bool os_is_sparse_file_supported(pfs_os_file_t fh);
1740
1741/** Decompress the page data contents. Page type must be FIL_PAGE_COMPRESSED, if
1742not then the source contents are left unchanged and DB_SUCCESS is returned.
1743@param[in] dblwr_read true of double write recovery in progress
1744@param[in,out] src Data read from disk, decompressed data will be
1745 copied to this page
1746@param[in,out] dst Scratch area to use for decompression or
1747 nullptr.
1748@param[in] dst_len If dst is valid, then size of the scratch area
1749 in bytes
1750@return DB_SUCCESS or error code */
1751[[nodiscard]] dberr_t os_file_decompress_page(bool dblwr_read, byte *src,
1752 byte *dst, ulint dst_len);
1753
1754/** Compress a data page
1755@param[in] compression Compression algorithm
1756@param[in] block_size File system block size
1757@param[in] src Source contents to compress
1758@param[in] src_len Length in bytes of the source
1759@param[out] dst Compressed page contents
1760@param[out] dst_len Length in bytes of dst contents
1761@return buffer data, dst_len will have the length of the data */
1762byte *os_file_compress_page(Compression compression, ulint block_size,
1763 byte *src, ulint src_len, byte *dst,
1764 ulint *dst_len);
1765
1766/** Determine if O_DIRECT is supported.
1767@retval true if O_DIRECT is supported.
1768@retval false if O_DIRECT is not supported. */
1769[[nodiscard]] bool os_is_o_direct_supported();
1770
1771/** Fill the pages with NULs
1772@param[in] file File handle
1773@param[in] name File name
1774@param[in] page_size physical page size
1775@param[in] start Offset from the start of the file in bytes
1776@param[in] len Length in bytes
1777@return DB_SUCCESS or error code */
1778[[nodiscard]] dberr_t os_file_write_zeros(pfs_os_file_t file, const char *name,
1779 ulint page_size, os_offset_t start,
1780 ulint len);
1781
1782#ifndef UNIV_NONINL
1783/** Class to scan the directory hierarchy using a depth first scan. */
1785 public:
1786 using Path = std::string;
1787
1788 /** Check if the path is a directory. The file/directory must exist.
1789 @param[in] path The path to check
1790 @return true if it is a directory */
1791 static bool is_directory(const Path &path);
1792
1793 /** Depth first traversal of the directory starting from basedir
1794 @param[in] basedir Start scanning from this directory
1795 @param[in] recursive `true` if scan should be recursive
1796 @param[in] f Function to call for each entry */
1797 template <typename F>
1798 static void walk(const Path &basedir, bool recursive, F &&f) {
1799#ifdef _WIN32
1800 walk_win32(basedir, recursive, [&](const Path &path, size_t) { f(path); });
1801#else
1802 walk_posix(basedir, recursive, [&](const Path &path, size_t) { f(path); });
1803#endif /* _WIN32 */
1804 }
1805
1806 private:
1807 /** Directory names for the depth first directory scan. */
1808 struct Entry {
1809 /** Constructor
1810 @param[in] path Directory to traverse
1811 @param[in] depth Relative depth to the base
1812 directory in walk() */
1813 Entry(const Path &path, size_t depth) : m_path(path), m_depth(depth) {}
1814
1815 /** Path to the directory */
1817
1818 /** Relative depth of m_path */
1819 size_t m_depth;
1820 };
1821
1822 using Function = std::function<void(const Path &, size_t)>;
1823
1824 /** Depth first traversal of the directory starting from basedir
1825 @param[in] basedir Start scanning from this directory
1826 @param[in] recursive `true` if scan should be recursive
1827 @param[in] f Function to call for each entry */
1828#ifdef _WIN32
1829 static void walk_win32(const Path &basedir, bool recursive, Function &&f);
1830#else
1831 static void walk_posix(const Path &basedir, bool recursive, Function &&f);
1832#endif /* _WIN32 */
1833};
1834
1835/** Allocate a page for sync IO
1836@return pointer to page */
1837[[nodiscard]] file::Block *os_alloc_block() noexcept;
1838
1839/** Get the sector aligned frame pointer.
1840@param[in] block the memory block containing the page frame.
1841@return the sector aligned frame pointer. */
1842[[nodiscard]] byte *os_block_get_frame(const file::Block *block) noexcept;
1843
1844/** Free a page after sync IO
1845@param[in,out] block The block to free/release */
1846void os_free_block(file::Block *block) noexcept;
1847
1848inline void file::Block::free(file::Block *obj) noexcept { os_free_block(obj); }
1849
1850/** Encrypt a page content when write it to disk.
1851@param[in] type IO flags
1852@param[out] buf buffer to read or write
1853@param[in] n number of bytes to read/write, starting from
1854 offset
1855@return pointer to the encrypted page */
1857
1858/** Allocate the buffer for IO on a transparently compressed table.
1859@param[in] type IO flags
1860@param[out] buf buffer to read or write
1861@param[in,out] n number of bytes to read/write, starting from
1862 offset
1863@return pointer to allocated page, compressed data is written to the offset
1864 that is aligned on the disk sector size */
1866
1867/** This is a wrapper function for the os_file_write() function call. The
1868purpose of this wrapper function is to retry on i/o error. On I/O error
1869(perhaps because of disk full situation) keep retrying the write operation
1870till it succeeds.
1871@param[in] type IO flags
1872@param[in] name name of the file or path as a null-terminated string
1873@param[in] file handle to an open file
1874@param[out] buf buffer from which to write
1875@param[in] offset file offset from the start where to read
1876@param[in] n number of bytes to read, starting from offset
1877@return DB_SUCCESS if request was successful, false if fail */
1879 pfs_os_file_t file, const void *buf,
1880 os_offset_t offset, ulint n);
1881
1882/** Helper class for doing synchronous file IO. Currently, the objective
1883is to hide the OS specific code, so that the higher level functions aren't
1884peppered with "#ifdef". Makes the code flow difficult to follow. */
1886 public:
1887 /** Constructor
1888 @param[in] fh File handle
1889 @param[in,out] buf Buffer to read/write
1890 @param[in] n Number of bytes to read/write
1891 @param[in] offset Offset where to read or write */
1893 : m_fh(fh),
1894 m_buf(buf),
1895 m_n(static_cast<ssize_t>(n)),
1896 m_offset(offset),
1897 m_orig_bytes(n) {
1898 ut_ad(m_n > 0);
1899 }
1900
1901 /** Destructor */
1902 ~SyncFileIO() = default;
1903
1904 /** Do the read/write
1905 @param[in] request The IO context and type
1906 @return the number of bytes read/written or negative value on error */
1907 ssize_t execute(const IORequest &request);
1908
1909 /** Do the read/write with retry.
1910 @param[in] request The IO context and type
1911 @param[in] max_retries the maximum number of retries on partial i/o.
1912 @return DB_SUCCESS on success, an error code on failure. */
1914 const IORequest &request,
1915 const size_t max_retries = NUM_RETRIES_ON_PARTIAL_IO);
1916
1917 /** Move the read/write offset up to where the partial IO succeeded.
1918 @param[in] n_bytes The number of bytes to advance */
1919 void advance(ssize_t n_bytes) {
1920 m_offset += n_bytes;
1921
1922 ut_ad(m_n >= n_bytes);
1923
1924 m_n -= n_bytes;
1925
1926 m_buf = reinterpret_cast<uchar *>(m_buf) + n_bytes;
1927 }
1928
1929 private:
1930 /** Open file handle */
1932
1933 /** Buffer to read/write */
1934 void *m_buf;
1935
1936 /** Number of bytes to read/write */
1937 ssize_t m_n;
1938
1939 /** Offset from where to read/write */
1941
1942 /** The total number of bytes to be read/written. */
1943 const size_t m_orig_bytes;
1944};
1945
1946#include "os0file.ic"
1947#endif /* UNIV_NONINL */
1948
1949#endif /* os0file_h */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
@ NORMAL
Get always.
Class to scan the directory hierarchy using a depth first scan.
Definition: os0file.h:1784
std::string Path
Definition: os0file.h:1786
static bool is_directory(const Path &path)
Check if the path is a directory.
Definition: os0file.cc:7642
static void walk_posix(const Path &basedir, bool recursive, Function &&f)
Depth first traversal of the directory starting from basedir.
Definition: os0file.cc:3569
std::function< void(const Path &, size_t)> Function
Definition: os0file.h:1822
static void walk(const Path &basedir, bool recursive, F &&f)
Depth first traversal of the directory starting from basedir.
Definition: os0file.h:1798
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
The IO Context that is passed down to the low level IO code.
Definition: os0file.h:265
uint32_t m_original_size
Length of the original IO size.
Definition: os0file.h:574
bool is_punch_hole_optimisation_disabled() const
Definition: os0file.h:389
void compression_algorithm(Compression::Type type)
Set compression algorithm.
Definition: os0file.h:453
bool is_dblwr() const
Definition: os0file.h:505
Compression compression_algorithm() const
Get the compression algorithm.
Definition: os0file.h:465
static std::string type_str(const ulint type)
Definition: os0file.cc:7680
bool is_partial_io_warning_disabled() const
Definition: os0file.h:371
void dblwr()
Note that the IO is for double write buffer page write.
Definition: os0file.h:502
void block_size(ulint block_size)
Set the block size for IO.
Definition: os0file.h:428
void clear_encrypted()
Clear all encryption related flags.
Definition: os0file.h:494
void clear_do_not_wake()
Clear the do not wake flag.
Definition: os0file.h:418
bool is_compression_enabled() const
Definition: os0file.h:475
bool is_encrypted() const
Definition: os0file.h:489
ulint block_size() const
Definition: os0file.h:424
void clear_punch_hole()
Clear the punch hole flag.
Definition: os0file.h:421
void disable_partial_io_warnings()
Disable partial read warnings.
Definition: os0file.h:377
@ UNSET
Definition: os0file.h:269
@ DBLWR
Request for a doublewrite page IO.
Definition: os0file.h:274
@ DISABLE_PARTIAL_IO_WARNINGS
Disable partial read warnings.
Definition: os0file.h:285
@ IGNORE_MISSING
Ignore failed reads of non-existent pages.
Definition: os0file.h:297
@ DO_NOT_WAKE
Do not to wake i/o-handler threads, but the caller will do the waking explicitly later,...
Definition: os0file.h:294
@ ROW_LOG
Row log used in online DDL.
Definition: os0file.h:310
@ LOG
Log file request.
Definition: os0file.h:282
@ 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:315
@ NO_COMPRESSION
Force raw read, do not try to compress/decompress.
Definition: os0file.h:307
@ WRITE
Definition: os0file.h:271
@ READ
Definition: os0file.h:270
@ DATA_FILE
Enumerations below can be ORed to READ/WRITE above.
Definition: os0file.h:279
@ PUNCH_HOLE
Use punch hole if available, only makes sense if compression algorithm != NONE.
Definition: os0file.h:301
const file::Block * get_encrypted_block() const noexcept
Get the encrypted block.
Definition: os0file.h:547
std::string to_string() const
Definition: os0file.h:524
uint32_t get_original_size() const
Returns original size of the IO to make.
Definition: os0file.h:434
bool operator==(const IORequest &rhs) const
Compare two requests.
Definition: os0file.h:449
void disable_compression()
Disable transformations.
Definition: os0file.h:480
bool punch_hole() const
Definition: os0file.h:383
IORequest()
Default constructor.
Definition: os0file.h:319
static bool is_punch_hole_supported()
Definition: os0file.h:508
static bool ignore_missing(int type)
Definition: os0file.h:349
void set_original_size(uint32_t original_size)
Definition: os0file.h:436
uint32_t m_block_size
Definition: os0file.h:553
bool ignore_missing() const
Definition: os0file.h:380
Compression m_compression
Compression algorithm.
Definition: os0file.h:559
void set_punch_hole()
Set the punch hole flag.
Definition: os0file.h:404
IORequest(int type)
Definition: os0file.h:332
Encryption & get_encryption_info() noexcept
Get a reference to the underlying encryption information.
Definition: os0file.h:535
uint32_t m_elen
The length of data in encrypted block.
Definition: os0file.h:568
bool is_write() const
Definition: os0file.h:357
bool validate() const
Definition: os0file.h:397
Encryption encryption_algorithm() const
Get the encryption algorithm.
Definition: os0file.h:484
bool is_row_log() const
Definition: os0file.h:363
void set_encrypted_block(const file::Block *eblock) noexcept
Set the encrypted block to the given value.
Definition: os0file.h:541
bool is_compressed() const
Definition: os0file.h:470
bool is_wake() const
Definition: os0file.h:368
void clear_compressed()
Clear all compression related flags.
Definition: os0file.h:441
void disable_punch_hole_optimisation()
Set the force punch hole flag.
Definition: os0file.h:411
const file::Block * m_eblock
The encrypted block.
Definition: os0file.h:565
int m_type
Request type bit flags.
Definition: os0file.h:556
bool is_read() const
Definition: os0file.h:354
bool is_log() const
Definition: os0file.h:360
Encryption m_encryption
Encryption algorithm.
Definition: os0file.h:562
Helper class for doing synchronous file IO.
Definition: os0file.h:1885
~SyncFileIO()=default
Destructor.
os_file_t m_fh
Open file handle.
Definition: os0file.h:1931
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:1993
const size_t m_orig_bytes
The total number of bytes to be read/written.
Definition: os0file.h:1943
SyncFileIO(os_file_t fh, void *buf, ulint n, os_offset_t offset)
Constructor.
Definition: os0file.h:1892
ssize_t m_n
Number of bytes to read/write.
Definition: os0file.h:1937
os_offset_t m_offset
Offset from where to read/write.
Definition: os0file.h:1940
ssize_t execute(const IORequest &request)
Do the read/write.
Definition: os0file.cc:2023
void * m_buf
Buffer to read/write.
Definition: os0file.h:1934
void advance(ssize_t n_bytes)
Move the read/write offset up to where the partial IO succeeded.
Definition: os0file.h:1919
dberr_t
Definition: db0err.h:39
struct PSI_file PSI_file
Definition: psi_file_bits.h:55
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:180
#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:84
static char * path
Definition: mysqldump.cc:149
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1105
Definition: buf0block_hint.cc:30
constexpr value_type read_only
Definition: classic_protocol_constants.h:213
const std::string FILE("FILE")
Definition: os0file.h:89
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:94
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:2872
static int exists(node_address *name, node_list const *nodes, u_int with_uid)
Definition: node_list.cc:106
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:6626
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:5687
constexpr uint32_t OS_FILE_MAX_PATH
Definition: os0file.h:650
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:590
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:3052
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:230
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:3029
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:6249
static const ulint OS_FILE_AIO_INTERRUPTED
Definition: os0file.h:248
os_file_type_t
Definition: os0file.h:616
@ OS_FILE_TYPE_BLOCK
Block device.
Definition: os0file.h:642
@ OS_FILE_PERMISSION_ERROR
stat() failed with EACCESS
Definition: os0file.h:624
@ OS_FILE_TYPE_MISSING
File doesn't exist.
Definition: os0file.h:627
@ OS_FILE_TYPE_NAME_TOO_LONG
stat() failed, with ENAMETOOLONG
Definition: os0file.h:621
@ OS_FILE_TYPE_UNKNOWN
File exists but type is unknown.
Definition: os0file.h:630
@ OS_FILE_TYPE_DIR
Directory.
Definition: os0file.h:636
@ OS_FILE_TYPE_FAILED
Get status failed.
Definition: os0file.h:618
@ OS_FILE_TYPE_LINK
Symbolic link.
Definition: os0file.h:639
@ OS_FILE_TYPE_FILE
Ordinary file.
Definition: os0file.h:633
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:5484
AIO_mode
Modes for aio operations.
Definition: os0file.h:593
@ 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.
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: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:3389
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: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!...
void os_aio_free()
Frees the asynchronous io system.
Definition: os0file.cc:6265
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:5333
static const ulint OS_FILE_ERROR_NOT_SPECIFIED
Definition: os0file.h:246
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:3086
std::function< void(const char *path, const char *name)> os_dir_cbk_t
Callback function type to be implemented by caller.
Definition: os0file.h:694
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:821
static constexpr os_fd_t OS_FD_CLOSED
Definition: os0file.h:117
bool os_is_sparse_file_supported(pfs_os_file_t fh)
Check if the file system supports sparse files.
Definition: os0file.cc:5721
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:5649
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:5708
int os_fd_t
Raw file handle.
Definition: os0file.h:115
void os_create_block_cache()
Creates and initializes block_cache.
Definition: os0file.cc:6209
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:5447
mysql_pfs_key_t innodb_arch_file_key
static const ulint OS_FILE_PATH_ERROR
Definition: os0file.h:240
void os_aio_wait_until_no_pending_writes()
Waits until there are no pending writes in os_aio_write_array.
Definition: os0file.cc:6319
static const ulint OS_DBLWR_FILE
Definition: os0file.h:233
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:5302
static const ulint OS_FILE_NOT_FOUND
Error codes from os_file_get_last_error.
Definition: os0file.h:237
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!...
void os_file_set_umask(mode_t umask)
Set the global file create umask.
Definition: os0file.cc:7631
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:6801
static const ulint OS_FILE_SHARING_VIOLATION
Definition: os0file.h:245
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:819
static const ulint OS_FILE_READ_ALLOW_DELETE
Used by MySQLBackup.
Definition: os0file.h:219
unsigned long long os_fsync_threshold
Definition: os0file.cc:108
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:6289
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:1717
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, mode_t umask, bool *success, ut::Location src_location)
Clang on Windows warns about umask not found.
static const ulint OS_FILE_NAME_TOO_LONG
Definition: os0file.h:251
pfs_os_file_t os_file_create_simple_no_error_handling_func(const char *name, ulint create_mode, ulint access_type, bool read_only, mode_t umask, bool *success)
Clang on Windows warns about umask not found.
Definition: os0file.cc:3235
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:7659
static const ulint OS_FILE_ERROR_MAX
Definition: os0file.h:254
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:3544
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:5695
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:2992
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:5256
static const ulint OS_FILE_ALREADY_EXISTS
Definition: os0file.h:239
static const ulint OS_FILE_DISK_FULL
Definition: os0file.h:238
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:3358
void os_aio_print(FILE *file)
Prints info of the aio arrays.
Definition: os0file.cc:7491
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
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:5858
constexpr size_t NUM_RETRIES_ON_PARTIAL_IO
Number of retries for partial I/O's.
Definition: os0file.h:76
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:5502
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:5755
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:7583
bool os_file_delete_func(const char *name)
Deletes a file.
Definition: os0file.cc:3337
static const ulint OS_FILE_READ_WRITE
Definition: os0file.h:216
static const ulint OS_FILE_ACCESS_VIOLATION
Definition: os0file.h:250
dberr_t os_get_free_space(const char *path, uint64_t &free_space)
Get available free space on disk.
Definition: os0file.cc:5736
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:7564
os_file_size_t os_file_get_size(const char *filename)
Gets a file size.
Definition: os0file.cc:3413
static const ulint OS_FILE_AIO_RESOURCES_RESERVED
wait for OS aio resources to become available again
Definition: os0file.h:243
static const ulint OS_CLONE_DATA_FILE
Definition: os0file.h:231
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:5135
static const ulint OS_FILE_OPERATION_ABORTED
Definition: os0file.h:249
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:3562
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:5425
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
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:2472
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:5783
static const ulint OS_FILE_INSUFFICIENT_RESOURCE
Definition: os0file.h:247
static constexpr os_fd_t OS_FILE_CLOSED
Definition: os0file.h:151
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:5816
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:7625
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:5638
char * innobase_mysql_tmpdir()
return any of the tmpdir path
Definition: ha_innodb.cc:2470
uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:87
static const ulint OS_FILE_TOO_MANY_OPENED
Definition: os0file.h:252
static const ulint OS_LOG_FILE_RESIZING
Definition: os0file.h:225
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:5670
void os_aio_start_threads()
Starts one thread for each segment created in os_aio_init.
Definition: os0file.cc:6262
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:3301
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.
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:1808
Entry(const Path &path, size_t depth)
Constructor.
Definition: os0file.h:1813
Path m_path
Path to the directory.
Definition: os0file.h:1816
size_t m_depth
Relative depth of m_path.
Definition: os0file.h:1819
File node of a tablespace or the log data space.
Definition: fil0fil.h:155
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:1848
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:580
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:586
os_offset_t m_total_size
Total size of file in bytes.
Definition: os0file.h:582
Struct used in fetching information of a file in a directory.
Definition: os0file.h:655
uint32_t block_size
Block size to use for IO in bytes.
Definition: os0file.h:661
time_t ctime
creation time
Definition: os0file.h:663
char name[OS_FILE_MAX_PATH]
path to a file
Definition: os0file.h:656
time_t atime
access time
Definition: os0file.h:665
bool rw_perm
true if can be opened in read-write mode.
Definition: os0file.h:666
os_file_type_t type
file type
Definition: os0file.h:657
os_offset_t size
file size in bytes
Definition: os0file.h:658
os_offset_t alloc_size
Allocated size for sparse files in bytes.
Definition: os0file.h:659
time_t mtime
modification time
Definition: os0file.h:664
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
Definition: ut0core.h:36
Include file for Sun RPC to compile out of the box.
static const size_t UNIV_SECTOR_SIZE
Definition: univ.i:639
unsigned long int ulint
Definition: univ.i:406
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:105
#define HANDLE
Definition: violite.h:159
int n
Definition: xcom_base.cc:509