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