MySQL 8.4.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/** NOTE! Use the corresponding macro os_file_create_simple(), not directly
719this function!
720A simple function to open or create a file.
721@param[in] name name of the file or path as a null-terminated
722 string
723@param[in] create_mode create mode
724@param[in] access_type OS_FILE_READ_ONLY or OS_FILE_READ_WRITE
725@param[in] read_only if true, read only checks are enforced
726@param[out] success true if succeed, false if error
727@return handle to the file, not defined if error, error number
728 can be retrieved with os_file_get_last_error */
729os_file_t os_file_create_simple_func(const char *name, ulint create_mode,
730 ulint access_type, bool read_only,
731 bool *success);
732
733/** NOTE! Use the corresponding macro
734os_file_create_simple_no_error_handling(), not directly this function!
735A simple function to open or create a file.
736@param[in] name name of the file or path as a
737null-terminated string
738@param[in] create_mode create mode
739@param[in] access_type OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or
740 OS_FILE_READ_ALLOW_DELETE; the last option
741 is used by a backup program reading the file
742@param[in] read_only if true read only mode checks are enforced
743@param[in] umask UNIX access permission to be set when creating a
744 file. Use os_umask_default to use global default
745 umask.
746@param[out] success true if succeeded
747@return own: handle to the file, not defined if error, error number
748 can be retrieved with os_file_get_last_error */
750 const char *name, ulint create_mode, ulint access_type, bool read_only,
751#ifndef _WIN32
752 mode_t umask,
753#endif
754 bool *success);
755
756/** Tries to disable OS caching on an opened file descriptor.
757@param[in] fd file descriptor to alter
758@param[in] file_name file name, used in the diagnostic message
759@param[in] operation_name "open" or "create"; used in the diagnostic
760 message */
761void os_file_set_nocache(int fd, const char *file_name,
762 const char *operation_name);
763
764/** NOTE! Use the corresponding macro os_file_create(), not directly
765this function!
766Opens an existing file or creates a new.
767@param[in] name name of the file or path as a null-terminated
768 string
769@param[in] create_mode create mode
770@param[in] purpose OS_FILE_AIO, if asynchronous, non-buffered I/O
771 is desired, OS_FILE_NORMAL, if any normal file;
772 NOTE that it also depends on type, os_aio_..
773 and srv_.. variables whether we really use
774 async I/O or unbuffered I/O: look in the
775 function source code for the exact rules
776@param[in] type OS_DATA_FILE, OS_LOG_FILE etc.
777@param[in] read_only if true read only mode checks are enforced
778@param[in] success true if succeeded
779@return own: handle to the file, not defined if error, error number
780 can be retrieved with os_file_get_last_error */
781[[nodiscard]] pfs_os_file_t os_file_create_func(const char *name,
782 ulint create_mode,
783 ulint purpose, ulint type,
784 bool read_only, bool *success);
785
786/** Deletes a file. The file has to be closed before calling this.
787@param[in] name file path as a null-terminated string
788@return true if success */
789bool os_file_delete_func(const char *name);
790
791/** Deletes a file if it exists. The file has to be closed before calling this.
792@param[in] name file path as a null-terminated string
793@param[out] exist indicate if file pre-exist
794@return true if success */
795bool os_file_delete_if_exists_func(const char *name, bool *exist);
796
797/** NOTE! Use the corresponding macro os_file_rename(), not directly
798this function!
799Renames a file (can also move it to another directory). It is safest that the
800file is closed before calling this function.
801@param[in] oldpath old file path as a null-terminated string
802@param[in] newpath new file path
803@return true if success */
804bool os_file_rename_func(const char *oldpath, const char *newpath);
805
806/** NOTE! Use the corresponding macro os_file_close(), not directly
807this function!
808Closes a file handle. In case of error, error number can be retrieved with
809os_file_get_last_error.
810@param[in] file Handle to a file
811@return true if success */
813
814#ifdef UNIV_PFS_IO
815
816/* Keys to register InnoDB I/O with performance schema */
824
825/* Following four macros are instumentations to register
826various file I/O operations with performance schema.
8271) register_pfs_file_open_begin() and register_pfs_file_open_end() are
828used to register file creation, opening and closing.
8292) register_pfs_file_rename_begin() and register_pfs_file_rename_end()
830are used to register file renaming.
8313) register_pfs_file_io_begin() and register_pfs_file_io_end() are
832used to register actual file read, write and flush
8334) register_pfs_file_close_begin() and register_pfs_file_close_end()
834are used to register file deletion operations*/
835#define register_pfs_file_open_begin(state, locker, key, op, name, \
836 src_location) \
837 do { \
838 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
839 op, name, &locker); \
840 if (locker != nullptr) { \
841 PSI_FILE_CALL(start_file_open_wait) \
842 (locker, src_location.filename, static_cast<uint>(src_location.line)); \
843 } \
844 } while (0)
845
846#define register_pfs_file_open_end(locker, file, result) \
847 do { \
848 if (locker != nullptr) { \
849 file.m_psi = PSI_FILE_CALL(end_file_open_wait)(locker, result); \
850 } \
851 } while (0)
852
853#define register_pfs_file_rename_begin(state, locker, key, op, from, to, \
854 src_location) \
855 do { \
856 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
857 op, from, &locker); \
858 if (locker != nullptr) { \
859 PSI_FILE_CALL(start_file_rename_wait) \
860 (locker, (size_t)0, from, to, src_location.filename, \
861 static_cast<uint>(src_location.line)); \
862 } \
863 } while (0)
864
865#define register_pfs_file_rename_end(locker, from, to, result) \
866 do { \
867 if (locker != nullptr) { \
868 PSI_FILE_CALL(end_file_rename_wait)(locker, from, to, result); \
869 } \
870 } while (0)
871
872#define register_pfs_file_close_begin(state, locker, key, op, name, \
873 src_location) \
874 do { \
875 locker = PSI_FILE_CALL(get_thread_file_name_locker)(state, key.m_value, \
876 op, name, &locker); \
877 if (locker != nullptr) { \
878 PSI_FILE_CALL(start_file_close_wait) \
879 (locker, src_location.filename, static_cast<uint>(src_location.line)); \
880 } \
881 } while (0)
882
883#define register_pfs_file_close_end(locker, result) \
884 do { \
885 if (locker != nullptr) { \
886 PSI_FILE_CALL(end_file_close_wait)(locker, result); \
887 } \
888 } while (0)
889
890#define register_pfs_file_io_begin(state, locker, file, count, op, \
891 src_location) \
892 do { \
893 locker = \
894 PSI_FILE_CALL(get_thread_file_stream_locker)(state, file.m_psi, op); \
895 if (locker != nullptr) { \
896 PSI_FILE_CALL(start_file_wait) \
897 (locker, count, src_location.filename, \
898 static_cast<uint>(src_location.line)); \
899 } \
900 } while (0)
901
902#define register_pfs_file_io_end(locker, count) \
903 do { \
904 if (locker != nullptr) { \
905 PSI_FILE_CALL(end_file_wait)(locker, count); \
906 } \
907 } while (0)
908
909/* Following macros/functions are file I/O APIs that would be performance
910schema instrumented if "UNIV_PFS_IO" is defined. They would point to
911wrapper functions with performance schema instrumentation in such case.
912
913os_file_create
914os_file_create_simple
915os_file_create_simple_no_error_handling
916os_file_close
917os_file_rename
918os_aio
919os_file_read
920os_file_read_no_error_handling
921os_file_read_no_error_handling_int_fd
922os_file_write
923
924The wrapper functions have the prefix of "innodb_". */
925
926#define os_file_create(key, name, create, purpose, type, read_only, success) \
927 pfs_os_file_create_func(key, name, create, purpose, type, read_only, \
928 success, UT_LOCATION_HERE)
929
930#define os_file_create_simple(key, name, create, access, read_only, success) \
931 pfs_os_file_create_simple_func(key, name, create, access, read_only, \
932 success, UT_LOCATION_HERE)
933
934#ifndef _WIN32
935#define os_file_create_simple_no_error_handling(key, name, create_mode, \
936 access, read_only, success) \
937 pfs_os_file_create_simple_no_error_handling_func( \
938 key, name, create_mode, access, read_only, os_innodb_umask_default, \
939 success, UT_LOCATION_HERE)
940
941#define os_file_create_simple_no_error_handling_with_umask( \
942 key, name, create_mode, access, read_only, umask, success) \
943 pfs_os_file_create_simple_no_error_handling_func(key, name, create_mode, \
944 access, read_only, umask, \
945 success, UT_LOCATION_HERE)
946#else
947#define os_file_create_simple_no_error_handling(key, name, create_mode, \
948 access, read_only, success) \
949 pfs_os_file_create_simple_no_error_handling_func( \
950 key, name, create_mode, access, read_only, success, UT_LOCATION_HERE)
951#endif
952
953#define os_file_close_pfs(file) pfs_os_file_close_func(file, UT_LOCATION_HERE)
954
955#define os_aio(type, mode, name, file, buf, offset, n, read_only, message1, \
956 message2) \
957 pfs_os_aio_func(type, mode, name, file, buf, offset, n, read_only, message1, \
958 message2, UT_LOCATION_HERE)
959
960#define os_file_read_pfs(type, file_name, file, buf, offset, n) \
961 pfs_os_file_read_func(type, file_name, file, buf, offset, n, UT_LOCATION_HERE)
962
963#define os_file_read_first_page_pfs(type, file_name, file, buf, n) \
964 pfs_os_file_read_first_page_func(type, file_name, file, buf, n, \
965 UT_LOCATION_HERE)
966
967#define os_file_copy_pfs(src, src_offset, dest, dest_offset, size) \
968 pfs_os_file_copy_func(src, src_offset, dest, dest_offset, size, \
969 UT_LOCATION_HERE)
970
971#define os_file_read_no_error_handling_pfs(type, file_name, file, buf, offset, \
972 n, o) \
973 pfs_os_file_read_no_error_handling_func(type, file_name, file, buf, offset, \
974 n, o, UT_LOCATION_HERE)
975
976#define os_file_read_no_error_handling_int_fd(type, file_name, file, buf, \
977 offset, n, o) \
978 pfs_os_file_read_no_error_handling_int_fd_func( \
979 type, file_name, file, buf, offset, n, o, UT_LOCATION_HERE)
980
981#define os_file_write_pfs(type, name, file, buf, offset, n) \
982 pfs_os_file_write_func(type, name, file, buf, offset, n, UT_LOCATION_HERE)
983
984#define os_file_write_int_fd(type, name, file, buf, offset, n) \
985 pfs_os_file_write_int_fd_func(type, name, file, buf, offset, n, \
986 UT_LOCATION_HERE)
987
988#define os_file_flush_pfs(file) pfs_os_file_flush_func(file, UT_LOCATION_HERE)
989
990#define os_file_rename(key, oldpath, newpath) \
991 pfs_os_file_rename_func(key, oldpath, newpath, UT_LOCATION_HERE)
992
993#define os_file_delete(key, name) \
994 pfs_os_file_delete_func(key, name, UT_LOCATION_HERE)
995
996#define os_file_delete_if_exists(key, name, exist) \
997 pfs_os_file_delete_if_exists_func(key, name, exist, UT_LOCATION_HERE)
998
999/** NOTE! Please use the corresponding macro os_file_create_simple(),
1000not directly this function!
1001A performance schema instrumented wrapper function for
1002os_file_create_simple() which opens or creates a file.
1003@param[in] key Performance Schema Key
1004@param[in] name name of the file or path as a null-terminated
1005 string
1006@param[in] create_mode create mode
1007@param[in] access_type OS_FILE_READ_ONLY or OS_FILE_READ_WRITE
1008@param[in] read_only if true read only mode checks are enforced
1009@param[out] success true if succeeded
1010@param[in] src_location location where func invoked
1011@return own: handle to the file, not defined if error, error number
1012 can be retrieved with os_file_get_last_error */
1014 mysql_pfs_key_t key, const char *name, ulint create_mode, ulint access_type,
1015 bool read_only, bool *success, ut::Location src_location);
1016
1017/** NOTE! Please use the corresponding macro
1018os_file_create_simple_no_error_handling(), not directly this function!
1019A performance schema instrumented wrapper function for
1020os_file_create_simple_no_error_handling(). Add instrumentation to
1021monitor file creation/open.
1022@param[in] key Performance Schema Key
1023@param[in] name name of the file or path as a null-terminated
1024 string
1025@param[in] create_mode create mode
1026@param[in] access_type OS_FILE_READ_ONLY, OS_FILE_READ_WRITE, or
1027 OS_FILE_READ_ALLOW_DELETE; the last option is
1028 used by a backup program reading the file
1029@param[in] read_only if true read only mode checks are enforced
1030@param[in] umask UNIX access permission to be set when creating a
1031 file. Use os_umask_default to use global default
1032 umask.
1033@param[out] success true if succeeded
1034@param[in] src_location location where func invoked
1035@return own: handle to the file, not defined if error, error number
1036 can be retrieved with os_file_get_last_error */
1037[[nodiscard]] static inline pfs_os_file_t
1039 mysql_pfs_key_t key, const char *name, ulint create_mode, ulint access_type,
1040 bool read_only,
1041#ifndef _WIN32
1042 mode_t umask,
1043#endif
1044 bool *success, ut::Location src_location);
1045
1046/** NOTE! Please use the corresponding macro os_file_create(), not directly
1047this function!
1048A performance schema wrapper function for os_file_create().
1049Add instrumentation to monitor file creation/open.
1050@param[in] key Performance Schema Key
1051@param[in] name name of the file or path as a null-terminated
1052 string
1053@param[in] create_mode create mode
1054@param[in] purpose OS_FILE_AIO, if asynchronous, non-buffered I/O
1055 is desired, OS_FILE_NORMAL, if any normal file;
1056 NOTE that it also depends on type, os_aio_..
1057 and srv_.. variables whether we really use
1058 async I/O or unbuffered I/O: look in the
1059 function source code for the exact rules
1060@param[in] type OS_DATA_FILE or OS_LOG_FILE
1061@param[in] read_only if true read only mode checks are enforced
1062@param[out] success true if succeeded
1063@param[in] src_location location where func invoked
1064@return own: handle to the file, not defined if error, error number
1065 can be retrieved with os_file_get_last_error */
1066[[nodiscard]] static inline pfs_os_file_t pfs_os_file_create_func(
1067 mysql_pfs_key_t key, const char *name, ulint create_mode, ulint purpose,
1068 ulint type, bool read_only, bool *success, ut::Location src_location);
1069
1070/** NOTE! Please use the corresponding macro os_file_close(), not directly
1071this function!
1072A performance schema instrumented wrapper function for os_file_close().
1073@param[in] file handle to a file
1074@param[in] src_location location where func invoked
1075@return true if success */
1077 ut::Location src_location);
1078
1079/** NOTE! Please use the corresponding macro os_file_read(), not directly
1080this function!
1081This is the performance schema instrumented wrapper function for
1082os_file_read() which requests a synchronous read operation.
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] offset file offset where to read
1088@param[in] n number of bytes to read
1089@param[in] src_location location where func invoked
1090@return DB_SUCCESS if request was successful */
1092 const char *file_name,
1093 pfs_os_file_t file, void *buf,
1094 os_offset_t offset, ulint n,
1095 ut::Location src_location);
1096
1097/** NOTE! Please use the corresponding macro os_file_read_first_page(),
1098not directly this function!
1099This is the performance schema instrumented wrapper function for
1100os_file_read_first_page() which requests a synchronous read operation
1101of page 0 of IBD file
1102@param[in, out] type IO request context
1103@param[in] file_name file name
1104@param[in] file Open file handle
1105@param[out] buf buffer where to read
1106@param[in] n number of bytes to read
1107@param[in] src_location location where func invoked
1108@return DB_SUCCESS if request was successful */
1110 IORequest &type, const char *file_name, pfs_os_file_t file, void *buf,
1111 ulint n, ut::Location src_location);
1112
1113/** copy data from one file to another file. Data is read/written
1114at current file offset.
1115@param[in] src file handle to copy from
1116@param[in] src_offset offset to copy from
1117@param[in] dest file handle to copy to
1118@param[in] dest_offset offset to copy to
1119@param[in] size number of bytes to copy
1120@param[in] src_location location where func invoked
1121@return DB_SUCCESS if successful */
1123 os_offset_t src_offset,
1124 pfs_os_file_t dest,
1125 os_offset_t dest_offset, uint size,
1126 ut::Location src_location);
1127
1128/** NOTE! Please use the corresponding macro os_file_read_no_error_handling(),
1129not directly this function!
1130This is the performance schema instrumented wrapper function for
1131os_file_read_no_error_handling_func() which requests a synchronous
1132read operation.
1133@param[in, out] type IO request context
1134@param[in] file_name file name
1135@param[in] file Open file handle
1136@param[out] buf buffer where to read
1137@param[in] offset file offset where to read
1138@param[in] n number of bytes to read
1139@param[out] o number of bytes actually read
1140@param[in] src_location location where func invoked
1141@return DB_SUCCESS if request was successful */
1143 IORequest &type, const char *file_name, pfs_os_file_t file, void *buf,
1144 os_offset_t offset, ulint n, ulint *o, ut::Location src_location);
1145
1146/** NOTE! Please use the corresponding macro
1147os_file_read_no_error_handling_int_fd(), not directly this function!
1148This is the performance schema instrumented wrapper function for
1149os_file_read_no_error_handling_int_fd_func() which requests a
1150synchronous read operation on files with int type descriptors.
1151@param[in, out] type IO request context
1152@param[in] file_name file name
1153@param[in] file Open file handle
1154@param[out] buf buffer where to read
1155@param[in] offset file offset where to read
1156@param[in] n number of bytes to read
1157@param[out] o number of bytes actually read
1158@param[in] src_location location where func invoked
1159@return DB_SUCCESS if request was successful */
1160
1162 IORequest &type, const char *file_name, int file, void *buf,
1163 os_offset_t offset, ulint n, ulint *o, ut::Location src_location);
1164
1165/** NOTE! Please use the corresponding macro os_aio(), not directly this
1166function!
1167Performance schema wrapper function of os_aio() which requests
1168an asynchronous I/O operation.
1169@param[in] type IO request context
1170@param[in] mode IO mode
1171@param[in] name Name of the file or path as NUL terminated
1172 string
1173@param[in] file Open file handle
1174@param[out] buf buffer where to read
1175@param[in] offset file offset where to read
1176@param[in] n how many bytes to read or write; this
1177must not cross a file boundary; in AIO this must be a block size multiple
1178@param[in] read_only if true read only mode checks are enforced
1179@param[in,out] m1 Message for the AIO handler, (can be used to
1180 identify a completed AIO operation); ignored
1181 if mode is OS_AIO_SYNC
1182@param[in,out] m2 message for the AIO handler (can be used to
1183 identify a completed AIO operation); ignored
1184 if mode is OS_AIO_SYNC
1185@param[in] location location where func invoked
1186@return DB_SUCCESS if request was queued successfully, false if fail */
1188 const char *name, pfs_os_file_t file,
1189 void *buf, os_offset_t offset, ulint n,
1190 bool read_only, fil_node_t *m1, void *m2,
1191 ut::Location location);
1192
1193/** NOTE! Please use the corresponding macro os_file_write(), not directly
1194this function!
1195This is the performance schema instrumented wrapper function for
1196os_file_write() which requests a synchronous write operation.
1197@param[in, out] type IO request context
1198@param[in] name Name of the file or path as NUL terminated
1199 string
1200@param[in] file Open file handle
1201@param[out] buf buffer where to read
1202@param[in] offset file offset where to read
1203@param[in] n number of bytes to read
1204@param[in] src_location location where func invoked
1205@return DB_SUCCESS if request was successful */
1208 const void *buf,
1209 os_offset_t offset, ulint n,
1210 ut::Location src_location);
1211
1212/** NOTE! Please use the corresponding macro os_file_write(), not
1213directly this function!
1214This is the performance schema instrumented wrapper function for
1215os_file_write() which requests a synchronous write operation
1216on files with int type descriptors.
1217@param[in, out] type IO request context
1218@param[in] name Name of the file or path as NUL terminated
1219 string
1220@param[in] file Open file handle
1221@param[out] buf buffer where to read
1222@param[in] offset file offset where to read
1223@param[in] n number of bytes to read
1224@param[in] src_location location where func invoked
1225@return DB_SUCCESS if request was successful */
1227 const char *name, int file,
1228 const void *buf,
1229 os_offset_t offset, ulint n,
1230 ut::Location src_location);
1231
1232/** NOTE! Please use the corresponding macro os_file_flush(), not directly
1233this function!
1234This is the performance schema instrumented wrapper function for
1235os_file_flush() which flushes the write buffers of a given file to the disk.
1236Flushes the write buffers of a given file to the disk.
1237@param[in] file Open file handle
1238@param[in] src_location location where func invoked
1239@return true if success */
1241 ut::Location src_location);
1242
1243/** NOTE! Please use the corresponding macro os_file_rename(), not directly
1244this function!
1245This is the performance schema instrumented wrapper function for
1246os_file_rename()
1247@param[in] key Performance Schema Key
1248@param[in] oldpath old file path as a null-terminated string
1249@param[in] newpath new file path
1250@param[in] src_location location where func invoked
1251@return true if success */
1253 const char *oldpath,
1254 const char *newpath,
1255 ut::Location src_location);
1256
1257/**
1258NOTE! Please use the corresponding macro os_file_delete(), not directly
1259this function!
1260This is the performance schema instrumented wrapper function for
1261os_file_delete()
1262@param[in] key Performance Schema Key
1263@param[in] name old file path as a null-terminated string
1264@param[in] src_location location where func invoked
1265@return true if success */
1267 const char *name,
1268 ut::Location src_location);
1269
1270/**
1271NOTE! Please use the corresponding macro os_file_delete_if_exists(), not
1272directly this function!
1273This is the performance schema instrumented wrapper function for
1274os_file_delete_if_exists()
1275@param[in] key Performance Schema Key
1276@param[in] name old file path as a null-terminated string
1277@param[in] exist indicate if file pre-exist
1278@param[in] src_location location where func invoked
1279@return true if success */
1281 const char *name,
1282 bool *exist,
1283 ut::Location src_location);
1284
1285#else /* UNIV_PFS_IO */
1286
1287/* If UNIV_PFS_IO is not defined, these I/O APIs point
1288to original un-instrumented file I/O APIs */
1289#define os_file_create(key, name, create, purpose, type, read_only, success) \
1290 os_file_create_func(name, create, purpose, type, read_only, success)
1291
1292#define os_file_create_simple(key, name, create_mode, access, read_only, \
1293 success) \
1294 os_file_create_simple_func(name, create_mode, access, read_only, success)
1295
1296#ifndef _WIN32
1297
1298#define os_file_create_simple_no_error_handling(key, name, create_mode, \
1299 access, read_only, success) \
1300 os_file_create_simple_no_error_handling_func( \
1301 name, create_mode, access, read_only, os_innodb_umask_default, success)
1302
1303#define os_file_create_simple_no_error_handling_with_umask( \
1304 key, name, create_mode, access, read_only, umask, success) \
1305 os_file_create_simple_no_error_handling_func(name, create_mode, access, \
1306 read_only, umask, success)
1307
1308#else
1309
1310#define os_file_create_simple_no_error_handling(key, name, create_mode, \
1311 access, read_only, success) \
1312 os_file_create_simple_no_error_handling_func(name, create_mode, access, \
1313 read_only, success)
1314
1315#endif
1316
1317#define os_file_close_pfs(file) os_file_close_func(file)
1318
1319#define os_aio(type, mode, name, file, buf, offset, n, read_only, message1, \
1320 message2) \
1321 os_aio_func(type, mode, name, file, buf, offset, n, read_only, message1, \
1322 message2)
1323
1324#define os_file_read_pfs(type, file_name, file, buf, offset, n) \
1325 os_file_read_func(type, file_name, file, buf, offset, n)
1326
1327#define os_file_read_first_page_pfs(type, file_name, file, buf, n) \
1328 os_file_read_first_page_func(type, file_name, file, buf, n)
1329
1330#define os_file_copy_pfs(src, src_offset, dest, dest_offset, size) \
1331 os_file_copy_func(src, src_offset, dest, dest_offset, size)
1332
1333#define os_file_read_no_error_handling_pfs(type, file_name, file, buf, offset, \
1334 n, o) \
1335 os_file_read_no_error_handling_func(type, file_name, file, buf, offset, n, o)
1336
1337#define os_file_read_no_error_handling_int_fd(type, file_name, file, buf, \
1338 offset, n, o) \
1339 os_file_read_no_error_handling_func(type, file_name, OS_FILE_FROM_FD(file), \
1340 buf, offset, n, o)
1341
1342#define os_file_write_pfs(type, name, file, buf, offset, n) \
1343 os_file_write_func(type, name, file, buf, offset, n)
1344
1345#define os_file_write_int_fd(type, name, file, buf, offset, n) \
1346 os_file_write_func(type, name, OS_FILE_FROM_FD(file), buf, offset, n)
1347
1348#define os_file_flush_pfs(file) os_file_flush_func(file)
1349
1350#define os_file_rename(key, oldpath, newpath) \
1351 os_file_rename_func(oldpath, newpath)
1352
1353#define os_file_delete(key, name) os_file_delete_func(name)
1354
1355#define os_file_delete_if_exists(key, name, exist) \
1356 os_file_delete_if_exists_func(name, exist)
1357
1358#endif /* UNIV_PFS_IO */
1359
1360#ifdef UNIV_PFS_IO
1361#define os_file_close(file) os_file_close_pfs(file)
1362#else
1363#define os_file_close(file) os_file_close_pfs((file).m_file)
1364#endif
1365
1366#ifdef UNIV_PFS_IO
1367#define os_file_read(type, file_name, file, buf, offset, n) \
1368 os_file_read_pfs(type, file_name, file, buf, offset, n)
1369#else
1370#define os_file_read(type, file_name, file, buf, offset, n) \
1371 os_file_read_pfs(type, file_name, file.m_file, buf, offset, n)
1372#endif
1373
1374#ifdef UNIV_PFS_IO
1375#define os_file_read_first_page(type, file_name, file, buf, n) \
1376 os_file_read_first_page_pfs(type, file_name, file, buf, n)
1377#else
1378#define os_file_read_first_page(type, file_name, file, buf, n) \
1379 os_file_read_first_page_pfs(type, file_name, file.m_file, buf, n)
1380#endif
1381
1382#ifdef UNIV_PFS_IO
1383#define os_file_flush(file) os_file_flush_pfs(file)
1384#else
1385#define os_file_flush(file) os_file_flush_pfs(file.m_file)
1386#endif
1387
1388#ifdef UNIV_PFS_IO
1389#define os_file_write(type, name, file, buf, offset, n) \
1390 os_file_write_pfs(type, name, file, buf, offset, n)
1391#else
1392#define os_file_write(type, name, file, buf, offset, n) \
1393 os_file_write_pfs(type, name, file.m_file, buf, offset, n)
1394#endif
1395
1396#ifdef UNIV_PFS_IO
1397#define os_file_copy(src, src_offset, dest, dest_offset, size) \
1398 os_file_copy_pfs(src, src_offset, dest, dest_offset, size)
1399#else
1400#define os_file_copy(src, src_offset, dest, dest_offset, size) \
1401 os_file_copy_pfs(src.m_file, src_offset, dest.m_file, dest_offset, size)
1402#endif
1403
1404#ifdef UNIV_PFS_IO
1405#define os_file_read_no_error_handling(type, file_name, file, buf, offset, n, \
1406 o) \
1407 os_file_read_no_error_handling_pfs(type, file_name, file, buf, offset, n, o)
1408#else
1409#define os_file_read_no_error_handling(type, file_name, file, buf, offset, n, \
1410 o) \
1411 os_file_read_no_error_handling_pfs(type, file_name, file.m_file, buf, \
1412 offset, n, o)
1413#endif
1414
1415#ifdef UNIV_HOTBACKUP
1416/** Closes a file handle.
1417@param[in] file handle to a file
1418@return true if success */
1419bool os_file_close_no_error_handling(os_file_t file);
1420#endif /* UNIV_HOTBACKUP */
1421
1422/** Gets a file size.
1423@param[in] filename Full path to the filename to check
1424@return file size if OK, else set m_total_size to ~0 and m_alloc_size to
1425 errno. */
1426[[nodiscard]] os_file_size_t os_file_get_size(const char *filename);
1427
1428/** Gets a file size.
1429@param[in] file Handle to a file
1430@return file size, or (os_offset_t) -1 on failure */
1432
1433/** Allocate a block to file using fallocate from the given offset if
1434fallocate is supported. Falls back to the old slower method of writing
1435zeros otherwise.
1436@param[in] name name of the file
1437@param[in] file handle to the file
1438@param[in] offset file offset
1439@param[in] size file size
1440@param[in] flush flush file content to disk
1441@return true if success */
1442[[nodiscard]] bool os_file_set_size_fast(const char *name, pfs_os_file_t file,
1444 bool flush);
1445
1446/** Write the specified number of zeros to a file from specific offset.
1447@param[in] name name of the file or path as a null-terminated
1448 string
1449@param[in] file handle to a file
1450@param[in] offset file offset
1451@param[in] size file size
1452@param[in] flush flush file content to disk
1453@return true if success */
1454[[nodiscard]] bool os_file_set_size(const char *name, pfs_os_file_t file,
1456 bool flush);
1457
1458/** Truncates a file at its current position.
1459@param[in,out] file file to be truncated
1460@return true if success */
1461bool os_file_set_eof(FILE *file); /*!< in: file to be truncated */
1462
1463/** Truncates a file to a specified size in bytes.
1464Do nothing if the size to preserve is greater or equal to the current
1465size of the file.
1466@param[in] pathname file path
1467@param[in] file file to be truncated
1468@param[in] size size to preserve in bytes
1469@return true if success */
1470bool os_file_truncate(const char *pathname, pfs_os_file_t file,
1472
1473/** Set read/write position of a file handle to specific offset.
1474@param[in] pathname file path
1475@param[in] file file handle
1476@param[in] offset read/write offset
1477@return true if success */
1478bool os_file_seek(const char *pathname, os_file_t file, os_offset_t offset);
1479
1480/** NOTE! Use the corresponding macro os_file_flush(), not directly this
1481function!
1482Flushes the write buffers of a given file to the disk.
1483@param[in] file handle to a file
1484@return true if success */
1486
1487/** Retrieves the last error number if an error occurs in a file io function.
1488The number should be retrieved before any other OS calls (because they may
1489overwrite the error number). If the number is not known to this program,
1490the OS error number + 100 is returned.
1491@param[in] report_all_errors true if we want an error message printed
1492 for all errors
1493@return error number, or OS error number + 100 */
1494ulint os_file_get_last_error(bool report_all_errors);
1495
1496/** NOTE! Use the corresponding macro os_file_read_first_page(), not directly
1497this function!
1498Requests a synchronous read operation of page 0 of IBD file.
1499@param[in] type IO request context
1500@param[in] file_name file name
1501@param[in] file Open file handle
1502@param[out] buf buffer where to read
1503@param[in] offset file offset where to read
1504@param[in] n number of bytes to read
1505@return DB_SUCCESS if request was successful, DB_IO_ERROR on failure */
1506[[nodiscard]] dberr_t os_file_read_func(IORequest &type, const char *file_name,
1507 os_file_t file, void *buf,
1508 os_offset_t offset, ulint n);
1509
1510/** NOTE! Use the corresponding macro os_file_read_first_page(),
1511not directly this function!
1512Requests a synchronous read operation of page 0 of IBD file
1513@param[in] type IO request context
1514@param[in] file_name file name
1515@param[in] file Open file handle
1516@param[out] buf buffer where to read
1517@param[in] n number of bytes to read
1518@return DB_SUCCESS if request was successful, DB_IO_ERROR on failure */
1520 const char *file_name,
1521 os_file_t file, void *buf,
1522 ulint n);
1523
1524/** Copy data from one file to another file. Data is read/written
1525at current file offset.
1526@param[in] src_file file handle to copy from
1527@param[in] src_offset offset to copy from
1528@param[in] dest_file file handle to copy to
1529@param[in] dest_offset offset to copy to
1530@param[in] size number of bytes to copy
1531@return DB_SUCCESS if successful */
1532[[nodiscard]] dberr_t os_file_copy_func(os_file_t src_file,
1533 os_offset_t src_offset,
1534 os_file_t dest_file,
1535 os_offset_t dest_offset, uint size);
1536
1537/** Rewind file to its start, read at most size - 1 bytes from it to str, and
1538NUL-terminate str. All errors are silently ignored. This function is
1539mostly meant to be used with temporary files.
1540@param[in,out] file File to read from
1541@param[in,out] str Buffer where to read
1542@param[in] size Size of buffer */
1543void os_file_read_string(FILE *file, char *str, ulint size);
1544
1545/** NOTE! Use the corresponding macro os_file_read_no_error_handling(),
1546not directly this function!
1547Requests a synchronous positioned read operation. This function does not do
1548any error handling. In case of error it returns false.
1549@param[in] type IO request context
1550@param[in] file_name file name
1551@param[in] file Open file handle
1552@param[out] buf buffer where to read
1553@param[in] offset file offset where to read
1554@param[in] n number of bytes to read
1555@param[out] o number of bytes actually read
1556@return DB_SUCCESS or error code */
1558 IORequest &type, const char *file_name, os_file_t file, void *buf,
1559 os_offset_t offset, ulint n, ulint *o);
1560
1561/** NOTE! Use the corresponding macro os_file_write(), not directly this
1562function!
1563Requests a synchronous write operation.
1564@param[in,out] type IO request context
1565@param[in] name name of the file or path as a null-terminated
1566 string
1567@param[in] file Open file handle
1568@param[out] buf buffer where to read
1569@param[in] offset file offset where to read
1570@param[in] n number of bytes to read
1571@return DB_SUCCESS if request was successful */
1572[[nodiscard]] dberr_t os_file_write_func(IORequest &type, const char *name,
1573 os_file_t file, const void *buf,
1574 os_offset_t offset, ulint n);
1575
1576/** Check the existence and type of a given path.
1577@param[in] path pathname of the file
1578@param[out] exists true if file exists
1579@param[out] type type of the file (if it exists)
1580@return true if call succeeded */
1581bool os_file_status(const char *path, bool *exists, os_file_type_t *type);
1582
1583/** Check the existence and usefulness of a given path.
1584@param[in] path path name
1585@retval true if the path exists and can be used
1586@retval false if the path does not exist or if the path is
1587unusable to get to a possibly existing file or directory. */
1588bool os_file_exists(const char *path);
1589
1590/** Create all missing subdirectories along the given path.
1591@return DB_SUCCESS if OK, otherwise error code. */
1593
1594#ifdef UNIV_ENABLE_UNIT_TEST_GET_PARENT_DIR
1595/* Test the function os_file_get_parent_dir. */
1596void unit_test_os_file_get_parent_dir();
1597#endif /* UNIV_ENABLE_UNIT_TEST_GET_PARENT_DIR */
1598
1599#ifdef UNIV_HOTBACKUP
1600/** Deallocates the "Blocks" in block_cache */
1601void meb_free_block_cache();
1602#endif /* UNIV_HOTBACKUP */
1603
1604/** Creates and initializes block_cache. Creates array of MAX_BLOCKS
1605and allocates the memory in each block to hold BUFFER_BLOCK_SIZE
1606of data.
1607
1608This function is called by InnoDB during srv_start().
1609It is also called by MEB while applying the redo logs on TDE tablespaces,
1610the "Blocks" allocated in this block_cache are used to hold the decrypted
1611page data. */
1613
1614/** Initializes the asynchronous io system.
1615Creates an array for ibuf i/o (if not in read-only mode).
1616Also creates one array each for read and write where each
1617array is divided logically into n_readers and n_writers
1618respectively. The caller must create an i/o handler thread for each
1619segment in these arrays by calling os_aio_start_threads().
1620
1621@param[in] n_readers number of reader threads
1622@param[in] n_writers number of writer threads */
1623bool os_aio_init(ulint n_readers, ulint n_writers);
1624
1625/** Starts one thread for each segment created in os_aio_init */
1627
1628/**
1629Frees the asynchronous io system. */
1630void os_aio_free();
1631
1632/**
1633NOTE! Use the corresponding macro os_aio(), not directly this function!
1634Requests an asynchronous i/o operation.
1635@param[in] type IO request context
1636@param[in] aio_mode IO mode
1637@param[in] name Name of the file or path as NUL terminated
1638string
1639@param[in] file Open file handle
1640@param[out] buf buffer where to read
1641@param[in] offset file offset where to read
1642@param[in] n how many bytes to read or write; this
1643must not cross a file boundary; in AIO this must be a block size multiple
1644@param[in] read_only if true read only mode checks are enforced
1645@param[in,out] m1 Message for the AIO handler, (can be used to
1646identify a completed AIO operation); ignored if mode is OS_AIO_SYNC
1647@param[in,out] m2 message for the AIO handler (can be used to
1648identify a completed AIO operation); ignored if mode is OS_AIO_SYNC
1649@return DB_SUCCESS or error code */
1650dberr_t os_aio_func(IORequest &type, AIO_mode aio_mode, const char *name,
1651 pfs_os_file_t file, void *buf, os_offset_t offset, ulint n,
1652 bool read_only, fil_node_t *m1, void *m2);
1653
1654/** Wakes up all async i/o threads so that they know to exit themselves in
1655shutdown. */
1657
1658/** Waits until there are no pending writes in os_aio_write_array. There can
1659be other, synchronous, pending writes. */
1661
1662/** Wakes up simulated aio i/o-handler threads if they have something to do. */
1664
1665/** This function can be called if one wants to post a batch of reads and
1666prefers an i/o-handler thread to handle them all at once later. You must
1667call os_aio_simulated_wake_handler_threads later to ensure the threads
1668are not left sleeping! */
1670
1671/** Waits for an AIO operation to complete. This function is used to wait the
1672for completed requests. The AIO array of pending requests is divided
1673into segments. The thread specifies which segment or slot it wants to wait
1674for. NOTE: this function will also take care of freeing the AIO slot,
1675therefore no other thread is allowed to do the freeing!
1676@param[in] segment The number of the segment in the AIO arrays to
1677 wait for; segment 0 is the ibuf I/O thread,
1678 then follow the non-ibuf read threads,
1679 and as the last are the non-ibuf write threads
1680@param[out] m1 the messages passed with the AIO request; note
1681 that also in the case where the AIO operation
1682 failed, these output parameters are valid and
1683 can be used to restart the operation,
1684 for example
1685@param[out] m2 callback message
1686@param[out] request OS_FILE_WRITE or ..._READ
1687@return DB_SUCCESS or error code */
1688dberr_t os_aio_handler(ulint segment, fil_node_t **m1, void **m2,
1689 IORequest *request);
1690
1691/** Prints info of the aio arrays.
1692@param[in,out] file file where to print */
1693void os_aio_print(FILE *file);
1694
1695/** Refreshes the statistics used to print per-second averages. */
1697
1698/** Checks that all slots in the system have been freed, that is, there are
1699no pending io operations. */
1701
1702#ifdef UNIV_DEBUG
1703
1704/** Prints all pending IO
1705@param[in] file File where to print */
1707
1708#endif /* UNIV_DEBUG */
1709
1710/** Get available free space on disk
1711@param[in] path pathname of a directory or file in disk
1712@param[out] free_space free space available in bytes
1713@return DB_SUCCESS if all OK */
1714dberr_t os_get_free_space(const char *path, uint64_t &free_space);
1715
1716/** This function returns information about the specified file
1717@param[in] path pathname of the file
1718@param[out] stat_info information of a file in a directory
1719@param[in] check_rw_perm for testing whether the file can be opened
1720 in RW mode
1721@param[in] read_only true if file is opened in read-only mode
1722@return DB_SUCCESS if all OK */
1723dberr_t os_file_get_status(const char *path, os_file_stat_t *stat_info,
1724 bool check_rw_perm, bool read_only);
1725
1726/** Check if a file can be opened in read-write mode.
1727 @param[in] name filename to check
1728 @param[in] read_only true if check for read-only mode only
1729 @retval true if file can be opened in the specified mode (rw or ro);
1730 or file does not exist
1731 @retval false if file exists and can't be opened in the specified mode */
1732bool os_file_check_mode(const char *name, bool read_only);
1733
1734#ifndef UNIV_HOTBACKUP
1735
1736/** return any of the tmpdir path */
1737char *innobase_mysql_tmpdir();
1738
1739/** Creates a temporary file in the location specified by the parameter
1740path. If the path is NULL, then it will be created in --tmpdir.
1741@param[in] path location for creating temporary file
1742@return temporary file descriptor, or OS_FD_CLOSED on error */
1744
1745#endif /* !UNIV_HOTBACKUP */
1746
1747/** If it is a compressed page return the compressed page data + footer size
1748@param[in] buf Buffer to check, must include header + 10 bytes
1749@return ULINT_UNDEFINED if the page is not a compressed page or length
1750 of the compressed data (including footer) if it is a compressed page */
1752
1753/** If it is a compressed page return the original page data + footer size
1754@param[in] buf Buffer to check, must include header + 10 bytes
1755@return ULINT_UNDEFINED if the page is not a compressed page or length
1756 of the original data + footer if it is a compressed page */
1758
1759#ifndef _WIN32
1760/** Set the global file create umask. This value is to be set once, at startup
1761and never modified.
1762@param[in] umask The umask to use for all InnoDB file creation.
1763*/
1764void os_file_set_umask(mode_t umask);
1765
1766/** A magic constant for the umask parameter that indicates caller wants the
1767`os_innodb_umask` value to be used. The `os_innodb_umask` is a static value,
1768private to this module, and to the file creation methods, so it should not be
1769used directly. */
1770constexpr mode_t os_innodb_umask_default = std::numeric_limits<mode_t>::max();
1771
1772#endif
1773
1774/** Free storage space associated with a section of the file.
1775@param[in] fh Open file handle
1776@param[in] off Starting offset (SEEK_SET)
1777@param[in] len Size of the hole
1778@return DB_SUCCESS or error code */
1779[[nodiscard]] dberr_t os_file_punch_hole(os_file_t fh, os_offset_t off,
1780 os_offset_t len);
1781
1782/** Check if the file system supports sparse files.
1783
1784Warning: On POSIX systems we try and punch a hole from offset 0 to
1785the system configured page size. This should only be called on an empty
1786file.
1787
1788Note: On Windows we use the name and on Unices we use the file handle.
1789
1790@param[in] fh File handle for the file - if opened
1791@return true if the file system supports sparse files */
1792[[nodiscard]] bool os_is_sparse_file_supported(pfs_os_file_t fh);
1793
1794/** Decompress the page data contents. Page type must be FIL_PAGE_COMPRESSED, if
1795not then the source contents are left unchanged and DB_SUCCESS is returned.
1796@param[in] dblwr_read true of double write recovery in progress
1797@param[in,out] src Data read from disk, decompressed data will be
1798 copied to this page
1799@param[in,out] dst Scratch area to use for decompression or
1800 nullptr.
1801@param[in] dst_len If dst is valid, then size of the scratch area
1802 in bytes
1803@return DB_SUCCESS or error code */
1804[[nodiscard]] dberr_t os_file_decompress_page(bool dblwr_read, byte *src,
1805 byte *dst, ulint dst_len);
1806
1807/** Compress a data page
1808@param[in] compression Compression algorithm
1809@param[in] block_size File system block size
1810@param[in] src Source contents to compress
1811@param[in] src_len Length in bytes of the source
1812@param[out] dst Compressed page contents
1813@param[out] dst_len Length in bytes of dst contents
1814@return buffer data, dst_len will have the length of the data */
1815byte *os_file_compress_page(Compression compression, ulint block_size,
1816 byte *src, ulint src_len, byte *dst,
1817 ulint *dst_len);
1818
1819/** Determine if O_DIRECT is supported.
1820@retval true if O_DIRECT is supported.
1821@retval false if O_DIRECT is not supported. */
1822[[nodiscard]] bool os_is_o_direct_supported();
1823
1824/** Fill the pages with NULs
1825@param[in] file File handle
1826@param[in] name File name
1827@param[in] page_size physical page size
1828@param[in] start Offset from the start of the file in bytes
1829@param[in] len Length in bytes
1830@return DB_SUCCESS or error code */
1831[[nodiscard]] dberr_t os_file_write_zeros(pfs_os_file_t file, const char *name,
1832 ulint page_size, os_offset_t start,
1833 ulint len);
1834
1835#ifndef UNIV_NONINL
1836/** Class to scan the directory hierarchy using a depth first scan. */
1838 public:
1839 using Path = std::string;
1840
1841 /** Check if the path is a directory. The file/directory must exist.
1842 @param[in] path The path to check
1843 @return true if it is a directory */
1844 static bool is_directory(const Path &path);
1845
1846 /** Depth first traversal of the directory starting from basedir
1847 @param[in] basedir Start scanning from this directory
1848 @param[in] recursive `true` if scan should be recursive
1849 @param[in] f Function to call for each entry */
1850 template <typename F>
1851 static void walk(const Path &basedir, bool recursive, F &&f) {
1852#ifdef _WIN32
1853 walk_win32(basedir, recursive, [&](const Path &path, size_t) { f(path); });
1854#else
1855 walk_posix(basedir, recursive, [&](const Path &path, size_t) { f(path); });
1856#endif /* _WIN32 */
1857 }
1858
1859 private:
1860 /** Directory names for the depth first directory scan. */
1861 struct Entry {
1862 /** Constructor
1863 @param[in] path Directory to traverse
1864 @param[in] depth Relative depth to the base
1865 directory in walk() */
1866 Entry(const Path &path, size_t depth) : m_path(path), m_depth(depth) {}
1867
1868 /** Path to the directory */
1870
1871 /** Relative depth of m_path */
1872 size_t m_depth;
1873 };
1874
1875 using Function = std::function<void(const Path &, size_t)>;
1876
1877 /** Depth first traversal of the directory starting from basedir
1878 @param[in] basedir Start scanning from this directory
1879 @param[in] recursive `true` if scan should be recursive
1880 @param[in] f Function to call for each entry */
1881#ifdef _WIN32
1882 static void walk_win32(const Path &basedir, bool recursive, Function &&f);
1883#else
1884 static void walk_posix(const Path &basedir, bool recursive, Function &&f);
1885#endif /* _WIN32 */
1886};
1887
1888/** Allocate a page for sync IO
1889@return pointer to page */
1890[[nodiscard]] file::Block *os_alloc_block() noexcept;
1891
1892/** Get the sector aligned frame pointer.
1893@param[in] block the memory block containing the page frame.
1894@return the sector aligned frame pointer. */
1895[[nodiscard]] byte *os_block_get_frame(const file::Block *block) noexcept;
1896
1897/** Free a page after sync IO
1898@param[in,out] block The block to free/release */
1899void os_free_block(file::Block *block) noexcept;
1900
1901inline void file::Block::free(file::Block *obj) noexcept { os_free_block(obj); }
1902
1903/** Encrypt a page content when write it to disk.
1904@param[in] type IO flags
1905@param[out] buf buffer to read or write
1906@param[in] n number of bytes to read/write, starting from
1907 offset
1908@return pointer to the encrypted page */
1910
1911/** Allocate the buffer for IO on a transparently compressed table.
1912@param[in] type IO flags
1913@param[out] buf buffer to read or write
1914@param[in,out] n number of bytes to read/write, starting from
1915 offset
1916@return pointer to allocated page, compressed data is written to the offset
1917 that is aligned on the disk sector size */
1919
1920/** This is a wrapper function for the os_file_write() function call. The
1921purpose of this wrapper function is to retry on i/o error. On I/O error
1922(perhaps because of disk full situation) keep retrying the write operation
1923till it succeeds.
1924@param[in] type IO flags
1925@param[in] name name of the file or path as a null-terminated string
1926@param[in] file handle to an open file
1927@param[out] buf buffer from which to write
1928@param[in] offset file offset from the start where to read
1929@param[in] n number of bytes to read, starting from offset
1930@return DB_SUCCESS if request was successful, false if fail */
1932 pfs_os_file_t file, const void *buf,
1933 os_offset_t offset, ulint n);
1934
1935/** Helper class for doing synchronous file IO. Currently, the objective
1936is to hide the OS specific code, so that the higher level functions aren't
1937peppered with "#ifdef". Makes the code flow difficult to follow. */
1939 public:
1940 /** Constructor
1941 @param[in] fh File handle
1942 @param[in,out] buf Buffer to read/write
1943 @param[in] n Number of bytes to read/write
1944 @param[in] offset Offset where to read or write */
1946 : m_fh(fh),
1947 m_buf(buf),
1948 m_n(static_cast<ssize_t>(n)),
1949 m_offset(offset),
1950 m_orig_bytes(n) {
1951 ut_ad(m_n > 0);
1952 }
1953
1954 /** Destructor */
1955 ~SyncFileIO() = default;
1956
1957 /** Do the read/write
1958 @param[in] request The IO context and type
1959 @return the number of bytes read/written or negative value on error */
1960 ssize_t execute(const IORequest &request);
1961
1962 /** Do the read/write with retry.
1963 @param[in] request The IO context and type
1964 @param[in] max_retries the maximum number of retries on partial i/o.
1965 @return DB_SUCCESS on success, an error code on failure. */
1967 const IORequest &request,
1968 const size_t max_retries = NUM_RETRIES_ON_PARTIAL_IO);
1969
1970 /** Move the read/write offset up to where the partial IO succeeded.
1971 @param[in] n_bytes The number of bytes to advance */
1972 void advance(ssize_t n_bytes) {
1973 m_offset += n_bytes;
1974
1975 ut_ad(m_n >= n_bytes);
1976
1977 m_n -= n_bytes;
1978
1979 m_buf = reinterpret_cast<uchar *>(m_buf) + n_bytes;
1980 }
1981
1982 private:
1983 /** Open file handle */
1985
1986 /** Buffer to read/write */
1987 void *m_buf;
1988
1989 /** Number of bytes to read/write */
1990 ssize_t m_n;
1991
1992 /** Offset from where to read/write */
1994
1995 /** The total number of bytes to be read/written. */
1996 const size_t m_orig_bytes;
1997};
1998
1999#include "os0file.ic"
2000#endif /* UNIV_NONINL */
2001
2002#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:1837
std::string Path
Definition: os0file.h:1839
static bool is_directory(const Path &path)
Check if the path is a directory.
Definition: os0file.cc:7897
static void walk_posix(const Path &basedir, bool recursive, Function &&f)
Depth first traversal of the directory starting from basedir.
Definition: os0file.cc:3611
std::function< void(const Path &, size_t)> Function
Definition: os0file.h:1875
static void walk(const Path &basedir, bool recursive, F &&f)
Depth first traversal of the directory starting from basedir.
Definition: os0file.h:1851
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:7935
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
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
@ 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
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:1938
~SyncFileIO()=default
Destructor.
os_file_t m_fh
Open file handle.
Definition: os0file.h:1984
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:1996
SyncFileIO(os_file_t fh, void *buf, ulint n, os_offset_t offset)
Constructor.
Definition: os0file.h:1945
ssize_t m_n
Number of bytes to read/write.
Definition: os0file.h:1990
os_offset_t m_offset
Offset from where to read/write.
Definition: os0file.h:1993
ssize_t execute(const IORequest &request)
Do the read/write.
Definition: os0file.cc:2025
void * m_buf
Buffer to read/write.
Definition: os0file.h:1987
void advance(ssize_t n_bytes)
Move the read/write offset up to where the partial IO succeeded.
Definition: os0file.h:1972
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 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:1073
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:2870
static int exists(node_address *name, node_list const *nodes, u_int with_uid)
Definition: node_list.cc:106
Macros for using atomics.
Page encryption infrastructure.
static const ulint OS_FILE_READ_ONLY
Definition: os0file.h: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:6881
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:5851
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:3107
ulint os_n_file_reads
Definition: os0file.cc:813
bool os_is_o_direct_supported()
Determine if O_DIRECT is supported.
Definition: os0file.cc:129
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:1017
dberr_t os_file_create_subdirs_if_needed(const char *path)
Create all missing subdirectories along the given path.
Definition: os0file.cc:1804
bool os_file_create_directory(const char *pathname, bool fail_if_exists)
This function attempts to create a directory named pathname.
Definition: os0file.cc:3088
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:6498
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:5648
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:816
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:1293
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:3431
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:1594
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:6520
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:5497
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:824
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:5885
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:5813
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:3141
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:5872
int os_fd_t
Raw file handle.
Definition: os0file.h:115
void os_create_block_cache()
Creates and initializes block_cache.
Definition: os0file.cc:6456
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:5611
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:6574
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:5466
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:7886
os_file_t os_file_create_simple_func(const char *name, ulint create_mode, ulint access_type, bool read_only, bool *success)
NOTE! Use the corresponding macro os_file_create_simple(), not directly this function!...
Definition: os0file.cc:2997
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:7056
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:822
static const ulint OS_FILE_READ_ALLOW_DELETE
Used by MySQLBackup.
Definition: os0file.h:223
unsigned long long os_fsync_threshold
Definition: os0file.cc:106
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:6544
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:1770
static pfs_os_file_t pfs_os_file_create_simple_no_error_handling_func(mysql_pfs_key_t key, const char *name, ulint create_mode, ulint access_type, bool read_only, mode_t umask, bool *success, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_create_simple_no_error_handling(),...
static pfs_os_file_t pfs_os_file_create_func(mysql_pfs_key_t key, const char *name, ulint create_mode, ulint purpose, ulint type, bool read_only, bool *success, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_create(), not directly this function!...
static const ulint OS_FILE_NAME_TOO_LONG
Definition: os0file.h: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)
NOTE! Use the corresponding macro os_file_create_simple_no_error_handling(), not directly this functi...
Definition: os0file.cc:3286
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:7914
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:3586
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:5859
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:2959
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:5420
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:3402
void os_aio_print(FILE *file)
Prints info of the aio arrays.
Definition: os0file.cc:7746
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:827
byte * os_block_get_frame(const file::Block *block) noexcept
Get the sector aligned frame pointer.
Definition: os0file.cc:970
ulint os_n_file_writes
Definition: os0file.cc:815
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:6022
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:5666
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:5919
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:7838
bool os_file_delete_func(const char *name)
Deletes a file.
Definition: os0file.cc:3383
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:5900
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:1918
void os_aio_refresh_stats()
Refreshes the statistics used to print per-second averages.
Definition: os0file.cc:7819
os_file_size_t os_file_get_size(const char *filename)
Gets a file size.
Definition: os0file.cc:3455
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:5299
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:3604
file::Block * os_alloc_block() noexcept
Allocate a page for sync IO.
Definition: os0file.cc:974
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:5589
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:2456
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:5947
static const ulint OS_FILE_INSUFFICIENT_RESOURCE
Definition: os0file.h:260
static constexpr os_fd_t OS_FILE_CLOSED
Definition: os0file.h:155
static pfs_os_file_t pfs_os_file_create_simple_func(mysql_pfs_key_t key, const char *name, ulint create_mode, ulint access_type, bool read_only, bool *success, ut::Location src_location)
NOTE! Please use the corresponding macro os_file_create_simple(), not directly this function!...
FILE * os_file_create_tmpfile()
Create a temporary file.
Definition: os0file.cc:1567
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:5980
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:7880
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:5802
char * innobase_mysql_tmpdir()
return any of the tmpdir path
Definition: ha_innodb.cc:2454
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:5834
void os_aio_start_threads()
Starts one thread for each segment created in os_aio_init.
Definition: os0file.cc:6517
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:1129
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:1113
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:3348
The interface to the operating system file io.
const char * filename
Definition: pfs_example_component_population.cc:67
required string key
Definition: replication_asynchronous_connection_failover.proto:60
required string type
Definition: replication_group_member_actions.proto:34
case opt name
Definition: sslopt-case.h: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:1861
Entry(const Path &path, size_t depth)
Constructor.
Definition: os0file.h:1866
Path m_path
Path to the directory.
Definition: os0file.h:1869
size_t m_depth
Relative depth of m_path.
Definition: os0file.h:1872
File node of a tablespace or the log data space.
Definition: fil0fil.h:151
Blocks for doing IO, used in the transparent compression and encryption code.
Definition: os0file.h:92
Block() noexcept
Default constructor.
Definition: os0file.h:94
static void free(file::Block *obj) noexcept
Free the given memory block.
Definition: os0file.h:1901
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