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