mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / innodb_plugin / include / os0file.h
blobc1f8e3003e2bd386dd4dcc13d3d11664582ffdee
1 /***********************************************************************
3 Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
4 Copyright (c) 2009, Percona Inc.
6 Portions of this file contain modifications contributed and copyrighted
7 by Percona Inc.. Those modifications are
8 gratefully acknowledged and are described briefly in the InnoDB
9 documentation. The contributions by Percona Inc. are incorporated with
10 their permission, and subject to the conditions contained in the file
11 COPYING.Percona.
13 This program is free software; you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by the
15 Free Software Foundation; version 2 of the License.
17 This program is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
20 Public License for more details.
22 You should have received a copy of the GNU General Public License along
23 with this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 ***********************************************************************/
28 /**************************************************//**
29 @file include/os0file.h
30 The interface to the operating system file io
32 Created 10/21/1995 Heikki Tuuri
33 *******************************************************/
35 #ifndef os0file_h
36 #define os0file_h
38 #include "univ.i"
40 #ifndef __WIN__
41 #include <dirent.h>
42 #include <sys/stat.h>
43 #include <time.h>
44 #endif
46 /** File node of a tablespace or the log data space */
47 typedef struct fil_node_struct fil_node_t;
49 #ifdef UNIV_DO_FLUSH
50 extern ibool os_do_not_call_flush_at_each_write;
51 #endif /* UNIV_DO_FLUSH */
52 extern ibool os_has_said_disk_full;
53 /** Flag: enable debug printout for asynchronous i/o */
54 extern ibool os_aio_print_debug;
56 /** Number of pending os_file_pread() operations */
57 extern ulint os_file_n_pending_preads;
58 /** Number of pending os_file_pwrite() operations */
59 extern ulint os_file_n_pending_pwrites;
61 /** Number of pending read operations */
62 extern ulint os_n_pending_reads;
63 /** Number of pending write operations */
64 extern ulint os_n_pending_writes;
66 #ifdef __WIN__
68 /** We define always WIN_ASYNC_IO, and check at run-time whether
69 the OS actually supports it: Win 95 does not, NT does. */
70 #define WIN_ASYNC_IO
72 /** Use unbuffered I/O */
73 #define UNIV_NON_BUFFERED_IO
75 #endif
77 #ifdef __WIN__
78 /** File handle */
79 #define os_file_t HANDLE
80 /** Convert a C file descriptor to a native file handle
81 @param fd file descriptor
82 @return native file handle */
83 #define OS_FILE_FROM_FD(fd) (HANDLE) _get_osfhandle(fd)
84 #else
85 /** File handle */
86 typedef int os_file_t;
87 /** Convert a C file descriptor to a native file handle
88 @param fd file descriptor
89 @return native file handle */
90 #define OS_FILE_FROM_FD(fd) fd
91 #endif
93 /** Umask for creating files */
94 extern ulint os_innodb_umask;
96 /** If this flag is TRUE, then we will use the native aio of the
97 OS (provided we compiled Innobase with it in), otherwise we will
98 use simulated aio we build below with threads */
100 extern ibool os_aio_use_native_aio;
102 /** The next value should be smaller or equal to the smallest sector size used
103 on any disk. A log block is required to be a portion of disk which is written
104 so that if the start and the end of a block get written to disk, then the
105 whole block gets written. This should be true even in most cases of a crash:
106 if this fails for a log block, then it is equivalent to a media failure in the
107 log. */
109 #define OS_FILE_LOG_BLOCK_SIZE 512
111 /** Options for file_create @{ */
112 #define OS_FILE_OPEN 51
113 #define OS_FILE_CREATE 52
114 #define OS_FILE_OVERWRITE 53
115 #define OS_FILE_OPEN_RAW 54
116 #define OS_FILE_CREATE_PATH 55
117 #define OS_FILE_OPEN_RETRY 56 /* for os_file_create() on
118 the first ibdata file */
120 #define OS_FILE_READ_ONLY 333
121 #define OS_FILE_READ_WRITE 444
122 #define OS_FILE_READ_ALLOW_DELETE 555 /* for ibbackup */
124 /* Options for file_create */
125 #define OS_FILE_AIO 61
126 #define OS_FILE_NORMAL 62
127 /* @} */
129 /** Types for file create @{ */
130 #define OS_DATA_FILE 100
131 #define OS_LOG_FILE 101
132 /* @} */
134 /** Error codes from os_file_get_last_error @{ */
135 #define OS_FILE_NOT_FOUND 71
136 #define OS_FILE_DISK_FULL 72
137 #define OS_FILE_ALREADY_EXISTS 73
138 #define OS_FILE_PATH_ERROR 74
139 #define OS_FILE_AIO_RESOURCES_RESERVED 75 /* wait for OS aio resources
140 to become available again */
141 #define OS_FILE_SHARING_VIOLATION 76
142 #define OS_FILE_ERROR_NOT_SPECIFIED 77
143 #define OS_FILE_INSUFFICIENT_RESOURCE 78
144 #define OS_FILE_OPERATION_ABORTED 79
145 /* @} */
147 /** Types for aio operations @{ */
148 #define OS_FILE_READ 10
149 #define OS_FILE_WRITE 11
151 #define OS_FILE_LOG 256 /* This can be ORed to type */
152 /* @} */
154 #define OS_AIO_N_PENDING_IOS_PER_THREAD 32 /*!< Win NT does not allow more
155 than 64 */
157 /** Modes for aio operations @{ */
158 #define OS_AIO_NORMAL 21 /*!< Normal asynchronous i/o not for ibuf
159 pages or ibuf bitmap pages */
160 #define OS_AIO_IBUF 22 /*!< Asynchronous i/o for ibuf pages or ibuf
161 bitmap pages */
162 #define OS_AIO_LOG 23 /*!< Asynchronous i/o for the log */
163 #define OS_AIO_SYNC 24 /*!< Asynchronous i/o where the calling thread
164 will itself wait for the i/o to complete,
165 doing also the job of the i/o-handler thread;
166 can be used for any pages, ibuf or non-ibuf.
167 This is used to save CPU time, as we can do
168 with fewer thread switches. Plain synchronous
169 i/o is not as good, because it must serialize
170 the file seek and read or write, causing a
171 bottleneck for parallelism. */
173 #define OS_AIO_SIMULATED_WAKE_LATER 512 /*!< This can be ORed to mode
174 in the call of os_aio(...),
175 if the caller wants to post several i/o
176 requests in a batch, and only after that
177 wake the i/o-handler thread; this has
178 effect only in simulated aio */
179 /* @} */
181 #define OS_WIN31 1 /*!< Microsoft Windows 3.x */
182 #define OS_WIN95 2 /*!< Microsoft Windows 95 */
183 #define OS_WINNT 3 /*!< Microsoft Windows NT 3.x */
184 #define OS_WIN2000 4 /*!< Microsoft Windows 2000 */
186 extern ulint os_n_file_reads;
187 extern ulint os_n_file_writes;
188 extern ulint os_n_fsyncs;
190 /* File types for directory entry data type */
192 enum os_file_type_enum{
193 OS_FILE_TYPE_UNKNOWN = 0,
194 OS_FILE_TYPE_FILE, /* regular file */
195 OS_FILE_TYPE_DIR, /* directory */
196 OS_FILE_TYPE_LINK /* symbolic link */
198 typedef enum os_file_type_enum os_file_type_t;
200 /* Maximum path string length in bytes when referring to tables with in the
201 './databasename/tablename.ibd' path format; we can allocate at least 2 buffers
202 of this size from the thread stack; that is why this should not be made much
203 bigger than 4000 bytes */
204 #define OS_FILE_MAX_PATH 4000
206 /* Struct used in fetching information of a file in a directory */
207 struct os_file_stat_struct{
208 char name[OS_FILE_MAX_PATH]; /*!< path to a file */
209 os_file_type_t type; /*!< file type */
210 ib_int64_t size; /*!< file size */
211 time_t ctime; /*!< creation time */
212 time_t mtime; /*!< modification time */
213 time_t atime; /*!< access time */
215 typedef struct os_file_stat_struct os_file_stat_t;
217 #ifdef __WIN__
218 typedef HANDLE os_file_dir_t; /*!< directory stream */
219 #else
220 typedef DIR* os_file_dir_t; /*!< directory stream */
221 #endif
223 /***********************************************************************//**
224 Gets the operating system version. Currently works only on Windows.
225 @return OS_WIN95, OS_WIN31, OS_WINNT, or OS_WIN2000 */
226 UNIV_INTERN
227 ulint
228 os_get_os_version(void);
229 /*===================*/
230 #ifndef UNIV_HOTBACKUP
231 /****************************************************************//**
232 Creates the seek mutexes used in positioned reads and writes. */
233 UNIV_INTERN
234 void
235 os_io_init_simple(void);
236 /*===================*/
237 /***********************************************************************//**
238 Creates a temporary file. This function is like tmpfile(3), but
239 the temporary file is created in the MySQL temporary directory.
240 On Netware, this function is like tmpfile(3), because the C run-time
241 library of Netware does not expose the delete-on-close flag.
242 @return temporary file handle, or NULL on error */
244 FILE*
245 os_file_create_tmpfile(void);
246 /*========================*/
247 #endif /* !UNIV_HOTBACKUP */
248 /***********************************************************************//**
249 The os_file_opendir() function opens a directory stream corresponding to the
250 directory named by the dirname argument. The directory stream is positioned
251 at the first entry. In both Unix and Windows we automatically skip the '.'
252 and '..' items at the start of the directory listing.
253 @return directory stream, NULL if error */
254 UNIV_INTERN
255 os_file_dir_t
256 os_file_opendir(
257 /*============*/
258 const char* dirname, /*!< in: directory name; it must not
259 contain a trailing '\' or '/' */
260 ibool error_is_fatal);/*!< in: TRUE if we should treat an
261 error as a fatal error; if we try to
262 open symlinks then we do not wish a
263 fatal error if it happens not to be
264 a directory */
265 /***********************************************************************//**
266 Closes a directory stream.
267 @return 0 if success, -1 if failure */
268 UNIV_INTERN
270 os_file_closedir(
271 /*=============*/
272 os_file_dir_t dir); /*!< in: directory stream */
273 /***********************************************************************//**
274 This function returns information of the next file in the directory. We jump
275 over the '.' and '..' entries in the directory.
276 @return 0 if ok, -1 if error, 1 if at the end of the directory */
277 UNIV_INTERN
279 os_file_readdir_next_file(
280 /*======================*/
281 const char* dirname,/*!< in: directory name or path */
282 os_file_dir_t dir, /*!< in: directory stream */
283 os_file_stat_t* info); /*!< in/out: buffer where the info is returned */
284 /*****************************************************************//**
285 This function attempts to create a directory named pathname. The new directory
286 gets default permissions. On Unix, the permissions are (0770 & ~umask). If the
287 directory exists already, nothing is done and the call succeeds, unless the
288 fail_if_exists arguments is true.
289 @return TRUE if call succeeds, FALSE on error */
290 UNIV_INTERN
291 ibool
292 os_file_create_directory(
293 /*=====================*/
294 const char* pathname, /*!< in: directory name as
295 null-terminated string */
296 ibool fail_if_exists);/*!< in: if TRUE, pre-existing directory
297 is treated as an error. */
298 /****************************************************************//**
299 A simple function to open or create a file.
300 @return own: handle to the file, not defined if error, error number
301 can be retrieved with os_file_get_last_error */
302 UNIV_INTERN
303 os_file_t
304 os_file_create_simple(
305 /*==================*/
306 const char* name, /*!< in: name of the file or path as a
307 null-terminated string */
308 ulint create_mode,/*!< in: OS_FILE_OPEN if an existing file is
309 opened (if does not exist, error), or
310 OS_FILE_CREATE if a new file is created
311 (if exists, error), or
312 OS_FILE_CREATE_PATH if new file
313 (if exists, error) and subdirectories along
314 its path are created (if needed)*/
315 ulint access_type,/*!< in: OS_FILE_READ_ONLY or
316 OS_FILE_READ_WRITE */
317 ibool* success);/*!< out: TRUE if succeed, FALSE if error */
318 /****************************************************************//**
319 A simple function to open or create a file.
320 @return own: handle to the file, not defined if error, error number
321 can be retrieved with os_file_get_last_error */
322 UNIV_INTERN
323 os_file_t
324 os_file_create_simple_no_error_handling(
325 /*====================================*/
326 const char* name, /*!< in: name of the file or path as a
327 null-terminated string */
328 ulint create_mode,/*!< in: OS_FILE_OPEN if an existing file
329 is opened (if does not exist, error), or
330 OS_FILE_CREATE if a new file is created
331 (if exists, error) */
332 ulint access_type,/*!< in: OS_FILE_READ_ONLY,
333 OS_FILE_READ_WRITE, or
334 OS_FILE_READ_ALLOW_DELETE; the last option is
335 used by a backup program reading the file */
336 ibool* success);/*!< out: TRUE if succeed, FALSE if error */
337 /****************************************************************//**
338 Tries to disable OS caching on an opened file descriptor. */
339 UNIV_INTERN
340 void
341 os_file_set_nocache(
342 /*================*/
343 int fd, /*!< in: file descriptor to alter */
344 const char* file_name, /*!< in: file name, used in the
345 diagnostic message */
346 const char* operation_name);/*!< in: "open" or "create"; used in the
347 diagnostic message */
348 /****************************************************************//**
349 Opens an existing file or creates a new.
350 @return own: handle to the file, not defined if error, error number
351 can be retrieved with os_file_get_last_error */
352 UNIV_INTERN
353 os_file_t
354 os_file_create(
355 /*===========*/
356 const char* name, /*!< in: name of the file or path as a
357 null-terminated string */
358 ulint create_mode,/*!< in: OS_FILE_OPEN if an existing file
359 is opened (if does not exist, error), or
360 OS_FILE_CREATE if a new file is created
361 (if exists, error),
362 OS_FILE_OVERWRITE if a new file is created
363 or an old overwritten;
364 OS_FILE_OPEN_RAW, if a raw device or disk
365 partition should be opened */
366 ulint purpose,/*!< in: OS_FILE_AIO, if asynchronous,
367 non-buffered i/o is desired,
368 OS_FILE_NORMAL, if any normal file;
369 NOTE that it also depends on type, os_aio_..
370 and srv_.. variables whether we really use
371 async i/o or unbuffered i/o: look in the
372 function source code for the exact rules */
373 ulint type, /*!< in: OS_DATA_FILE or OS_LOG_FILE */
374 ibool* success);/*!< out: TRUE if succeed, FALSE if error */
375 /***********************************************************************//**
376 Deletes a file. The file has to be closed before calling this.
377 @return TRUE if success */
378 UNIV_INTERN
379 ibool
380 os_file_delete(
381 /*===========*/
382 const char* name); /*!< in: file path as a null-terminated string */
384 /***********************************************************************//**
385 Deletes a file if it exists. The file has to be closed before calling this.
386 @return TRUE if success */
387 UNIV_INTERN
388 ibool
389 os_file_delete_if_exists(
390 /*=====================*/
391 const char* name); /*!< in: file path as a null-terminated string */
392 /***********************************************************************//**
393 Renames a file (can also move it to another directory). It is safest that the
394 file is closed before calling this function.
395 @return TRUE if success */
396 UNIV_INTERN
397 ibool
398 os_file_rename(
399 /*===========*/
400 const char* oldpath, /*!< in: old file path as a
401 null-terminated string */
402 const char* newpath); /*!< in: new file path */
403 /***********************************************************************//**
404 Closes a file handle. In case of error, error number can be retrieved with
405 os_file_get_last_error.
406 @return TRUE if success */
407 UNIV_INTERN
408 ibool
409 os_file_close(
410 /*==========*/
411 os_file_t file); /*!< in, own: handle to a file */
412 #ifdef UNIV_HOTBACKUP
413 /***********************************************************************//**
414 Closes a file handle.
415 @return TRUE if success */
416 UNIV_INTERN
417 ibool
418 os_file_close_no_error_handling(
419 /*============================*/
420 os_file_t file); /*!< in, own: handle to a file */
421 #endif /* UNIV_HOTBACKUP */
422 /***********************************************************************//**
423 Gets a file size.
424 @return TRUE if success */
425 UNIV_INTERN
426 ibool
427 os_file_get_size(
428 /*=============*/
429 os_file_t file, /*!< in: handle to a file */
430 ulint* size, /*!< out: least significant 32 bits of file
431 size */
432 ulint* size_high);/*!< out: most significant 32 bits of size */
433 /***********************************************************************//**
434 Gets file size as a 64-bit integer ib_int64_t.
435 @return size in bytes, -1 if error */
436 UNIV_INTERN
437 ib_int64_t
438 os_file_get_size_as_iblonglong(
439 /*===========================*/
440 os_file_t file); /*!< in: handle to a file */
441 /***********************************************************************//**
442 Write the specified number of zeros to a newly created file.
443 @return TRUE if success */
444 UNIV_INTERN
445 ibool
446 os_file_set_size(
447 /*=============*/
448 const char* name, /*!< in: name of the file or path as a
449 null-terminated string */
450 os_file_t file, /*!< in: handle to a file */
451 ulint size, /*!< in: least significant 32 bits of file
452 size */
453 ulint size_high);/*!< in: most significant 32 bits of size */
454 /***********************************************************************//**
455 Truncates a file at its current position.
456 @return TRUE if success */
457 UNIV_INTERN
458 ibool
459 os_file_set_eof(
460 /*============*/
461 FILE* file); /*!< in: file to be truncated */
462 /***********************************************************************//**
463 Flushes the write buffers of a given file to the disk.
464 @return TRUE if success */
465 UNIV_INTERN
466 ibool
467 os_file_flush(
468 /*==========*/
469 os_file_t file); /*!< in, own: handle to a file */
470 /***********************************************************************//**
471 Retrieves the last error number if an error occurs in a file io function.
472 The number should be retrieved before any other OS calls (because they may
473 overwrite the error number). If the number is not known to this program,
474 the OS error number + 100 is returned.
475 @return error number, or OS error number + 100 */
476 UNIV_INTERN
477 ulint
478 os_file_get_last_error(
479 /*===================*/
480 ibool report_all_errors); /*!< in: TRUE if we want an error message
481 printed of all errors */
482 /*******************************************************************//**
483 Requests a synchronous read operation.
484 @return TRUE if request was successful, FALSE if fail */
485 UNIV_INTERN
486 ibool
487 os_file_read(
488 /*=========*/
489 os_file_t file, /*!< in: handle to a file */
490 void* buf, /*!< in: buffer where to read */
491 ulint offset, /*!< in: least significant 32 bits of file
492 offset where to read */
493 ulint offset_high,/*!< in: most significant 32 bits of
494 offset */
495 ulint n); /*!< in: number of bytes to read */
496 /*******************************************************************//**
497 Rewind file to its start, read at most size - 1 bytes from it to str, and
498 NUL-terminate str. All errors are silently ignored. This function is
499 mostly meant to be used with temporary files. */
500 UNIV_INTERN
501 void
502 os_file_read_string(
503 /*================*/
504 FILE* file, /*!< in: file to read from */
505 char* str, /*!< in: buffer where to read */
506 ulint size); /*!< in: size of buffer */
507 /*******************************************************************//**
508 Requests a synchronous positioned read operation. This function does not do
509 any error handling. In case of error it returns FALSE.
510 @return TRUE if request was successful, FALSE if fail */
511 UNIV_INTERN
512 ibool
513 os_file_read_no_error_handling(
514 /*===========================*/
515 os_file_t file, /*!< in: handle to a file */
516 void* buf, /*!< in: buffer where to read */
517 ulint offset, /*!< in: least significant 32 bits of file
518 offset where to read */
519 ulint offset_high,/*!< in: most significant 32 bits of
520 offset */
521 ulint n); /*!< in: number of bytes to read */
523 /*******************************************************************//**
524 Requests a synchronous write operation.
525 @return TRUE if request was successful, FALSE if fail */
526 UNIV_INTERN
527 ibool
528 os_file_write(
529 /*==========*/
530 const char* name, /*!< in: name of the file or path as a
531 null-terminated string */
532 os_file_t file, /*!< in: handle to a file */
533 const void* buf, /*!< in: buffer from which to write */
534 ulint offset, /*!< in: least significant 32 bits of file
535 offset where to write */
536 ulint offset_high,/*!< in: most significant 32 bits of
537 offset */
538 ulint n); /*!< in: number of bytes to write */
539 /*******************************************************************//**
540 Check the existence and type of the given file.
541 @return TRUE if call succeeded */
542 UNIV_INTERN
543 ibool
544 os_file_status(
545 /*===========*/
546 const char* path, /*!< in: pathname of the file */
547 ibool* exists, /*!< out: TRUE if file exists */
548 os_file_type_t* type); /*!< out: type of the file (if it exists) */
549 /****************************************************************//**
550 The function os_file_dirname returns a directory component of a
551 null-terminated pathname string. In the usual case, dirname returns
552 the string up to, but not including, the final '/', and basename
553 is the component following the final '/'. Trailing '/' charac­
554 ters are not counted as part of the pathname.
556 If path does not contain a slash, dirname returns the string ".".
558 Concatenating the string returned by dirname, a "/", and the basename
559 yields a complete pathname.
561 The return value is a copy of the directory component of the pathname.
562 The copy is allocated from heap. It is the caller responsibility
563 to free it after it is no longer needed.
565 The following list of examples (taken from SUSv2) shows the strings
566 returned by dirname and basename for different paths:
568 path dirname basename
569 "/usr/lib" "/usr" "lib"
570 "/usr/" "/" "usr"
571 "usr" "." "usr"
572 "/" "/" "/"
573 "." "." "."
574 ".." "." ".."
576 @return own: directory component of the pathname */
577 UNIV_INTERN
578 char*
579 os_file_dirname(
580 /*============*/
581 const char* path); /*!< in: pathname */
582 /****************************************************************//**
583 Creates all missing subdirectories along the given path.
584 @return TRUE if call succeeded FALSE otherwise */
585 UNIV_INTERN
586 ibool
587 os_file_create_subdirs_if_needed(
588 /*=============================*/
589 const char* path); /*!< in: path name */
590 /***********************************************************************
591 Initializes the asynchronous io system. Creates one array each for ibuf
592 and log i/o. Also creates one array each for read and write where each
593 array is divided logically into n_read_segs and n_write_segs
594 respectively. The caller must create an i/o handler thread for each
595 segment in these arrays. This function also creates the sync array.
596 No i/o handler thread needs to be created for that */
597 UNIV_INTERN
598 void
599 os_aio_init(
600 /*========*/
601 ulint n_per_seg, /*<! in: maximum number of pending aio
602 operations allowed per segment */
603 ulint n_read_segs, /*<! in: number of reader threads */
604 ulint n_write_segs, /*<! in: number of writer threads */
605 ulint n_slots_sync); /*<! in: number of slots in the sync aio
606 array */
607 /***********************************************************************
608 Frees the asynchronous io system. */
609 UNIV_INTERN
610 void
611 os_aio_free(void);
612 /*=============*/
614 /*******************************************************************//**
615 Requests an asynchronous i/o operation.
616 @return TRUE if request was queued successfully, FALSE if fail */
617 UNIV_INTERN
618 ibool
619 os_aio(
620 /*===*/
621 ulint type, /*!< in: OS_FILE_READ or OS_FILE_WRITE */
622 ulint mode, /*!< in: OS_AIO_NORMAL, ..., possibly ORed
623 to OS_AIO_SIMULATED_WAKE_LATER: the
624 last flag advises this function not to wake
625 i/o-handler threads, but the caller will
626 do the waking explicitly later, in this
627 way the caller can post several requests in
628 a batch; NOTE that the batch must not be
629 so big that it exhausts the slots in aio
630 arrays! NOTE that a simulated batch
631 may introduce hidden chances of deadlocks,
632 because i/os are not actually handled until
633 all have been posted: use with great
634 caution! */
635 const char* name, /*!< in: name of the file or path as a
636 null-terminated string */
637 os_file_t file, /*!< in: handle to a file */
638 void* buf, /*!< in: buffer where to read or from which
639 to write */
640 ulint offset, /*!< in: least significant 32 bits of file
641 offset where to read or write */
642 ulint offset_high, /*!< in: most significant 32 bits of
643 offset */
644 ulint n, /*!< in: number of bytes to read or write */
645 fil_node_t* message1,/*!< in: message for the aio handler
646 (can be used to identify a completed
647 aio operation); ignored if mode is
648 OS_AIO_SYNC */
649 void* message2);/*!< in: message for the aio handler
650 (can be used to identify a completed
651 aio operation); ignored if mode is
652 OS_AIO_SYNC */
653 /************************************************************************//**
654 Wakes up all async i/o threads so that they know to exit themselves in
655 shutdown. */
656 UNIV_INTERN
657 void
658 os_aio_wake_all_threads_at_shutdown(void);
659 /*=====================================*/
660 /************************************************************************//**
661 Waits until there are no pending writes in os_aio_write_array. There can
662 be other, synchronous, pending writes. */
663 UNIV_INTERN
664 void
665 os_aio_wait_until_no_pending_writes(void);
666 /*=====================================*/
667 /**********************************************************************//**
668 Wakes up simulated aio i/o-handler threads if they have something to do. */
669 UNIV_INTERN
670 void
671 os_aio_simulated_wake_handler_threads(void);
672 /*=======================================*/
673 /**********************************************************************//**
674 This function can be called if one wants to post a batch of reads and
675 prefers an i/o-handler thread to handle them all at once later. You must
676 call os_aio_simulated_wake_handler_threads later to ensure the threads
677 are not left sleeping! */
678 UNIV_INTERN
679 void
680 os_aio_simulated_put_read_threads_to_sleep(void);
681 /*============================================*/
683 #ifdef WIN_ASYNC_IO
684 /**********************************************************************//**
685 This function is only used in Windows asynchronous i/o.
686 Waits for an aio operation to complete. This function is used to wait the
687 for completed requests. The aio array of pending requests is divided
688 into segments. The thread specifies which segment or slot it wants to wait
689 for. NOTE: this function will also take care of freeing the aio slot,
690 therefore no other thread is allowed to do the freeing!
691 @return TRUE if the aio operation succeeded */
692 UNIV_INTERN
693 ibool
694 os_aio_windows_handle(
695 /*==================*/
696 ulint segment, /*!< in: the number of the segment in the aio
697 arrays to wait for; segment 0 is the ibuf
698 i/o thread, segment 1 the log i/o thread,
699 then follow the non-ibuf read threads, and as
700 the last are the non-ibuf write threads; if
701 this is ULINT_UNDEFINED, then it means that
702 sync aio is used, and this parameter is
703 ignored */
704 ulint pos, /*!< this parameter is used only in sync aio:
705 wait for the aio slot at this position */
706 fil_node_t**message1, /*!< out: the messages passed with the aio
707 request; note that also in the case where
708 the aio operation failed, these output
709 parameters are valid and can be used to
710 restart the operation, for example */
711 void** message2,
712 ulint* type); /*!< out: OS_FILE_WRITE or ..._READ */
713 #endif
715 /**********************************************************************//**
716 Does simulated aio. This function should be called by an i/o-handler
717 thread.
718 @return TRUE if the aio operation succeeded */
719 UNIV_INTERN
720 ibool
721 os_aio_simulated_handle(
722 /*====================*/
723 ulint segment, /*!< in: the number of the segment in the aio
724 arrays to wait for; segment 0 is the ibuf
725 i/o thread, segment 1 the log i/o thread,
726 then follow the non-ibuf read threads, and as
727 the last are the non-ibuf write threads */
728 fil_node_t**message1, /*!< out: the messages passed with the aio
729 request; note that also in the case where
730 the aio operation failed, these output
731 parameters are valid and can be used to
732 restart the operation, for example */
733 void** message2,
734 ulint* type); /*!< out: OS_FILE_WRITE or ..._READ */
735 /**********************************************************************//**
736 Validates the consistency of the aio system.
737 @return TRUE if ok */
738 UNIV_INTERN
739 ibool
740 os_aio_validate(void);
741 /*=================*/
742 /**********************************************************************//**
743 Prints info of the aio arrays. */
744 UNIV_INTERN
745 void
746 os_aio_print(
747 /*=========*/
748 FILE* file); /*!< in: file where to print */
749 /**********************************************************************//**
750 Refreshes the statistics used to print per-second averages. */
751 UNIV_INTERN
752 void
753 os_aio_refresh_stats(void);
754 /*======================*/
756 #ifdef UNIV_DEBUG
757 /**********************************************************************//**
758 Checks that all slots in the system have been freed, that is, there are
759 no pending io operations. */
760 UNIV_INTERN
761 ibool
762 os_aio_all_slots_free(void);
763 /*=======================*/
764 #endif /* UNIV_DEBUG */
766 /*******************************************************************//**
767 This function returns information about the specified file
768 @return TRUE if stat information found */
769 UNIV_INTERN
770 ibool
771 os_file_get_status(
772 /*===============*/
773 const char* path, /*!< in: pathname of the file */
774 os_file_stat_t* stat_info); /*!< information of a file in a
775 directory */
777 #if !defined(UNIV_HOTBACKUP) && !defined(__NETWARE__)
778 /*********************************************************************//**
779 Creates a temporary file that will be deleted on close.
780 This function is defined in ha_innodb.cc.
781 @return temporary file descriptor, or < 0 on error */
782 UNIV_INTERN
784 innobase_mysql_tmpfile(void);
785 /*========================*/
786 #endif /* !UNIV_HOTBACKUP && !__NETWARE__ */
788 #endif