MySQL 9.3.0
Source Code Documentation
os0file.h
Go to the documentation of this file.
1/***********************************************************************
2
3Copyright (c) 1995, 2025, 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;
235/** @} */
236
237/** Error codes from os_file_get_last_error @{ */
238static const ulint OS_FILE_NOT_FOUND = 71;
239static const ulint OS_FILE_DISK_FULL = 72;
241static const ulint OS_FILE_PATH_ERROR = 74;
242
243/** wait for OS aio resources to become available again */
245
252static const ulint OS_FILE_NAME_TOO_LONG = 82;
254
255static const ulint OS_FILE_ERROR_MAX = 100;
256/** @} */
257
258/** Types for AIO operations @{ */
259
260/** No transformations during read/write, write as is. */
261#define IORequestRead IORequest(IORequest::READ)
262#define IORequestWrite IORequest(IORequest::WRITE)
263
264/**
265The IO Context that is passed down to the low level IO code */
267 public:
268 /** Flags passed in the request, they can be ORred together. */
269 enum {
270 UNSET = 0,
271 READ = 1,
272 WRITE = 2,
273
274 /** Request for a doublewrite page IO */
275 DBLWR = 4,
276
277 /** Enumerations below can be ORed to READ/WRITE above*/
278
279 /** Data file */
281
282 /** Log file request*/
283 LOG = 16,
284
285 /** Disable partial read warnings */
287
288 /** Do not to wake i/o-handler threads, but the caller will do
289 the waking explicitly later, in this way the caller can post
290 several requests in a batch; NOTE that the batch must not be
291 so big that it exhausts the slots in AIO arrays! NOTE that
292 a simulated batch may introduce hidden chances of deadlocks,
293 because I/Os are not actually handled until all
294 have been posted: use with great caution! */
296
297 /** Ignore failed reads of non-existent pages */
299
300 /** Use punch hole if available, only makes sense if
301 compression algorithm != NONE. Ignored if not set */
303
304 /** Force raw read, do not try to compress/decompress.
305 This can be used to force a read and write without any
306 compression e.g., for redo log, merge sort temporary files
307 and the truncate redo log. */
309
310 /** Row log used in online DDL */
311 ROW_LOG = 1024,
312
313 /** We optimise cases where punch hole is not done if the compressed length
314 of the page is the same as the original size of the page. Ignore such
315 optimisations if this flag is set. */
317 };
318
319 /** Default constructor */
322 m_type(READ),
324 m_encryption(),
326 m_elen(0) {
327 /* No op */
328 }
329
330 /**
331 @param[in] type Request type, can be a value that is
332 ORed from the above enum */
333 explicit IORequest(int type)
335 m_type(type),
337 m_encryption(),
339 m_elen(0) {
340 if (is_log() || is_row_log()) {
342 }
343
346 }
347 }
348
349 /** @return true if ignore missing flag is set */
350 [[nodiscard]] static bool ignore_missing(int type) {
351 return ((type & IGNORE_MISSING) == IGNORE_MISSING);
352 }
353
354 /** @return true if it is a read request */
355 [[nodiscard]] bool is_read() const { return ((m_type & READ) == READ); }
356
357 /** @return true if it is a write request */
358 [[nodiscard]] bool is_write() const { return ((m_type & WRITE) == WRITE); }
359
360 /** @return true if it is a redo log write */
361 [[nodiscard]] bool is_log() const { return ((m_type & LOG) == LOG); }
362
363 /** @return true if it is a row log entry used in online DDL */
364 [[nodiscard]] bool is_row_log() const {
365 return ((m_type & ROW_LOG) == ROW_LOG);
366 }
367
368 /** @return true if the simulated AIO thread should be woken up */
369 [[nodiscard]] bool is_wake() const { return ((m_type & DO_NOT_WAKE) == 0); }
370
371 /** @return true if partial read warning disabled */
372 [[nodiscard]] bool is_partial_io_warning_disabled() const {
375 }
376
377 /** Disable partial read warnings */
379
380 /** @return true if missing files should be ignored */
381 [[nodiscard]] bool ignore_missing() const { return (ignore_missing(m_type)); }
382
383 /** @return true if punch hole should be used */
384 [[nodiscard]] bool punch_hole() const {
385 return ((m_type & PUNCH_HOLE) == PUNCH_HOLE);
386 }
387
388 /** @return true if punch hole needs to be done always if it's supported and
389 if the page is to be compressed. */
390 [[nodiscard]] bool is_punch_hole_optimisation_disabled() const {
392
395 }
396
397 /** @return true if the read should be validated */
398 [[nodiscard]] bool validate() const {
399 ut_ad(is_read() ^ is_write());
400
401 return (!is_read() || !punch_hole());
402 }
403
404 /** Set the punch hole flag */
408 }
409 }
410
411 /** Set the force punch hole flag */
415 }
416 }
417
418 /** Clear the do not wake flag */
419 void clear_do_not_wake() { m_type &= ~DO_NOT_WAKE; }
420
421 /** Clear the punch hole flag */
422 void clear_punch_hole() { m_type &= ~PUNCH_HOLE; }
423
424 /** @return the block size to use for IO */
425 [[nodiscard]] ulint block_size() const { return (m_block_size); }
426
427 /** Set the block size for IO
428 @param[in] block_size Block size to set */
430 m_block_size = static_cast<uint32_t>(block_size);
431 }
432
433 /** Returns original size of the IO to make. If one was not specified, then 0
434 is returned. */
435 uint32_t get_original_size() const { return m_original_size; }
436
437 void set_original_size(uint32_t original_size) {
438 m_original_size = original_size;
439 }
440
441 /** Clear all compression related flags */
444
446 }
447
448 /** Compare two requests
449 @return true if the are equal */
450 bool operator==(const IORequest &rhs) const { return (m_type == rhs.m_type); }
451
452 /** Set compression algorithm
453 @param[in] type The compression algorithm to use */
455 if (type == Compression::NONE) {
456 return;
457 }
458
460
462 }
463
464 /** Get the compression algorithm.
465 @return the compression algorithm */
466 [[nodiscard]] Compression compression_algorithm() const {
467 return (m_compression);
468 }
469
470 /** @return true if the page should be compressed */
471 [[nodiscard]] bool is_compressed() const {
473 }
474
475 /** @return true if the page read should not be transformed. */
476 [[nodiscard]] bool is_compression_enabled() const {
477 return ((m_type & NO_COMPRESSION) == 0);
478 }
479
480 /** Disable transformations. */
482
483 /** Get the encryption algorithm.
484 @return the encryption algorithm */
485 [[nodiscard]] Encryption encryption_algorithm() const {
486 return (m_encryption);
487 }
488
489 /** @return true if the page should be encrypted. */
490 [[nodiscard]] bool is_encrypted() const {
492 }
493
494 /** Clear all encryption related flags */
496 m_encryption.set_key(nullptr);
500 }
501
502 /** Note that the IO is for double write buffer page write. */
503 void dblwr() { m_type |= DBLWR; }
504
505 /** @return true if the request is for a dblwr page. */
506 [[nodiscard]] bool is_dblwr() const { return ((m_type & DBLWR) == DBLWR); }
507
508 /** @return true if punch hole is supported */
510 /* In this debugging mode, we act as if punch hole is supported,
511 and then skip any calls to actually punch a hole here.
512 In this way, Transparent Page Compression is still being tested. */
513 DBUG_EXECUTE_IF("ignore_punch_hole", return (true););
514
515#if defined(HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE) || defined(_WIN32)
516 return (true);
517#else
518 return (false);
519#endif /* HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE || _WIN32 */
520 }
521
522 static std::string type_str(const ulint type);
523
524 /** @return string representation. */
525 std::string to_string() const {
527 os << "bs: " << m_block_size << " flags:";
528 os << type_str(m_type);
529 os << ", comp: " << m_compression.to_string();
530 os << ", enc: " << m_encryption.to_string(m_encryption.get_type());
531 return (os.str());
532 }
533
534 /** Get a reference to the underlying encryption information.
535 @return reference to the encryption information. */
536 [[nodiscard]] Encryption &get_encryption_info() noexcept {
537 return m_encryption;
538 }
539
540 /** Set the encrypted block to the given value.
541 @param[in] eblock the encrypted block. */
542 void set_encrypted_block(const file::Block *eblock) noexcept {
543 m_eblock = eblock;
544 }
545
546 /** Get the encrypted block.
547 @return the encrypted block. */
548 [[nodiscard]] const file::Block *get_encrypted_block() const noexcept {
549 return m_eblock;
550 }
551
552 private:
553 /* File system best block size */
554 uint32_t m_block_size{};
555
556 /** Request type bit flags */
557 int m_type{};
558
559 /** Compression algorithm */
561
562 /** Encryption algorithm */
564
565 /** The encrypted block. */
567
568 /** The length of data in encrypted block. */
569 uint32_t m_elen{};
570
571 /** Length of the original IO size.
572 For reads it is an expected uncompressed length.
573 For writes it is a length up to which the write is to be extended with a punch
574 hole, if supported. */
575 uint32_t m_original_size{};
576};
577
578/** @} */
579
580/** Sparse file size information. */
582 /** Total size of file in bytes */
584
585 /** If it is a sparse file then this is the number of bytes
586 actually allocated for the file. */
588};
589
590/** Win NT does not allow more than 64 */
592
593/** Modes for aio operations @{ */
594enum class AIO_mode : size_t {
595 /** Normal asynchronous i/o not for ibuf pages or ibuf bitmap pages */
596 NORMAL = 21,
597
598 /** Asynchronous i/o for ibuf pages or ibuf bitmap pages */
599 IBUF = 22,
600
601 /** Asynchronous i/o where the calling thread will itself wait for
602 the i/o to complete, doing also the job of the i/o-handler thread;
603 can be used for any pages, ibuf or non-ibuf. This is used to save
604 CPU time, as we can do with fewer thread switches. Plain synchronous
605 I/O is not as good, because it must serialize the file seek and read
606 or write, causing a bottleneck for parallelism. */
607 SYNC = 24
608};
609/** @} */
610
613extern ulint os_n_fsyncs;
614
615/* File types for directory entry data type */
616
618 /** Get status failed. */
620
621 /** stat() failed, with ENAMETOOLONG */
623
624 /** stat() failed with EACCESS */
626
627 /** File doesn't exist. */
629
630 /** File exists but type is unknown. */
632
633 /** Ordinary file. */
635
636 /** Directory. */
638
639 /** Symbolic link. */
641
642 /** Block device. */
645
646/* Maximum path string length in bytes when referring to tables with in the
647'./databasename/tablename.ibd' path format; we can allocate at least 2 buffers
648of this size from the thread stack; that is why this should not be made much
649bigger than 4000 bytes. The maximum path length used by any storage engine
650in the server must be at least this big. */
651constexpr uint32_t OS_FILE_MAX_PATH = 4000;
652static_assert(FN_REFLEN_SE >= OS_FILE_MAX_PATH,
653 "(FN_REFLEN_SE < OS_FILE_MAX_PATH)");
654
655/** Struct used in fetching information of a file in a directory */
657 char name[OS_FILE_MAX_PATH]; /*!< path to a file */
658 os_file_type_t type; /*!< file type */
659 os_offset_t size; /*!< file size in bytes */
660 os_offset_t alloc_size; /*!< Allocated size for
661 sparse files in bytes */
662 uint32_t block_size; /*!< Block size to use for IO
663 in bytes*/
664 time_t ctime; /*!< creation time */
665 time_t mtime; /*!< modification time */
666 time_t atime; /*!< access time */
667 bool rw_perm; /*!< true if can be opened
668 in read-write mode. Only valid
669 if type == OS_FILE_TYPE_FILE */
670};
671
672#ifndef UNIV_HOTBACKUP
673/** Create a temporary file. This function is like tmpfile(3). It will create
674the file in the MySQL server configuration parameter (--tmpdir).
675@return temporary file handle, or NULL on error */
677#endif /* !UNIV_HOTBACKUP */
678
679/** This function attempts to create a directory named pathname. The new
680directory gets default permissions. On Unix the permissions are
681(0770 & ~umask). If the directory exists already, nothing is done and
682the call succeeds, unless the fail_if_exists arguments is true.
683If another error occurs, such as a permission error, this does not crash,
684but reports the error and returns false.
685@param[in] pathname directory name as null-terminated string
686@param[in] fail_if_exists if true, pre-existing directory is treated as
687 an error.
688@return true if call succeeds, false on error */
689bool os_file_create_directory(const char *pathname, bool fail_if_exists);
690
691/** Callback function type to be implemented by caller. It is called for each
692entry in directory.
693@param[in] path path to the file
694@param[in] name name of the file */
695typedef std::function<void(const char *path, const char *name)> os_dir_cbk_t;
696
697/** This function scans the contents of a directory and invokes the callback
698for each entry.
699@param[in] path directory name as null-terminated string
700@param[in] scan_cbk use callback to be called for each entry
701@param[in] is_drop attempt to drop the directory after scan
702@return true if call succeeds, false on error */
703bool os_file_scan_directory(const char *path, os_dir_cbk_t scan_cbk,
704 bool is_drop);
705
706/** Clang on Windows warns about umask not found. */
708#ifdef _WIN32
710#endif
711
712/** NOTE! Use the corresponding macro
713os_file_create_simple_no_error_handling(), not directly this function!
714A simple function to open or create a file.
715@param[in] name name of the file or path as a
716null-terminated string
717@param[in] create_mode create mode
718@param[in] access_type OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or
719 OS_FILE_READ_ALLOW_DELETE; the last option
720 is used by a backup program reading the file
721@param[in] read_only if true read only mode checks are enforced
722@param[in] umask UNIX access permission to be set when creating a
723 file. Use os_umask_default to use global default
724 umask.
725@param[out] success true if succeeded
726@return own: handle to the file, not defined if error, error number
727 can be retrieved with os_file_get_last_error */
729 const char *name, ulint create_mode, ulint access_type, bool read_only,
730#ifndef _WIN32
731 mode_t umask,
732#endif
733 bool *success);
735
736/** Tries to disable OS caching on an opened file descriptor.
737@param[in] fd file descriptor to alter
738@param[in] file_name file name, used in the diagnostic message
739@param[in] operation_name "open" or "create"; used in the diagnostic
740 message
741@param[in] on_error_silent if true then don't print any message to the log
742*/
743void os_file_set_nocache(int fd, const char *file_name,
744 const char *operation_name,
745 bool on_error_silent = false);
746/** NOTE! Use the corresponding macro os_file_create(), not directly
747this function!
748Opens an existing file or creates a new.
749@param[in] name name of the file or path as a null-terminated
750 string
751@param[in] create_mode create mode
752@param[in] purpose OS_DATA_FILE, OS_LOG_FILE etc.
753@param[in] read_only if true read only mode checks are enforced
754@param[out] success true if succeeded
755@return own: handle to the file, not defined if error, error number
756 can be retrieved with os_file_get_last_error */
757[[nodiscard]] pfs_os_file_t os_file_create_func(const char *name,
758 ulint create_mode,
759 ulint purpose, bool read_only,
760 bool *success);
761
762/** Deletes a file. The file has to be closed before calling this.
763@param[in] name file path as a null-terminated string
764@return true if success */
765bool os_file_delete_func(const char *name);
766
767/** Deletes a file if it exists. The file has to be closed before calling this.
768@param[in] name file path as a null-terminated string
769@param[out] exist indicate if file pre-exist
770@return true if success */
771bool os_file_delete_if_exists_func(const char *name, bool *exist);
772
773/** NOTE! Use the corresponding macro os_file_rename(), not directly
774this function!
775Renames a file (can also move it to another directory). It is safest that the
776file is closed before calling this function.
777@param[in] oldpath old file path as a null-terminated string
778@param[in] newpath new file path
779@return true if success */
780bool os_file_rename_func(const char *oldpath, const char *newpath);
781
782/** NOTE! Use the corresponding macro os_file_close(), not directly
783this function!
784Closes a file handle. In case of error, error number can be retrieved with
785os_file_get_last_error.
786@param[in] file Handle to a file
787@return true if success */
789
790#ifdef UNIV_PFS_IO
791
792/* Keys to register InnoDB I/O with performance schema */
800
801/* Following four macros are instumentations to register
802various file I/O operations with performance schema.
8031) register_pfs_file_open_begin() and register_pfs_file_open_end() are
804used to register file creation, opening and closing.
8052) register_pfs_file_rename_begin() and register_pfs_file_rename_end()
806are used to register file renaming.
8073) register_pfs_file_io_begin() and register_pfs_file_io_end() are
808used to register actual file read, write and flush
8094) register_pfs_file_close_begin() and register_pfs_file_close_end()
810are used to register file deletion operations*/
811#define register_pfs_file_open_begin(state, locker, key, op, name, \
812 src_location) \
813 do { \
814 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
815 op, name, &locker); \
816 if (locker != nullptr) { \
817 PSI_FILE_CALL(start_file_open_wait) \
818 (locker, src_location.filename, static_cast<uint>(src_location.line)); \
819 } \
820 } while (0)
821
822#define register_pfs_file_open_end(locker, file, result) \
823 do { \
824 if (locker != nullptr) { \
825 file.m_psi = PSI_FILE_CALL(end_file_open_wait)(locker, result); \
826 } \
827 } while (0)
828
829#define register_pfs_file_rename_begin(state, locker, key, op, from, to, \
830 src_location) \
831 do { \
832 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
833 op, from, &locker); \
834 if (locker != nullptr) { \
835 PSI_FILE_CALL(start_file_rename_wait) \
836 (locker, (size_t)0, from, to, src_location.filename, \
837 static_cast<uint>(src_location.line)); \
838 } \
839 } while (0)
840
841#define register_pfs_file_rename_end(locker, from, to, result) \
842 do { \
843 if (locker != nullptr) { \
844 PSI_FILE_CALL(end_file_rename_wait)(locker, from, to, result); \
845 } \
846 } while (0)
847
848#define register_pfs_file_close_begin(state, locker, key, op, name, \
849 src_location) \
850 do { \
851 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
852 op, name, &locker); \
853 if (locker != nullptr) { \
854 PSI_FILE_CALL(start_file_close_wait) \
855 (locker, src_location.filename, static_cast<uint>(src_location.line)); \
856 } \
857 } while (0)
858
859#define register_pfs_file_close_end(locker, result) \
860 do { \
861 if (locker != nullptr) { \
862 PSI_FILE_CALL(end_file_close_wait)(locker, result); \
863 } \
864 } while (0)
865
866#define register_pfs_file_io_begin(state, locker, file, count, op, \
867 src_location) \
868 do { \
869 locker = \
870 PSI_FILE_CALL(get_thread_file_stream_locker)(state, file.m_psi, op); \
871 if (locker != nullptr) { \
872 PSI_FILE_CALL(start_file_wait) \
873 (locker, count, src_location.filename, \
874 static_cast<uint>(src_location.line)); \
875 } \
876 } while (0)
877
878#define register_pfs_file_io_end(locker, count) \
879 do { \
880 if (locker != nullptr) { \
881 PSI_FILE_CALL(end_file_wait)(locker, count); \
882 } \
883 } while (0)
884
885/* Following macros/functions are file I/O APIs that would be performance
886schema instrumented if "UNIV_PFS_IO" is defined. They would point to
887wrapper functions with performance schema instrumentation in such case.
888
889os_file_create
890os_file_create_simple_no_error_handling
891os_file_close
892os_file_rename
893os_aio
894os_file_read
895os_file_read_no_error_handling
896os_file_read_no_error_handling_int_fd
897os_file_write
898
899The wrapper functions have the prefix of "innodb_". */
900
901#define os_file_create(key, name, create, purpose, read_only, success) \
902 pfs_os_file_create_func(key, name, create, purpose, read_only, success, \
903 UT_LOCATION_HERE)
904
905#ifndef _WIN32
906#define os_file_create_simple_no_error_handling(key, name, create_mode, \
907 access, read_only, success) \
908 pfs_os_file_create_simple_no_error_handling_func( \
909 key, name, create_mode, access, read_only, os_innodb_umask_default, \
910 success, UT_LOCATION_HERE)
911
912#define os_file_create_simple_no_error_handling_with_umask( \
913 key, name, create_mode, access, read_only, umask, success) \
914 pfs_os_file_create_simple_no_error_handling_func(key, name, create_mode, \
915 access, read_only, umask, \
916 success, UT_LOCATION_HERE)
917#else
918#define os_file_create_simple_no_error_handling(key, name, create_mode, \
919 access, read_only, success) \
920 pfs_os_file_create_simple_no_error_handling_func( \
921 key, name, create_mode, access, read_only, success, UT_LOCATION_HERE)
922#endif
923
924#define os_file_close_pfs(file) pfs_os_file_close_func(file, UT_LOCATION_HERE)
925
926#define os_aio(type, mode, name, file, buf, offset, n, read_only, message1, \
927 message2) \
928 pfs_os_aio_func(type, mode, name, file, buf, offset, n, read_only, message1, \
929 message2, UT_LOCATION_HERE)
930
931#define os_file_read_pfs(type, file_name, file, buf, offset, n) \
932 pfs_os_file_read_func(type, file_name, file, buf, offset, n, UT_LOCATION_HERE)
933
934#define os_file_read_first_page_pfs(type, file_name, file, buf, n) \
935 pfs_os_file_read_first_page_func(type, file_name, file, buf, n, \
936 UT_LOCATION_HERE)
937
938#define os_file_copy_pfs(src, src_offset, dest, dest_offset, size) \
939 pfs_os_file_copy_func(src, src_offset, dest, dest_offset, size, \
940 UT_LOCATION_HERE)
941
942#define os_file_read_no_error_handling_pfs(type, file_name, file, buf, offset, \
943 n, o) \
944 pfs_os_file_read_no_error_handling_func(type, file_name, file, buf, offset, \
945 n, o, UT_LOCATION_HERE)
946
947#define os_file_read_no_error_handling_int_fd(type, file_name, file, buf, \
948 offset, n, o) \
949 pfs_os_file_read_no_error_handling_int_fd_func( \
950 type, file_name, file, buf, offset, n, o, UT_LOCATION_HERE)
951
952#define os_file_write_pfs(type, name, file, buf, offset, n) \
953 pfs_os_file_write_func(type, name, file, buf, offset, n, UT_LOCATION_HERE)
954
955#define os_file_write_int_fd(type, name, file, buf, offset, n) \
956 pfs_os_file_write_int_fd_func(type, name, file, buf, offset, n, \
957 UT_LOCATION_HERE)
958
959#define os_file_flush_pfs(file) pfs_os_file_flush_func(file, UT_LOCATION_HERE)
960
961#define os_file_rename(key, oldpath, newpath) \
962 pfs_os_file_rename_func(key, oldpath, newpath, UT_LOCATION_HERE)
963
964#define os_file_delete(key, name) \
965 pfs_os_file_delete_func(key, name, UT_LOCATION_HERE)
966
967#define os_file_delete_if_exists(key, name, exist) \
968 pfs_os_file_delete_if_exists_func(key, name, exist, UT_LOCATION_HERE)
969
970/** Clang on Windows warns about umask not found. */
972#ifdef _WIN32
974#endif
975
976/** NOTE! Please use the corresponding macro
977os_file_create_simple_no_error_handling(), not directly this function!
978A performance schema instrumented wrapper function for
979os_file_create_simple_no_error_handling(). Add instrumentation to
980monitor file creation/open.
981@param[in] key Performance Schema Key
982@param[in] name name of the file or path as a null-terminated
983 string
984@param[in] create_mode create mode
985@param[in] access_type OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or
986 OS_FILE_READ_ALLOW_DELETE; the last option is
987 used by a backup program reading the file
988@param[in] read_only if true read only mode checks are enforced
989@param[in] umask UNIX access permission to be set when creating a
990 file. Use os_umask_default to use global default
991 umask.
992@param[out] success true if succeeded
993@param[in] src_location location where func invoked
994@return own: handle to the file, not defined if error, error number
995 can be retrieved with os_file_get_last_error */
996[[nodiscard]] static inline pfs_os_file_t
998 mysql_pfs_key_t key, const char *name, ulint create_mode, ulint access_type,
999 bool read_only,
1000#ifndef _WIN32
1001 mode_t umask,
1002#endif
1003 bool *success, ut::Location src_location);
1005
1006/** NOTE! Please use the corresponding macro os_file_create(), not directly
1007this function!
1008A performance schema wrapper function for os_file_create().
1009Add instrumentation to monitor file creation/open.
1010@param[in] key Performance Schema Key
1011@param[in] name name of the file or path as a null-terminated
1012 string
1013@param[in] create_mode create mode
1014@param[in] purpose OS_DATA_FILE, OS_LOG_FILE etc.
1015@param[in] read_only if true read only mode checks are enforced
1016@param[out] success true if succeeded
1017@param[in] src_location location where func invoked
1018@return own: handle to the file, not defined if error, error number
1019 can be retrieved with os_file_get_last_error */
1020[[nodiscard]] static inline pfs_os_file_t pfs_os_file_create_func(
1021 mysql_pfs_key_t key, const char *name, ulint create_mode, ulint purpose,
1022 bool read_only, bool *success, ut::Location src_location);
1023
1024/** NOTE! Please use the corresponding macro os_file_close(), not directly
1025this function!
1026A performance schema instrumented wrapper function for os_file_close().
1027@param[in] file handle to a file
1028@param[in] src_location location where func invoked
1029@return true if success */
1031 ut::Location src_location);
1032
1033/** NOTE! Please use the corresponding macro os_file_read(), not directly
1034this function!
1035This is the performance schema instrumented wrapper function for
1036os_file_read() which requests a synchronous read operation.
1037@param[in, out] type IO request context
1038@param[in] file_name file name
1039@param[in] file Open file handle
1040@param[out] buf buffer where to read
1041@param[in] offset file offset where to read
1042@param[in] n number of bytes to read
1043@param[in] src_location location where func invoked
1044@return DB_SUCCESS if request was successful */
1046 const char *file_name,
1047 pfs_os_file_t file, void *buf,
1048 os_offset_t offset, ulint n,
1049 ut::Location src_location);
1050
1051/** NOTE! Please use the corresponding macro os_file_read_first_page(),
1052not directly this function!
1053This is the performance schema instrumented wrapper function for
1054os_file_read_first_page() which requests a synchronous read operation
1055of page 0 of IBD file
1056@param[in, out] type IO request context
1057@param[in] file_name file name
1058@param[in] file Open file handle
1059@param[out] buf buffer where to read
1060@param[in] n number of bytes to read
1061@param[in] src_location location where func invoked
1062@return DB_SUCCESS if request was successful */
1064 IORequest &type, const char *file_name, pfs_os_file_t file, void *buf,
1065 ulint n, ut::Location src_location);
1066
1067/** copy data from one file to another file. Data is read/written
1068at current file offset.
1069@param[in] src file handle to copy from
1070@param[in] src_offset offset to copy from
1071@param[in] dest file handle to copy to
1072@param[in] dest_offset offset to copy to
1073@param[in] size number of bytes to copy
1074@param[in] src_location location where func invoked
1075@return DB_SUCCESS if successful */
1077 os_offset_t src_offset,
1078 pfs_os_file_t dest,
1079 os_offset_t dest_offset, uint size,
1080 ut::Location src_location);
1081
1082/** NOTE! Please use the corresponding macro os_file_read_no_error_handling(),
1083not directly this function!
1084This is the performance schema instrumented wrapper function for
1085os_file_read_no_error_handling_func() which requests a synchronous
1086read operation.
1087@param[in, out] type IO request context
1088@param[in] file_name file name
1089@param[in] file Open file handle
1090@param[out] buf buffer where to read
1091@param[in] offset file offset where to read
1092@param[in] n number of bytes to read
1093@param[out] o number of bytes actually read
1094@param[in] src_location location where func invoked
1095@return DB_SUCCESS if request was successful */
1097 IORequest &type, const char *file_name, pfs_os_file_t file, void *buf,
1098 os_offset_t offset, ulint n, ulint *o, ut::Location src_location);
1099
1100/** NOTE! Please use the corresponding macro
1101os_file_read_no_error_handling_int_fd(), not directly this function!
1102This is the performance schema instrumented wrapper function for
1103os_file_read_no_error_handling_int_fd_func() which requests a
1104synchronous read operation on files with int type descriptors.
1105@param[in, out] type IO request context
1106@param[in] file_name file name
1107@param[in] file Open file handle
1108@param[out] buf buffer where to read
1109@param[in] offset file offset where to read
1110@param[in] n number of bytes to read
1111@param[out] o number of bytes actually read
1112@param[in] src_location location where func invoked
1113@return DB_SUCCESS if request was successful */
1114
1116 IORequest &type, const char *file_name, int file, void *buf,
1117 os_offset_t offset, ulint n, ulint *o, ut::Location src_location);
1118
1119/** NOTE! Please use the corresponding macro os_aio(), not directly this
1120function!
1121Performance schema wrapper function of os_aio() which requests
1122an asynchronous I/O operation.
1123@param[in] type IO request context
1124@param[in] mode IO mode
1125@param[in] name Name of the file or path as NUL terminated
1126 string
1127@param[in] file Open file handle
1128@param[out] buf buffer where to read
1129@param[in] offset file offset where to read
1130@param[in] n how many bytes to read or write; this
1131must not cross a file boundary; in AIO this must be a block size multiple
1132@param[in] read_only if true read only mode checks are enforced
1133@param[in,out] m1 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,out] m2 message for the AIO handler (can be used to
1137 identify a completed AIO operation); ignored
1138 if mode is OS_AIO_SYNC
1139@param[in] location location where func invoked
1140@return DB_SUCCESS if request was queued successfully, false if fail */
1142 const char *name, pfs_os_file_t file,
1143 void *buf, os_offset_t offset, ulint n,
1144 bool read_only, fil_node_t *m1, void *m2,
1145 ut::Location location);
1146
1147/** NOTE! Please use the corresponding macro os_file_write(), not directly
1148this function!
1149This is the performance schema instrumented wrapper function for
1150os_file_write() which requests a synchronous write operation.
1151@param[in, out] type IO request context
1152@param[in] name Name of the file or path as NUL terminated
1153 string
1154@param[in] file Open file handle
1155@param[out] buf buffer where to read
1156@param[in] offset file offset where to read
1157@param[in] n number of bytes to read
1158@param[in] src_location location where func invoked
1159@return DB_SUCCESS if request was successful */
1162 const void *buf,
1163 os_offset_t offset, ulint n,
1164 ut::Location src_location);
1165
1166/** NOTE! Please use the corresponding macro os_file_write(), not
1167directly this function!
1168This is the performance schema instrumented wrapper function for
1169os_file_write() which requests a synchronous write operation
1170on files with int type descriptors.
1171@param[in, out] type IO request context
1172@param[in] name Name of the file or path as NUL terminated
1173 string
1174@param[in] file Open file handle
1175@param[out] buf buffer where to read
1176@param[in] offset file offset where to read
1177@param[in] n number of bytes to read
1178@param[in] src_location location where func invoked
1179@return DB_SUCCESS if request was successful */
1181 const char *name, int file,
1182 const void *buf,
1183 os_offset_t offset, ulint n,
1184 ut::Location src_location);
1185
1186/** NOTE! Please use the corresponding macro os_file_flush(), not directly
1187this function!
1188This is the performance schema instrumented wrapper function for
1189os_file_flush() which flushes the write buffers of a given file to the disk.
1190Flushes the write buffers of a given file to the disk.
1191@param[in] file Open file handle
1192@param[in] src_location location where func invoked
1193@return true if success */
1195 ut::Location src_location);
1196
1197/** NOTE! Please use the corresponding macro os_file_rename(), not directly
1198this function!
1199This is the performance schema instrumented wrapper function for
1200os_file_rename()
1201@param[in] key Performance Schema Key
1202@param[in] oldpath old file path as a null-terminated string
1203@param[in] newpath new file path
1204@param[in] src_location location where func invoked
1205@return true if success */
1207 const char *oldpath,
1208 const char *newpath,
1209 ut::Location src_location);
1210
1211/**
1212NOTE! Please use the corresponding macro os_file_delete(), not directly
1213this function!
1214This is the performance schema instrumented wrapper function for
1215os_file_delete()
1216@param[in] key Performance Schema Key
1217@param[in] name old file path as a null-terminated string
1218@param[in] src_location location where func invoked
1219@return true if success */
1221 const char *name,
1222 ut::Location src_location);
1223
1224/**
1225NOTE! Please use the corresponding macro os_file_delete_if_exists(), not
1226directly this function!
1227This is the performance schema instrumented wrapper function for
1228os_file_delete_if_exists()
1229@param[in] key Performance Schema Key
1230@param[in] name old file path as a null-terminated string
1231@param[in] exist indicate if file pre-exist
1232@param[in] src_location location where func invoked
1233@return true if success */
1235 const char *name,
1236 bool *exist,
1237 ut::Location src_location);
1238
1239#else /* UNIV_PFS_IO */
1240
1241/* If UNIV_PFS_IO is not defined, these I/O APIs point
1242to original un-instrumented file I/O APIs */
1243
1244#define os_file_create(key, name, create, purpose, read_only, success) \
1245 os_file_create_func(name, create, purpose, read_only, success)
1246
1247#ifndef _WIN32
1248
1249#define os_file_create_simple_no_error_handling(key, name, create_mode, \
1250 access, read_only, success) \
1251 os_file_create_simple_no_error_handling_func( \
1252 name, create_mode, access, read_only, os_innodb_umask_default, success)
1253
1254#define os_file_create_simple_no_error_handling_with_umask( \
1255 key, name, create_mode, access, read_only, umask, success) \
1256 os_file_create_simple_no_error_handling_func(name, create_mode, access, \
1257 read_only, umask, success)
1258
1259#else
1260
1261#define os_file_create_simple_no_error_handling(key, name, create_mode, \
1262 access, read_only, success) \
1263 os_file_create_simple_no_error_handling_func(name, create_mode, access, \
1264 read_only, success)
1265
1266#endif
1267
1268#define os_file_close_pfs(file) os_file_close_func(file)
1269
1270#define os_aio(type, mode, name, file, buf, offset, n, read_only, message1, \
1271 message2) \
1272 os_aio_func(type, mode, name, file, buf, offset, n, read_only, message1, \
1273 message2)
1274
1275#define os_file_read_pfs(type, file_name, file, buf, offset, n) \
1276 os_file_read_func(type, file_name, file, buf, offset, n)
1277
1278#define os_file_read_first_page_pfs(type, file_name, file, buf, n) \
1279 os_file_read_first_page_func(type, file_name, file, buf, n)
1280
1281#define os_file_copy_pfs(src, src_offset, dest, dest_offset, size) \
1282 os_file_copy_func(src, src_offset, dest, dest_offset, size)
1283
1284#define os_file_read_no_error_handling_pfs(type, file_name, file, buf, offset, \
1285 n, o) \
1286 os_file_read_no_error_handling_func(type, file_name, file, buf, offset, n, o)
1287
1288#define os_file_read_no_error_handling_int_fd(type, file_name, file, buf, \
1289 offset, n, o) \
1290 os_file_read_no_error_handling_func(type, file_name, OS_FILE_FROM_FD(file), \
1291 buf, offset, n, o)
1292
1293#define os_file_write_pfs(type, name, file, buf, offset, n) \
1294 os_file_write_func(type, name, file, buf, offset, n)
1295
1296#define os_file_write_int_fd(type, name, file, buf, offset, n) \
1297 os_file_write_func(type, name, OS_FILE_FROM_FD(file), buf, offset, n)
1298
1299#define os_file_flush_pfs(file) os_file_flush_func(file)
1300
1301#define os_file_rename(key, oldpath, newpath) \
1302 os_file_rename_func(oldpath, newpath)
1303
1304#define os_file_delete(key, name) os_file_delete_func(name)
1305
1306#define os_file_delete_if_exists(key, name, exist) \
1307 os_file_delete_if_exists_func(name, exist)
1308
1309#endif /* UNIV_PFS_IO */
1310
1311#ifdef UNIV_PFS_IO
1312#define os_file_close(file) os_file_close_pfs(file)
1313#else
1314#define os_file_close(file) os_file_close_pfs((file).m_file)
1315#endif
1316
1317#ifdef UNIV_PFS_IO
1318#define os_file_read(type, file_name, file, buf, offset, n) \
1319 os_file_read_pfs(type, file_name, file, buf, offset, n)
1320#else
1321#define os_file_read(type, file_name, file, buf, offset, n) \
1322 os_file_read_pfs(type, file_name, file.m_file, buf, offset, n)
1323#endif
1324
1325#ifdef UNIV_PFS_IO
1326#define os_file_read_first_page(type, file_name, file, buf, n) \
1327 os_file_read_first_page_pfs(type, file_name, file, buf, n)
1328#else
1329#define os_file_read_first_page(type, file_name, file, buf, n) \
1330 os_file_read_first_page_pfs(type, file_name, file.m_file, buf, n)
1331#endif
1332
1333#ifdef UNIV_PFS_IO
1334#define os_file_flush(file) os_file_flush_pfs(file)
1335#else
1336#define os_file_flush(file) os_file_flush_pfs(file.m_file)
1337#endif
1338
1339#ifdef UNIV_PFS_IO
1340#define os_file_write(type, name, file, buf, offset, n) \
1341 os_file_write_pfs(type, name, file, buf, offset, n)
1342#else
1343#define os_file_write(type, name, file, buf, offset, n) \
1344 os_file_write_pfs(type, name, file.m_file, buf, offset, n)
1345#endif
1346
1347#ifdef UNIV_PFS_IO
1348#define os_file_copy(src, src_offset, dest, dest_offset, size) \
1349 os_file_copy_pfs(src, src_offset, dest, dest_offset, size)
1350#else
1351#define os_file_copy(src, src_offset, dest, dest_offset, size) \
1352 os_file_copy_pfs(src.m_file, src_offset, dest.m_file, dest_offset, size)
1353#endif
1354
1355#ifdef UNIV_PFS_IO
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, buf, offset, n, o)
1359#else
1360#define os_file_read_no_error_handling(type, file_name, file, buf, offset, n, \
1361 o) \
1362 os_file_read_no_error_handling_pfs(type, file_name, file.m_file, buf, \
1363 offset, n, o)
1364#endif
1365
1366#ifdef UNIV_HOTBACKUP
1367/** Closes a file handle.
1368@param[in] file handle to a file
1369@return true if success */
1370bool os_file_close_no_error_handling(os_file_t file);
1371#endif /* UNIV_HOTBACKUP */
1372
1373/** Gets a file size.
1374@param[in] filename Full path to the filename to check
1375@return file size if OK, else set m_total_size to ~0 and m_alloc_size to
1376 errno. */
1377[[nodiscard]] os_file_size_t os_file_get_size(const char *filename);
1378
1379/** Gets a file size.
1380@param[in] file Handle to a file
1381@return file size, or (os_offset_t) -1 on failure */
1383
1384/** Allocate a block to file using fallocate from the given offset if
1385fallocate is supported. Falls back to the old slower method of writing
1386zeros otherwise.
1387@param[in] name name of the file
1388@param[in] file handle to the file
1389@param[in] offset file offset
1390@param[in] size file size
1391@param[in] flush flush file content to disk
1392@return true if success */
1393[[nodiscard]] bool os_file_set_size_fast(const char *name, pfs_os_file_t file,
1395 bool flush);
1396
1397/** Write the specified number of zeros to a file from specific offset.
1398@param[in] name name of the file or path as a null-terminated
1399 string
1400@param[in] file handle to a file
1401@param[in] offset file offset
1402@param[in] size file size
1403@param[in] flush flush file content to disk
1404@return true if success */
1405[[nodiscard]] bool os_file_set_size(const char *name, pfs_os_file_t file,
1407 bool flush);
1408
1409/** Truncates a file at its current position.
1410@param[in,out] file file to be truncated
1411@return true if success */
1412bool os_file_set_eof(FILE *file); /*!< in: file to be truncated */
1413
1414/** Truncates a file to a specified size in bytes.
1415Do nothing if the size to preserve is greater or equal to the current
1416size of the file.
1417@param[in] pathname file path
1418@param[in] file file to be truncated
1419@param[in] size size to preserve in bytes
1420@return true if success */
1421bool os_file_truncate(const char *pathname, pfs_os_file_t file,
1423
1424/** Set read/write position of a file handle to specific offset.
1425@param[in] pathname file path
1426@param[in] file file handle
1427@param[in] offset read/write offset
1428@return true if success */
1429bool os_file_seek(const char *pathname, os_file_t file, os_offset_t offset);
1430
1431/** NOTE! Use the corresponding macro os_file_flush(), not directly this
1432function!
1433Flushes the write buffers of a given file to the disk.
1434@param[in] file handle to a file
1435@return true if success */
1437
1438/** Retrieves the last error number if an error occurs in a file io function.
1439The number should be retrieved before any other OS calls (because they may
1440overwrite the error number). If the number is not known to this program,
1441the OS error number + 100 is returned.
1442@param[in] report_all_errors true if we want an error message printed
1443 for all errors
1444@return error number, or OS error number + 100 */
1445ulint os_file_get_last_error(bool report_all_errors);
1446
1447/** NOTE! Use the corresponding macro os_file_read_first_page(), not directly
1448this function!
1449Requests a synchronous read operation of page 0 of IBD file.
1450@param[in] type IO request context
1451@param[in] file_name file name
1452@param[in] file Open file handle
1453@param[out] buf buffer where to read
1454@param[in] offset file offset where to read
1455@param[in] n number of bytes to read
1456@return DB_SUCCESS if request was successful, DB_IO_ERROR on failure */
1457[[nodiscard]] dberr_t os_file_read_func(IORequest &type, const char *file_name,
1458 os_file_t file, void *buf,
1459 os_offset_t offset, ulint n);
1460
1461/** NOTE! Use the corresponding macro os_file_read_first_page(),
1462not directly this function!
1463Requests a synchronous read operation of page 0 of IBD file
1464@param[in] type IO request context
1465@param[in] file_name file name
1466@param[in] file Open file handle
1467@param[out] buf buffer where to read
1468@param[in] n number of bytes to read
1469@return DB_SUCCESS if request was successful, DB_IO_ERROR on failure */
1471 const char *file_name,
1472 os_file_t file, void *buf,
1473 ulint n);
1474
1475/** Copy data from one file to another file. Data is read/written
1476at current file offset.
1477@param[in] src_file file handle to copy from
1478@param[in] src_offset offset to copy from
1479@param[in] dest_file file handle to copy to
1480@param[in] dest_offset offset to copy to
1481@param[in] size number of bytes to copy
1482@return DB_SUCCESS if successful */
1483[[nodiscard]] dberr_t os_file_copy_func(os_file_t src_file,
1484 os_offset_t src_offset,
1485 os_file_t dest_file,
1486 os_offset_t dest_offset, uint size);
1487
1488/** Rewind file to its start, read at most size - 1 bytes from it to str, and
1489NUL-terminate str. All errors are silently ignored. This function is
1490mostly meant to be used with temporary files.
1491@param[in,out] file File to read from
1492@param[in,out] str Buffer where to read
1493@param[in] size Size of buffer */
1494void os_file_read_string(FILE *file, char *str, ulint size);
1495
1496/** NOTE! Use the corresponding macro os_file_read_no_error_handling(),
1497not directly this function!
1498Requests a synchronous positioned read operation. This function does not do
1499any error handling. In case of error it returns false.
1500@param[in] type IO request context
1501@param[in] file_name file name
1502@param[in] file Open file handle
1503@param[out] buf buffer where to read
1504@param[in] offset file offset where to read
1505@param[in] n number of bytes to read
1506@param[out] o number of bytes actually read
1507@return DB_SUCCESS or error code */
1509 IORequest &type, const char *file_name, os_file_t file, void *buf,
1510 os_offset_t offset, ulint n, ulint *o);
1511
1512/** NOTE! Use the corresponding macro os_file_write(), not directly this
1513function!
1514Requests a synchronous write operation.
1515@param[in,out] type IO request context
1516@param[in] name name of the file or path as a null-terminated
1517 string
1518@param[in] file Open file handle
1519@param[out] buf buffer where to read
1520@param[in] offset file offset where to read
1521@param[in] n number of bytes to read
1522@return DB_SUCCESS if request was successful */
1523[[nodiscard]] dberr_t os_file_write_func(IORequest &type, const char *name,
1524 os_file_t file, const void *buf,
1525 os_offset_t offset, ulint n);
1526
1527/** Check the existence and type of a given path.
1528@param[in] path pathname of the file
1529@param[out] exists true if file exists
1530@param[out] type type of the file (if it exists)
1531@return true if call succeeded */
1532bool os_file_status(const char *path, bool *exists, os_file_type_t *type);
1533
1534/** Check the existence and usefulness of a given path.
1535@param[in] path path name
1536@retval true if the path exists and can be used
1537@retval false if the path does not exist or if the path is
1538unusable to get to a possibly existing file or directory. */
1539bool os_file_exists(const char *path);
1540
1541/** Create all missing subdirectories along the given path.
1542@return DB_SUCCESS if OK, otherwise error code. */
1544
1545#ifdef UNIV_ENABLE_UNIT_TEST_GET_PARENT_DIR
1546/* Test the function os_file_get_parent_dir. */
1547void unit_test_os_file_get_parent_dir();
1548#endif /* UNIV_ENABLE_UNIT_TEST_GET_PARENT_DIR */
1549
1550#ifdef UNIV_HOTBACKUP
1551/** Deallocates the "Blocks" in block_cache */
1552void meb_free_block_cache();
1553#endif /* UNIV_HOTBACKUP */
1554
1555/** Creates and initializes block_cache. Creates array of MAX_BLOCKS
1556and allocates the memory in each block to hold BUFFER_BLOCK_SIZE
1557of data.
1558
1559This function is called by InnoDB during srv_start().
1560It is also called by MEB while applying the redo logs on TDE tablespaces,
1561the "Blocks" allocated in this block_cache are used to hold the decrypted
1562page data. */
1564
1565/** Initializes the asynchronous io system.
1566Creates an array for ibuf i/o (if not in read-only mode).
1567Also creates one array each for read and write where each
1568array is divided logically into n_readers and n_writers
1569respectively. The caller must create an i/o handler thread for each
1570segment in these arrays by calling os_aio_start_threads().
1571
1572@param[in] n_readers number of reader threads
1573@param[in] n_writers number of writer threads */
1574bool os_aio_init(ulint n_readers, ulint n_writers);
1575
1576/** Starts one thread for each segment created in os_aio_init */
1578
1579/**
1580Frees the asynchronous io system. */
1581void os_aio_free();
1582
1583/**
1584NOTE! Use the corresponding macro os_aio(), not directly this function!
1585Requests an asynchronous i/o operation.
1586@param[in] type IO request context
1587@param[in] aio_mode IO mode
1588@param[in] name Name of the file or path as NUL terminated
1589string
1590@param[in] file Open file handle
1591@param[out] buf buffer where to read
1592@param[in] offset file offset where to read
1593@param[in] n how many bytes to read or write; this
1594must not cross a file boundary; in AIO this must be a block size multiple
1595@param[in] read_only if true read only mode checks are enforced
1596@param[in,out] m1 Message for the AIO handler, (can be used to
1597identify a completed AIO operation); ignored if mode is OS_AIO_SYNC
1598@param[in,out] m2 message for the AIO handler (can be used to
1599identify a completed AIO operation); ignored if mode is OS_AIO_SYNC
1600@return DB_SUCCESS or error code */
1601dberr_t os_aio_func(IORequest &type, AIO_mode aio_mode, const char *name,
1602 pfs_os_file_t file, void *buf, os_offset_t offset, ulint n,
1603 bool read_only, fil_node_t *m1, void *m2);
1604
1605/** Wakes up all async i/o threads so that they know to exit themselves in
1606shutdown. */
1608
1609/** Waits until there are no pending writes in os_aio_write_array. There can
1610be other, synchronous, pending writes. */
1612
1613/** Wakes up simulated aio i/o-handler threads if they have something to do. */
1615
1616/** This function can be called if one wants to post a batch of reads and
1617prefers an i/o-handler thread to handle them all at once later. You must
1618call os_aio_simulated_wake_handler_threads later to ensure the threads
1619are not left sleeping! */
1621
1622/** Waits for an AIO operation to complete. This function is used to wait the
1623for completed requests. The AIO array of pending requests is divided
1624into segments. The thread specifies which segment or slot it wants to wait
1625for. NOTE: this function will also take care of freeing the AIO slot,
1626therefore no other thread is allowed to do the freeing!
1627@param[in] segment The number of the segment in the AIO arrays to
1628 wait for; segment 0 is the ibuf I/O thread,
1629 then follow the non-ibuf read threads,
1630 and as the last are the non-ibuf write threads
1631@param[out] m1 the messages passed with the AIO request; note
1632 that also in the case where the AIO operation
1633 failed, these output parameters are valid and
1634 can be used to restart the operation,
1635 for example
1636@param[out] m2 callback message
1637@param[out] request OS_FILE_WRITE or ..._READ
1638@return DB_SUCCESS or error code */
1639dberr_t os_aio_handler(ulint segment, fil_node_t **m1, void **m2,
1640 IORequest *request);
1641
1642/** Prints info of the aio arrays.
1643@param[in,out] file file where to print */
1644void os_aio_print(FILE *file);
1645
1646/** Refreshes the statistics used to print per-second averages. */
1648
1649/** Checks that all slots in the system have been freed, that is, there are
1650no pending io operations. */
1652
1653#ifdef UNIV_DEBUG
1654
1655/** Prints all pending IO
1656@param[in] file File where to print */
1658
1659#endif /* UNIV_DEBUG */
1660
1661/** Get available free space on disk
1662@param[in] path pathname of a directory or file in disk
1663@param[out] free_space free space available in bytes
1664@return DB_SUCCESS if all OK */
1665dberr_t os_get_free_space(const char *path, uint64_t &free_space);
1666
1667/** This function returns information about the specified file
1668@param[in] path pathname of the file
1669@param[out] stat_info information of a file in a directory
1670@param[in] check_rw_perm for testing whether the file can be opened
1671 in RW mode
1672@param[in] read_only true if file is opened in read-only mode
1673@return DB_SUCCESS if all OK */
1674dberr_t os_file_get_status(const char *path, os_file_stat_t *stat_info,
1675 bool check_rw_perm, bool read_only);
1676
1677/** Check if a file can be opened in read-write mode.
1678 @param[in] name filename to check
1679 @param[in] read_only true if check for read-only mode only
1680 @retval true if file can be opened in the specified mode (rw or ro);
1681 or file does not exist
1682 @retval false if file exists and can't be opened in the specified mode */
1683bool os_file_check_mode(const char *name, bool read_only);
1684
1685#ifndef UNIV_HOTBACKUP
1686
1687/** return any of the tmpdir path */
1688char *innobase_mysql_tmpdir();
1689
1690/** Creates a temporary file in the location specified by the parameter
1691path. If the path is NULL, then it will be created in --tmpdir.
1692@param[in] path location for creating temporary file
1693@return temporary file descriptor, or OS_FD_CLOSED on error */
1695
1696#endif /* !UNIV_HOTBACKUP */
1697
1698/** If it is a compressed page return the compressed page data + footer size
1699@param[in] buf Buffer to check, must include header + 10 bytes
1700@return ULINT_UNDEFINED if the page is not a compressed page or length
1701 of the compressed data (including footer) if it is a compressed page */
1703
1704/** If it is a compressed page return the original page data + footer size
1705@param[in] buf Buffer to check, must include header + 10 bytes
1706@return ULINT_UNDEFINED if the page is not a compressed page or length
1707 of the original data + footer if it is a compressed page */
1709
1710#ifndef _WIN32
1711/** Set the global file create umask. This value is to be set once, at startup
1712and never modified.
1713@param[in] umask The umask to use for all InnoDB file creation.
1714*/
1715void os_file_set_umask(mode_t umask);
1716
1717/** A magic constant for the umask parameter that indicates caller wants the
1718`os_innodb_umask` value to be used. The `os_innodb_umask` is a static value,
1719private to this module, and to the file creation methods, so it should not be
1720used directly. */
1722
1723#endif
1724
1725/** Free storage space associated with a section of the file.
1726@param[in] fh Open file handle
1727@param[in] off Starting offset (SEEK_SET)
1728@param[in] len Size of the hole
1729@return DB_SUCCESS or error code */
1730[[nodiscard]] dberr_t os_file_punch_hole(os_file_t fh, os_offset_t off,
1731 os_offset_t len);
1732
1733/** Check if the file system supports sparse files.
1734
1735Warning: On POSIX systems we try and punch a hole from offset 0 to
1736the system configured page size. This should only be called on an empty
1737file.
1738
1739Note: On Windows we use the name and on Unices we use the file handle.
1740
1741@param[in] fh File handle for the file - if opened
1742@return true if the file system supports sparse files */
1743[[nodiscard]] bool os_is_sparse_file_supported(pfs_os_file_t fh);
1744
1745/** Decompress the page data contents. Page type must be FIL_PAGE_COMPRESSED, if
1746not then the source contents are left unchanged and DB_SUCCESS is returned.
1747@param[in] dblwr_read true of double write recovery in progress
1748@param[in,out] src Data read from disk, decompressed data will be
1749 copied to this page
1750@param[in,out] dst Scratch area to use for decompression or
1751 nullptr.
1752@param[in] dst_len If dst is valid, then size of the scratch area
1753 in bytes
1754@return DB_SUCCESS or error code */
1755[[nodiscard]] dberr_t os_file_decompress_page(bool dblwr_read, byte *src,
1756 byte *dst, ulint dst_len);
1757
1758/** Compress a data page
1759@param[in] compression Compression algorithm
1760@param[in] block_size File system block size
1761@param[in] src Source contents to compress
1762@param[in] src_len Length in bytes of the source
1763@param[out] dst Compressed page contents
1764@param[out] dst_len Length in bytes of dst contents
1765@return buffer data, dst_len will have the length of the data */
1766byte *os_file_compress_page(Compression compression, ulint block_size,
1767 byte *src, ulint src_len, byte *dst,
1768 ulint *dst_len);
1769
1770/** Determine if O_DIRECT is supported.
1771@retval true if O_DIRECT is supported.
1772@retval false if O_DIRECT is not supported. */
1773[[nodiscard]] bool os_is_o_direct_supported();
1774
1775/** Fill the pages with NULs
1776@param[in] file File handle
1777@param[in] name File name
1778@param[in] page_size physical page size
1779@param[in] start Offset from the start of the file in bytes
1780@param[in] len Length in bytes
1781@return DB_SUCCESS or error code */
1782[[nodiscard]] dberr_t os_file_write_zeros(pfs_os_file_t file, const char *name,
1783 ulint page_size, os_offset_t start,
1784 ulint len);
1785
1786#ifndef UNIV_NONINL
1787/** Class to scan the directory hierarchy using a depth first scan. */
1789 public:
1790 using Path = std::string;
1791
1792 /** Check if the path is a directory. The file/directory must exist.
1793 @param[in] path The path to check
1794 @return true if it is a directory */
1795 static bool is_directory(const Path &path);
1796
1797 /** Depth first traversal of the directory starting from basedir
1798 @param[in] basedir Start scanning from this directory
1799 @param[in] recursive `true` if scan should be recursive
1800 @param[in] f Function to call for each entry */
1801 template <typename F>
1802 static void walk(const Path &basedir, bool recursive, F &&f) {
1803#ifdef _WIN32
1804 walk_win32(basedir, recursive, [&](const Path &path, size_t) { f(path); });
1805#else
1806 walk_posix(basedir, recursive, [&](const Path &path, size_t) { f(path); });
1807#endif /* _WIN32 */
1808 }
1809
1810 private:
1811 /** Directory names for the depth first directory scan. */
1812 struct Entry {
1813 /** Constructor
1814 @param[in] path Directory to traverse
1815 @param[in] depth Relative depth to the base
1816 directory in walk() */
1817 Entry(const Path &path, size_t depth) : m_path(path), m_depth(depth) {}
1818
1819 /** Path to the directory */
1821
1822 /** Relative depth of m_path */
1823 size_t m_depth;
1824 };
1825
1826 using Function = std::function<void(const Path &, size_t)>;
1827
1828 /** Depth first traversal of the directory starting from basedir
1829 @param[in] basedir Start scanning from this directory
1830 @param[in] recursive `true` if scan should be recursive
1831 @param[in] f Function to call for each entry */
1832#ifdef _WIN32
1833 static void walk_win32(const Path &basedir, bool recursive, Function &&f);
1834#else
1835 static void walk_posix(const Path &basedir, bool recursive, Function &&f);
1836#endif /* _WIN32 */
1837};
1838
1839/** Allocate a page for sync IO
1840@return pointer to page */
1841[[nodiscard]] file::Block *os_alloc_block() noexcept;
1842
1843/** Get the sector aligned frame pointer.
1844@param[in] block the memory block containing the page frame.
1845@return the sector aligned frame pointer. */
1846[[nodiscard]] byte *os_block_get_frame(const file::Block *block) noexcept;
1847
1848/** Free a page after sync IO
1849@param[in,out] block The block to free/release */
1850void os_free_block(file::Block *block) noexcept;
1851
1852inline void file::Block::free(file::Block *obj) noexcept { os_free_block(obj); }
1853
1854/** Encrypt a page content when write it to disk.
1855@param[in] type IO flags
1856@param[out] buf buffer to read or write
1857@param[in] n number of bytes to read/write, starting from
1858 offset
1859@return pointer to the encrypted page */
1861
1862/** Allocate the buffer for IO on a transparently compressed table.
1863@param[in] type IO flags
1864@param[out] buf buffer to read or write
1865@param[in,out] n number of bytes to read/write, starting from
1866 offset
1867@return pointer to allocated page, compressed data is written to the offset
1868 that is aligned on the disk sector size */
1870
1871/** This is a wrapper function for the os_file_write() function call. The
1872purpose of this wrapper function is to retry on i/o error. On I/O error
1873(perhaps because of disk full situation) keep retrying the write operation
1874till it succeeds.
1875@param[in] type IO flags
1876@param[in] name name of the file or path as a null-terminated string
1877@param[in] file handle to an open file
1878@param[out] buf buffer from which to write
1879@param[in] offset file offset from the start where to read
1880@param[in] n number of bytes to read, starting from offset
1881@return DB_SUCCESS if request was successful, false if fail */
1883 pfs_os_file_t file, const void *buf,
1884 os_offset_t offset, ulint n);
1885
1886/** Helper class for doing synchronous file IO. Currently, the objective
1887is to hide the OS specific code, so that the higher level functions aren't
1888peppered with "#ifdef". Makes the code flow difficult to follow. */
1890 public:
1891 /** Constructor
1892 @param[in] fh File handle
1893 @param[in,out] buf Buffer to read/write
1894 @param[in] n Number of bytes to read/write
1895 @param[in] offset Offset where to read or write */
1897 : m_fh(fh),
1898 m_buf(buf),
1899 m_n(static_cast<ssize_t>(n)),
1900 m_offset(offset),
1901 m_orig_bytes(n) {
1902 ut_ad(m_n > 0);
1903 }
1904
1905 /** Destructor */
1906 ~SyncFileIO() = default;
1907
1908 /** Do the read/write
1909 @param[in] request The IO context and type
1910 @return the number of bytes read/written or negative value on error */
1911 ssize_t execute(const IORequest &request);
1912
1913 /** Do the read/write with retry.
1914 @param[in] request The IO context and type
1915 @param[in] max_retries the maximum number of retries on partial i/o.
1916 @return DB_SUCCESS on success, an error code on failure. */
1918 const IORequest &request,
1919 const size_t max_retries = NUM_RETRIES_ON_PARTIAL_IO);
1920
1921 /** Move the read/write offset up to where the partial IO succeeded.
1922 @param[in] n_bytes The number of bytes to advance */
1923 void advance(ssize_t n_bytes) {
1924 m_offset += n_bytes;
1925
1926 ut_ad(m_n >= n_bytes);
1927
1928 m_n -= n_bytes;
1929
1930 m_buf = reinterpret_cast<uchar *>(m_buf) + n_bytes;
1931 }
1932
1933 private:
1934 /** Open file handle */
1936
1937 /** Buffer to read/write */
1938 void *m_buf;
1939
1940 /** Number of bytes to read/write */
1941 ssize_t m_n;
1942
1943 /** Offset from where to read/write */
1945
1946 /** The total number of bytes to be read/written. */
1947 const size_t m_orig_bytes;
1948};
1949
1950#include "os0file.ic"
1951#endif /* UNIV_NONINL */
1952
1953#endif /* os0file_h */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
@ NORMAL
Get always.
Class to scan the directory hierarchy using a depth first scan.
Definition: os0file.h:1788
std::string Path
Definition: os0file.h:1790
static bool is_directory(const Path &path)
Check if the path is a directory.
Definition: os0file.cc:7664
static void walk_posix(const Path &basedir, bool recursive, Function &&f)
Depth first traversal of the directory starting from basedir.
Definition: os0file.cc:3596
std::function< void(const Path &, size_t)> Function
Definition: os0file.h:1826
static void walk(const Path &basedir, bool recursive, F &&f)
Depth first traversal of the directory starting from basedir.
Definition: os0file.h:1802
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:266
uint32_t m_original_size
Length of the original IO size.
Definition: os0file.h:575
bool is_punch_hole_optimisation_disabled() const
Definition: os0file.h:390
void compression_algorithm(Compression::Type type)
Set compression algorithm.
Definition: os0file.h:454
bool is_dblwr() const
Definition: os0file.h:506
Compression compression_algorithm() const
Get the compression algorithm.
Definition: os0file.h:466
static std::string type_str(const ulint type)
Definition: os0file.cc:7702
bool is_partial_io_warning_disabled() const
Definition: os0file.h:372
void dblwr()
Note that the IO is for double write buffer page write.
Definition: os0file.h:503
void block_size(ulint block_size)
Set the block size for IO.
Definition: os0file.h:429
void clear_encrypted()
Clear all encryption related flags.
Definition: os0file.h:495
void clear_do_not_wake()
Clear the do not wake flag.
Definition: os0file.h:419
bool is_compression_enabled() const
Definition: os0file.h:476
bool is_encrypted() const
Definition: os0file.h:490
ulint block_size() const
Definition: os0file.h:425
void clear_punch_hole()
Clear the punch hole flag.
Definition: os0file.h:422
void disable_partial_io_warnings()
Disable partial read warnings.
Definition: os0file.h:378
const file::Block * get_encrypted_block() const noexcept
Get the encrypted block.
Definition: os0file.h:548
std::string to_string() const
Definition: os0file.h:525
uint32_t get_original_size() const
Returns original size of the IO to make.
Definition: os0file.h:435
bool operator==(const IORequest &rhs) const
Compare two requests.
Definition: os0file.h:450
@ UNSET
Definition: os0file.h:270
@ DBLWR
Request for a doublewrite page IO.
Definition: os0file.h:275
@ DISABLE_PARTIAL_IO_WARNINGS
Disable partial read warnings.
Definition: os0file.h:286
@ IGNORE_MISSING
Ignore failed reads of non-existent pages.
Definition: os0file.h:298
@ DO_NOT_WAKE
Do not to wake i/o-handler threads, but the caller will do the waking explicitly later,...
Definition: os0file.h:295
@ ROW_LOG
Row log used in online DDL.
Definition: os0file.h:311
@ LOG
Log file request.
Definition: os0file.h:283
@ 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:316
@ NO_COMPRESSION
Force raw read, do not try to compress/decompress.
Definition: os0file.h:308
@ WRITE
Definition: os0file.h:272
@ READ
Definition: os0file.h:271
@ DATA_FILE
Enumerations below can be ORed to READ/WRITE above.
Definition: os0file.h:280
@ PUNCH_HOLE
Use punch hole if available, only makes sense if compression algorithm != NONE.
Definition: os0file.h:302
void disable_compression()
Disable transformations.
Definition: os0file.h:481
bool punch_hole() const
Definition: os0file.h:384
IORequest()
Default constructor.
Definition: os0file.h:320
static bool is_punch_hole_supported()
Definition: os0file.h:509
static bool ignore_missing(int type)
Definition: os0file.h:350
void set_original_size(uint32_t original_size)
Definition: os0file.h:437
uint32_t m_block_size
Definition: os0file.h:554
bool ignore_missing() const
Definition: os0file.h:381
Compression m_compression
Compression algorithm.
Definition: os0file.h:560
void set_punch_hole()
Set the punch hole flag.
Definition: os0file.h:405
IORequest(int type)
Definition: os0file.h:333
Encryption & get_encryption_info() noexcept
Get a reference to the underlying encryption information.
Definition: os0file.h:536
uint32_t m_elen
The length of data in encrypted block.
Definition: os0file.h:569
bool is_write() const
Definition: os0file.h:358
bool validate() const
Definition: os0file.h:398
Encryption encryption_algorithm() const
Get the encryption algorithm.
Definition: os0file.h:485
bool is_row_log() const
Definition: os0file.h:364
void set_encrypted_block(const file::Block *eblock) noexcept
Set the encrypted block to the given value.
Definition: os0file.h:542
bool is_compressed() const
Definition: os0file.h:471
bool is_wake() const
Definition: os0file.h:369
void clear_compressed()
Clear all compression related flags.
Definition: os0file.h:442
void disable_punch_hole_optimisation()
Set the force punch hole flag.
Definition: os0file.h:412
const file::Block * m_eblock
The encrypted block.
Definition: os0file.h:566
int m_type
Request type bit flags.
Definition: os0file.h:557
bool is_read() const
Definition: os0file.h:355
bool is_log() const
Definition: os0file.h:361
Encryption m_encryption
Encryption algorithm.
Definition: os0file.h:563
Helper class for doing synchronous file IO.
Definition: os0file.h:1889
~SyncFileIO()=default
Destructor.
os_file_t m_fh
Open file handle.
Definition: os0file.h:1935
dberr_t execute_with_retry(const IORequest &request, const size_t max_retries=NUM_RETRIES_ON_PARTIAL_IO)
Do the read/write with retry.
Definition: os0file.cc:2001
const size_t m_orig_bytes
The total number of bytes to be read/written.
Definition: os0file.h:1947
SyncFileIO(os_file_t fh, void *buf, ulint n, os_offset_t offset)
Constructor.
Definition: os0file.h:1896
ssize_t m_n
Number of bytes to read/write.
Definition: os0file.h:1941
os_offset_t m_offset
Offset from where to read/write.
Definition: os0file.h:1944
ssize_t execute(const IORequest &request)
Do the read/write.
Definition: os0file.cc:2031
void * m_buf
Buffer to read/write.
Definition: os0file.h:1938
void advance(ssize_t n_bytes)
Move the read/write offset up to where the partial IO succeeded.
Definition: os0file.h:1923
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 F
Definition: jit_executor_value.cc:374
#define free(A)
Definition: lexyy.cc:915
#define MY_COMPILER_DIAGNOSTIC_PUSH()
save the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:277
#define MY_COMPILER_DIAGNOSTIC_POP()
restore the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:278
#define DBUG_EXECUTE_IF(keyword, a1)
Definition: my_dbug.h:171
unsigned char uchar
Definition: my_inttypes.h:52
Common #defines and includes for file and socket I/O.
#define FN_REFLEN_SE
Definition: my_io.h:88
static char * path
Definition: mysqldump.cc:150
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1084
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
ValueType max(X &&first)
Definition: gtid.h:103
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:6639
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:5720
constexpr uint32_t OS_FILE_MAX_PATH
Definition: os0file.h:651
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:591
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:3060
ulint os_n_file_reads
Definition: os0file.cc:822
bool os_is_o_direct_supported()
Determine if O_DIRECT is supported.
Definition: os0file.cc:135
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:1026
dberr_t os_file_create_subdirs_if_needed(const char *path)
Create all missing subdirectories along the given path.
Definition: os0file.cc:1809
bool os_file_create_directory(const char *pathname, bool fail_if_exists)
This function attempts to create a directory named pathname.
Definition: os0file.cc:3037
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:6281
static const ulint OS_FILE_AIO_INTERRUPTED
Definition: os0file.h:249
os_file_type_t
Definition: os0file.h:617
@ OS_FILE_TYPE_BLOCK
Block device.
Definition: os0file.h:643
@ OS_FILE_PERMISSION_ERROR
stat() failed with EACCESS
Definition: os0file.h:625
@ OS_FILE_TYPE_MISSING
File doesn't exist.
Definition: os0file.h:628
@ OS_FILE_TYPE_NAME_TOO_LONG
stat() failed, with ENAMETOOLONG
Definition: os0file.h:622
@ OS_FILE_TYPE_UNKNOWN
File exists but type is unknown.
Definition: os0file.h:631
@ OS_FILE_TYPE_DIR
Directory.
Definition: os0file.h:637
@ OS_FILE_TYPE_FAILED
Get status failed.
Definition: os0file.h:619
@ OS_FILE_TYPE_LINK
Symbolic link.
Definition: os0file.h:640
@ OS_FILE_TYPE_FILE
Ordinary file.
Definition: os0file.h:634
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:5517
AIO_mode
Modes for aio operations.
Definition: os0file.h:594
@ 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:825
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:1301
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:3416
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:1599
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:6297
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:5366
static const ulint OS_FILE_ERROR_NOT_SPECIFIED
Definition: os0file.h:247
pfs_os_file_t os_file_create_func(const char *name, ulint create_mode, ulint purpose, bool read_only, bool *success)
NOTE! Use the corresponding macro os_file_create(), not directly this function! Opens an existing fil...
Definition: os0file.cc:3094
std::function< void(const char *path, const char *name)> os_dir_cbk_t
Callback function type to be implemented by caller.
Definition: os0file.h:695
void os_file_set_nocache(int fd, const char *file_name, const char *operation_name, bool on_error_silent=false)
Tries to disable OS caching on an opened file descriptor.
Definition: os0file.cc:5288
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:833
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:5754
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:5682
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:5741
int os_fd_t
Raw file handle.
Definition: os0file.h:115
void os_create_block_cache()
Creates and initializes block_cache.
Definition: os0file.cc:6241
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:5480
mysql_pfs_key_t innodb_arch_file_key
static const ulint OS_FILE_PATH_ERROR
Definition: os0file.h:241
void os_aio_wait_until_no_pending_writes()
Waits until there are no pending writes in os_aio_write_array.
Definition: os0file.cc:6351
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:5335
static const ulint OS_FILE_NOT_FOUND
Error codes from os_file_get_last_error.
Definition: os0file.h:238
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:7653
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:6814
static const ulint OS_FILE_SHARING_VIOLATION
Definition: os0file.h:246
static pfs_os_file_t pfs_os_file_create_func(mysql_pfs_key_t key, const char *name, ulint create_mode, ulint purpose, bool read_only, bool *success, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_create(), not directly this function!...
std::atomic< ulint > os_n_pending_writes
Number of pending write operations.
Definition: os0file.cc:831
static const ulint OS_FILE_READ_ALLOW_DELETE
Used by MySQLBackup.
Definition: os0file.h:219
unsigned long long os_fsync_threshold
Definition: os0file.cc:115
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:6321
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:1721
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:252
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:3262
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:7681
static const ulint OS_FILE_ERROR_MAX
Definition: os0file.h:255
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:3571
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:5728
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:3000
static const ulint OS_FILE_ALREADY_EXISTS
Definition: os0file.h:240
static const ulint OS_FILE_DISK_FULL
Definition: os0file.h:239
bool os_file_rename_func(const char *oldpath, const char *newpath)
NOTE! Use the corresponding macro os_file_rename(), not directly this function! Renames a file (can a...
Definition: os0file.cc:3385
void os_aio_print(FILE *file)
Prints info of the aio arrays.
Definition: os0file.cc:7513
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:836
byte * os_block_get_frame(const file::Block *block) noexcept
Get the sector aligned frame pointer.
Definition: os0file.cc:979
ulint os_n_file_writes
Definition: os0file.cc:824
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:5891
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:5535
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:5788
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:7605
bool os_file_delete_func(const char *name)
Deletes a file.
Definition: os0file.cc:3364
static const ulint OS_FILE_READ_WRITE
Definition: os0file.h:216
static const ulint OS_FILE_ACCESS_VIOLATION
Definition: os0file.h:251
dberr_t os_get_free_space(const char *path, uint64_t &free_space)
Get available free space on disk.
Definition: os0file.cc:5769
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:1923
void os_aio_refresh_stats()
Refreshes the statistics used to print per-second averages.
Definition: os0file.cc:7586
os_file_size_t os_file_get_size(const char *filename)
Gets a file size.
Definition: os0file.cc:3440
static const ulint OS_FILE_AIO_RESOURCES_RESERVED
wait for OS aio resources to become available again
Definition: os0file.h:244
static const ulint OS_CLONE_DATA_FILE
Definition: os0file.h:231
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:5167
static const ulint OS_FILE_OPERATION_ABORTED
Definition: os0file.h:250
void os_aio_simulated_put_read_threads_to_sleep()
This function can be called if one wants to post a batch of reads and prefers an i/o-handler thread t...
Definition: os0file.cc:3589
file::Block * os_alloc_block() noexcept
Allocate a page for sync IO.
Definition: os0file.cc:983
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:5458
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:2474
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:5816
static const ulint OS_DATA_FILE_FOR_SPACE_ID_READ
Definition: os0file.h:234
static const ulint OS_FILE_INSUFFICIENT_RESOURCE
Definition: os0file.h:248
static constexpr os_fd_t OS_FILE_CLOSED
Definition: os0file.h:151
FILE * os_file_create_tmpfile()
Create a temporary file.
Definition: os0file.cc:1572
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:5849
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:7647
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:5671
char * innobase_mysql_tmpdir()
return any of the tmpdir path
Definition: ha_innodb.cc:2472
uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:87
static const ulint OS_FILE_TOO_MANY_OPENED
Definition: os0file.h:253
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:5703
void os_aio_start_threads()
Starts one thread for each segment created in os_aio_init.
Definition: os0file.cc:6294
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:1138
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:1122
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:3328
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:1812
Entry(const Path &path, size_t depth)
Constructor.
Definition: os0file.h:1817
Path m_path
Path to the directory.
Definition: os0file.h:1820
size_t m_depth
Relative depth of m_path.
Definition: os0file.h:1823
File node of a tablespace or the log data space.
Definition: fil0fil.h:160
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:1852
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:581
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:587
os_offset_t m_total_size
Total size of file in bytes.
Definition: os0file.h:583
Struct used in fetching information of a file in a directory.
Definition: os0file.h:656
uint32_t block_size
Block size to use for IO in bytes.
Definition: os0file.h:662
time_t ctime
creation time
Definition: os0file.h:664
char name[OS_FILE_MAX_PATH]
path to a file
Definition: os0file.h:657
time_t atime
access time
Definition: os0file.h:666
bool rw_perm
true if can be opened in read-write mode.
Definition: os0file.h:667
os_file_type_t type
file type
Definition: os0file.h:658
os_offset_t size
file size in bytes
Definition: os0file.h:659
os_offset_t alloc_size
Allocated size for sparse files in bytes.
Definition: os0file.h:660
time_t mtime
modification time
Definition: os0file.h:665
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