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