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