00001 /****************************************************** 00002 The interface to the operating system file io 00003 00004 (c) 1995 Innobase Oy 00005 00006 Created 10/21/1995 Heikki Tuuri 00007 *******************************************************/ 00008 00009 #ifndef os0file_h 00010 #define os0file_h 00011 00012 #include "univ.i" 00013 00014 #ifndef __WIN__ 00015 #include <dirent.h> 00016 #include <sys/stat.h> 00017 #include <time.h> 00018 #endif 00019 00020 typedef struct fil_node_struct fil_node_t; 00021 00022 #ifdef UNIV_DO_FLUSH 00023 extern ibool os_do_not_call_flush_at_each_write; 00024 #endif /* UNIV_DO_FLUSH */ 00025 extern ibool os_has_said_disk_full; 00026 extern ibool os_aio_print_debug; 00027 00028 extern ulint os_file_n_pending_preads; 00029 extern ulint os_file_n_pending_pwrites; 00030 00031 extern ulint os_n_pending_reads; 00032 extern ulint os_n_pending_writes; 00033 00034 #ifdef __WIN__ 00035 00036 /* We define always WIN_ASYNC_IO, and check at run-time whether 00037 the OS actually supports it: Win 95 does not, NT does. */ 00038 #define WIN_ASYNC_IO 00039 00040 #define UNIV_NON_BUFFERED_IO 00041 00042 #endif 00043 00044 #ifdef __WIN__ 00045 #define os_file_t HANDLE 00046 #else 00047 typedef int os_file_t; 00048 #endif 00049 00050 extern ulint os_innodb_umask; 00051 00052 /* If this flag is TRUE, then we will use the native aio of the 00053 OS (provided we compiled Innobase with it in), otherwise we will 00054 use simulated aio we build below with threads */ 00055 00056 extern ibool os_aio_use_native_aio; 00057 00058 #define OS_FILE_SECTOR_SIZE 512 00059 00060 /* The next value should be smaller or equal to the smallest sector size used 00061 on any disk. A log block is required to be a portion of disk which is written 00062 so that if the start and the end of a block get written to disk, then the 00063 whole block gets written. This should be true even in most cases of a crash: 00064 if this fails for a log block, then it is equivalent to a media failure in the 00065 log. */ 00066 00067 #define OS_FILE_LOG_BLOCK_SIZE 512 00068 00069 /* Options for file_create */ 00070 #define OS_FILE_OPEN 51 00071 #define OS_FILE_CREATE 52 00072 #define OS_FILE_OVERWRITE 53 00073 #define OS_FILE_OPEN_RAW 54 00074 #define OS_FILE_CREATE_PATH 55 00075 #define OS_FILE_OPEN_RETRY 56 /* for os_file_create() on 00076 the first ibdata file */ 00077 00078 #define OS_FILE_READ_ONLY 333 00079 #define OS_FILE_READ_WRITE 444 00080 #define OS_FILE_READ_ALLOW_DELETE 555 /* for ibbackup */ 00081 00082 /* Options for file_create */ 00083 #define OS_FILE_AIO 61 00084 #define OS_FILE_NORMAL 62 00085 00086 /* Types for file create */ 00087 #define OS_DATA_FILE 100 00088 #define OS_LOG_FILE 101 00089 00090 /* Error codes from os_file_get_last_error */ 00091 #define OS_FILE_NOT_FOUND 71 00092 #define OS_FILE_DISK_FULL 72 00093 #define OS_FILE_ALREADY_EXISTS 73 00094 #define OS_FILE_PATH_ERROR 74 00095 #define OS_FILE_AIO_RESOURCES_RESERVED 75 /* wait for OS aio resources 00096 to become available again */ 00097 #define OS_FILE_ERROR_NOT_SPECIFIED 76 00098 00099 /* Types for aio operations */ 00100 #define OS_FILE_READ 10 00101 #define OS_FILE_WRITE 11 00102 00103 #define OS_FILE_LOG 256 /* This can be ORed to type */ 00104 00105 #define OS_AIO_N_PENDING_IOS_PER_THREAD 32 /* Win NT does not allow more 00106 than 64 */ 00107 00108 /* Modes for aio operations */ 00109 #define OS_AIO_NORMAL 21 /* Normal asynchronous i/o not for ibuf 00110 pages or ibuf bitmap pages */ 00111 #define OS_AIO_IBUF 22 /* Asynchronous i/o for ibuf pages or ibuf 00112 bitmap pages */ 00113 #define OS_AIO_LOG 23 /* Asynchronous i/o for the log */ 00114 #define OS_AIO_SYNC 24 /* Asynchronous i/o where the calling thread 00115 will itself wait for the i/o to complete, 00116 doing also the job of the i/o-handler thread; 00117 can be used for any pages, ibuf or non-ibuf. 00118 This is used to save CPU time, as we can do 00119 with fewer thread switches. Plain synchronous 00120 i/o is not as good, because it must serialize 00121 the file seek and read or write, causing a 00122 bottleneck for parallelism. */ 00123 00124 #define OS_AIO_SIMULATED_WAKE_LATER 512 /* This can be ORed to mode 00125 in the call of os_aio(...), 00126 if the caller wants to post several i/o 00127 requests in a batch, and only after that 00128 wake the i/o-handler thread; this has 00129 effect only in simulated aio */ 00130 #define OS_WIN31 1 00131 #define OS_WIN95 2 00132 #define OS_WINNT 3 00133 #define OS_WIN2000 4 00134 00135 extern ulint os_n_file_reads; 00136 extern ulint os_n_file_writes; 00137 extern ulint os_n_fsyncs; 00138 00139 /* File types for directory entry data type */ 00140 00141 enum os_file_type_enum{ 00142 OS_FILE_TYPE_UNKNOWN = 0, 00143 OS_FILE_TYPE_FILE, /* regular file */ 00144 OS_FILE_TYPE_DIR, /* directory */ 00145 OS_FILE_TYPE_LINK /* symbolic link */ 00146 }; 00147 typedef enum os_file_type_enum os_file_type_t; 00148 00149 /* Maximum path string length in bytes when referring to tables with in the 00150 './databasename/tablename.ibd' path format; we can allocate at least 2 buffers 00151 of this size from the thread stack; that is why this should not be made much 00152 bigger than 4000 bytes */ 00153 #define OS_FILE_MAX_PATH 4000 00154 00155 /* Struct used in fetching information of a file in a directory */ 00156 struct os_file_stat_struct{ 00157 char name[OS_FILE_MAX_PATH]; /* path to a file */ 00158 os_file_type_t type; /* file type */ 00159 ib_longlong size; /* file size */ 00160 time_t ctime; /* creation time */ 00161 time_t mtime; /* modification time */ 00162 time_t atime; /* access time */ 00163 }; 00164 typedef struct os_file_stat_struct os_file_stat_t; 00165 00166 #ifdef __WIN__ 00167 typedef HANDLE os_file_dir_t; /* directory stream */ 00168 #else 00169 typedef DIR* os_file_dir_t; /* directory stream */ 00170 #endif 00171 00172 /*************************************************************************** 00173 Gets the operating system version. Currently works only on Windows. */ 00174 00175 ulint 00176 os_get_os_version(void); 00177 /*===================*/ 00178 /* out: OS_WIN95, OS_WIN31, OS_WINNT, or OS_WIN2000 */ 00179 /******************************************************************** 00180 Creates the seek mutexes used in positioned reads and writes. */ 00181 00182 void 00183 os_io_init_simple(void); 00184 /*===================*/ 00185 /*************************************************************************** 00186 Creates a temporary file. This function is like tmpfile(3), but 00187 the temporary file is created in the MySQL temporary directory. 00188 On Netware, this function is like tmpfile(3), because the C run-time 00189 library of Netware does not expose the delete-on-close flag. */ 00190 00191 FILE* 00192 os_file_create_tmpfile(void); 00193 /*========================*/ 00194 /* out: temporary file handle, or NULL on error */ 00195 /*************************************************************************** 00196 The os_file_opendir() function opens a directory stream corresponding to the 00197 directory named by the dirname argument. The directory stream is positioned 00198 at the first entry. In both Unix and Windows we automatically skip the '.' 00199 and '..' items at the start of the directory listing. */ 00200 00201 os_file_dir_t 00202 os_file_opendir( 00203 /*============*/ 00204 /* out: directory stream, NULL if 00205 error */ 00206 const char* dirname, /* in: directory name; it must not 00207 contain a trailing '\' or '/' */ 00208 ibool error_is_fatal);/* in: TRUE if we should treat an 00209 error as a fatal error; if we try to 00210 open symlinks then we do not wish a 00211 fatal error if it happens not to be 00212 a directory */ 00213 /*************************************************************************** 00214 Closes a directory stream. */ 00215 00216 int 00217 os_file_closedir( 00218 /*=============*/ 00219 /* out: 0 if success, -1 if failure */ 00220 os_file_dir_t dir); /* in: directory stream */ 00221 /*************************************************************************** 00222 This function returns information of the next file in the directory. We jump 00223 over the '.' and '..' entries in the directory. */ 00224 00225 int 00226 os_file_readdir_next_file( 00227 /*======================*/ 00228 /* out: 0 if ok, -1 if error, 1 if at the end 00229 of the directory */ 00230 const char* dirname,/* in: directory name or path */ 00231 os_file_dir_t dir, /* in: directory stream */ 00232 os_file_stat_t* info); /* in/out: buffer where the info is returned */ 00233 /********************************************************************* 00234 This function attempts to create a directory named pathname. The new directory 00235 gets default permissions. On Unix, the permissions are (0770 & ~umask). If the 00236 directory exists already, nothing is done and the call succeeds, unless the 00237 fail_if_exists arguments is true. */ 00238 00239 ibool 00240 os_file_create_directory( 00241 /*=====================*/ 00242 /* out: TRUE if call succeeds, 00243 FALSE on error */ 00244 const char* pathname, /* in: directory name as 00245 null-terminated string */ 00246 ibool fail_if_exists);/* in: if TRUE, pre-existing directory 00247 is treated as an error. */ 00248 /******************************************************************** 00249 A simple function to open or create a file. */ 00250 00251 os_file_t 00252 os_file_create_simple( 00253 /*==================*/ 00254 /* out, own: handle to the file, not defined 00255 if error, error number can be retrieved with 00256 os_file_get_last_error */ 00257 const char* name, /* in: name of the file or path as a 00258 null-terminated string */ 00259 ulint create_mode,/* in: OS_FILE_OPEN if an existing file is 00260 opened (if does not exist, error), or 00261 OS_FILE_CREATE if a new file is created 00262 (if exists, error), or 00263 OS_FILE_CREATE_PATH if new file 00264 (if exists, error) and subdirectories along 00265 its path are created (if needed)*/ 00266 ulint access_type,/* in: OS_FILE_READ_ONLY or 00267 OS_FILE_READ_WRITE */ 00268 ibool* success);/* out: TRUE if succeed, FALSE if error */ 00269 /******************************************************************** 00270 A simple function to open or create a file. */ 00271 00272 os_file_t 00273 os_file_create_simple_no_error_handling( 00274 /*====================================*/ 00275 /* out, own: handle to the file, not defined 00276 if error, error number can be retrieved with 00277 os_file_get_last_error */ 00278 const char* name, /* in: name of the file or path as a 00279 null-terminated string */ 00280 ulint create_mode,/* in: OS_FILE_OPEN if an existing file 00281 is opened (if does not exist, error), or 00282 OS_FILE_CREATE if a new file is created 00283 (if exists, error) */ 00284 ulint access_type,/* in: OS_FILE_READ_ONLY, 00285 OS_FILE_READ_WRITE, or 00286 OS_FILE_READ_ALLOW_DELETE; the last option is 00287 used by a backup program reading the file */ 00288 ibool* success);/* out: TRUE if succeed, FALSE if error */ 00289 /******************************************************************** 00290 Opens an existing file or creates a new. */ 00291 00292 os_file_t 00293 os_file_create( 00294 /*===========*/ 00295 /* out, own: handle to the file, not defined 00296 if error, error number can be retrieved with 00297 os_file_get_last_error */ 00298 const char* name, /* in: name of the file or path as a 00299 null-terminated string */ 00300 ulint create_mode,/* in: OS_FILE_OPEN if an existing file 00301 is opened (if does not exist, error), or 00302 OS_FILE_CREATE if a new file is created 00303 (if exists, error), 00304 OS_FILE_OVERWRITE if a new file is created 00305 or an old overwritten; 00306 OS_FILE_OPEN_RAW, if a raw device or disk 00307 partition should be opened */ 00308 ulint purpose,/* in: OS_FILE_AIO, if asynchronous, 00309 non-buffered i/o is desired, 00310 OS_FILE_NORMAL, if any normal file; 00311 NOTE that it also depends on type, os_aio_.. 00312 and srv_.. variables whether we really use 00313 async i/o or unbuffered i/o: look in the 00314 function source code for the exact rules */ 00315 ulint type, /* in: OS_DATA_FILE or OS_LOG_FILE */ 00316 ibool* success);/* out: TRUE if succeed, FALSE if error */ 00317 /*************************************************************************** 00318 Deletes a file. The file has to be closed before calling this. */ 00319 00320 ibool 00321 os_file_delete( 00322 /*===========*/ 00323 /* out: TRUE if success */ 00324 const char* name); /* in: file path as a null-terminated string */ 00325 00326 /*************************************************************************** 00327 Deletes a file if it exists. The file has to be closed before calling this. */ 00328 00329 ibool 00330 os_file_delete_if_exists( 00331 /*=====================*/ 00332 /* out: TRUE if success */ 00333 const char* name); /* in: file path as a null-terminated string */ 00334 /*************************************************************************** 00335 Renames a file (can also move it to another directory). It is safest that the 00336 file is closed before calling this function. */ 00337 00338 ibool 00339 os_file_rename( 00340 /*===========*/ 00341 /* out: TRUE if success */ 00342 const char* oldpath, /* in: old file path as a 00343 null-terminated string */ 00344 const char* newpath); /* in: new file path */ 00345 /*************************************************************************** 00346 Closes a file handle. In case of error, error number can be retrieved with 00347 os_file_get_last_error. */ 00348 00349 ibool 00350 os_file_close( 00351 /*==========*/ 00352 /* out: TRUE if success */ 00353 os_file_t file); /* in, own: handle to a file */ 00354 /*************************************************************************** 00355 Closes a file handle. */ 00356 00357 ibool 00358 os_file_close_no_error_handling( 00359 /*============================*/ 00360 /* out: TRUE if success */ 00361 os_file_t file); /* in, own: handle to a file */ 00362 /*************************************************************************** 00363 Gets a file size. */ 00364 00365 ibool 00366 os_file_get_size( 00367 /*=============*/ 00368 /* out: TRUE if success */ 00369 os_file_t file, /* in: handle to a file */ 00370 ulint* size, /* out: least significant 32 bits of file 00371 size */ 00372 ulint* size_high);/* out: most significant 32 bits of size */ 00373 /*************************************************************************** 00374 Gets file size as a 64-bit integer ib_longlong. */ 00375 00376 ib_longlong 00377 os_file_get_size_as_iblonglong( 00378 /*===========================*/ 00379 /* out: size in bytes, -1 if error */ 00380 os_file_t file); /* in: handle to a file */ 00381 /*************************************************************************** 00382 Write the specified number of zeros to a newly created file. */ 00383 00384 ibool 00385 os_file_set_size( 00386 /*=============*/ 00387 /* out: TRUE if success */ 00388 const char* name, /* in: name of the file or path as a 00389 null-terminated string */ 00390 os_file_t file, /* in: handle to a file */ 00391 ulint size, /* in: least significant 32 bits of file 00392 size */ 00393 ulint size_high);/* in: most significant 32 bits of size */ 00394 /*************************************************************************** 00395 Truncates a file at its current position. */ 00396 00397 ibool 00398 os_file_set_eof( 00399 /*============*/ 00400 /* out: TRUE if success */ 00401 FILE* file); /* in: file to be truncated */ 00402 /*************************************************************************** 00403 Flushes the write buffers of a given file to the disk. */ 00404 00405 ibool 00406 os_file_flush( 00407 /*==========*/ 00408 /* out: TRUE if success */ 00409 os_file_t file); /* in, own: handle to a file */ 00410 /*************************************************************************** 00411 Retrieves the last error number if an error occurs in a file io function. 00412 The number should be retrieved before any other OS calls (because they may 00413 overwrite the error number). If the number is not known to this program, 00414 the OS error number + 100 is returned. */ 00415 00416 ulint 00417 os_file_get_last_error( 00418 /*===================*/ 00419 /* out: error number, or OS error 00420 number + 100 */ 00421 ibool report_all_errors); /* in: TRUE if we want an error message 00422 printed of all errors */ 00423 /*********************************************************************** 00424 Requests a synchronous read operation. */ 00425 00426 ibool 00427 os_file_read( 00428 /*=========*/ 00429 /* out: TRUE if request was 00430 successful, FALSE if fail */ 00431 os_file_t file, /* in: handle to a file */ 00432 void* buf, /* in: buffer where to read */ 00433 ulint offset, /* in: least significant 32 bits of file 00434 offset where to read */ 00435 ulint offset_high,/* in: most significant 32 bits of 00436 offset */ 00437 ulint n); /* in: number of bytes to read */ 00438 /*********************************************************************** 00439 Rewind file to its start, read at most size - 1 bytes from it to str, and 00440 NUL-terminate str. All errors are silently ignored. This function is 00441 mostly meant to be used with temporary files. */ 00442 00443 void 00444 os_file_read_string( 00445 /*================*/ 00446 FILE* file, /* in: file to read from */ 00447 char* str, /* in: buffer where to read */ 00448 ulint size); /* in: size of buffer */ 00449 /*********************************************************************** 00450 Requests a synchronous positioned read operation. This function does not do 00451 any error handling. In case of error it returns FALSE. */ 00452 00453 ibool 00454 os_file_read_no_error_handling( 00455 /*===========================*/ 00456 /* out: TRUE if request was 00457 successful, FALSE if fail */ 00458 os_file_t file, /* in: handle to a file */ 00459 void* buf, /* in: buffer where to read */ 00460 ulint offset, /* in: least significant 32 bits of file 00461 offset where to read */ 00462 ulint offset_high,/* in: most significant 32 bits of 00463 offset */ 00464 ulint n); /* in: number of bytes to read */ 00465 00466 /*********************************************************************** 00467 Requests a synchronous write operation. */ 00468 00469 ibool 00470 os_file_write( 00471 /*==========*/ 00472 /* out: TRUE if request was 00473 successful, FALSE if fail */ 00474 const char* name, /* in: name of the file or path as a 00475 null-terminated string */ 00476 os_file_t file, /* in: handle to a file */ 00477 const void* buf, /* in: buffer from which to write */ 00478 ulint offset, /* in: least significant 32 bits of file 00479 offset where to write */ 00480 ulint offset_high,/* in: most significant 32 bits of 00481 offset */ 00482 ulint n); /* in: number of bytes to write */ 00483 /*********************************************************************** 00484 Check the existence and type of the given file. */ 00485 00486 ibool 00487 os_file_status( 00488 /*===========*/ 00489 /* out: TRUE if call succeeded */ 00490 const char* path, /* in: pathname of the file */ 00491 ibool* exists, /* out: TRUE if file exists */ 00492 os_file_type_t* type); /* out: type of the file (if it exists) */ 00493 /******************************************************************** 00494 The function os_file_dirname returns a directory component of a 00495 null-terminated pathname string. In the usual case, dirname returns 00496 the string up to, but not including, the final '/', and basename 00497 is the component following the final '/'. Trailing '/' charac 00498 ters are not counted as part of the pathname. 00499 00500 If path does not contain a slash, dirname returns the string ".". 00501 00502 Concatenating the string returned by dirname, a "/", and the basename 00503 yields a complete pathname. 00504 00505 The return value is a copy of the directory component of the pathname. 00506 The copy is allocated from heap. It is the caller responsibility 00507 to free it after it is no longer needed. 00508 00509 The following list of examples (taken from SUSv2) shows the strings 00510 returned by dirname and basename for different paths: 00511 00512 path dirname basename 00513 "/usr/lib" "/usr" "lib" 00514 "/usr/" "/" "usr" 00515 "usr" "." "usr" 00516 "/" "/" "/" 00517 "." "." "." 00518 ".." "." ".." 00519 */ 00520 00521 char* 00522 os_file_dirname( 00523 /*============*/ 00524 /* out, own: directory component of the 00525 pathname */ 00526 const char* path); /* in: pathname */ 00527 /******************************************************************** 00528 Creates all missing subdirectories along the given path. */ 00529 00530 ibool 00531 os_file_create_subdirs_if_needed( 00532 /*=============================*/ 00533 /* out: TRUE if call succeeded 00534 FALSE otherwise */ 00535 const char* path); /* in: path name */ 00536 /**************************************************************************** 00537 Initializes the asynchronous io system. Creates separate aio array for 00538 non-ibuf read and write, a third aio array for the ibuf i/o, with just one 00539 segment, two aio arrays for log reads and writes with one segment, and a 00540 synchronous aio array of the specified size. The combined number of segments 00541 in the three first aio arrays is the parameter n_segments given to the 00542 function. The caller must create an i/o handler thread for each segment in 00543 the four first arrays, but not for the sync aio array. */ 00544 00545 void 00546 os_aio_init( 00547 /*========*/ 00548 ulint n, /* in: maximum number of pending aio operations 00549 allowed; n must be divisible by n_segments */ 00550 ulint n_segments, /* in: combined number of segments in the four 00551 first aio arrays; must be >= 4 */ 00552 ulint n_slots_sync); /* in: number of slots in the sync aio array */ 00553 /*********************************************************************** 00554 Requests an asynchronous i/o operation. */ 00555 00556 ibool 00557 os_aio( 00558 /*===*/ 00559 /* out: TRUE if request was queued 00560 successfully, FALSE if fail */ 00561 ulint type, /* in: OS_FILE_READ or OS_FILE_WRITE */ 00562 ulint mode, /* in: OS_AIO_NORMAL, ..., possibly ORed 00563 to OS_AIO_SIMULATED_WAKE_LATER: the 00564 last flag advises this function not to wake 00565 i/o-handler threads, but the caller will 00566 do the waking explicitly later, in this 00567 way the caller can post several requests in 00568 a batch; NOTE that the batch must not be 00569 so big that it exhausts the slots in aio 00570 arrays! NOTE that a simulated batch 00571 may introduce hidden chances of deadlocks, 00572 because i/os are not actually handled until 00573 all have been posted: use with great 00574 caution! */ 00575 const char* name, /* in: name of the file or path as a 00576 null-terminated string */ 00577 os_file_t file, /* in: handle to a file */ 00578 void* buf, /* in: buffer where to read or from which 00579 to write */ 00580 ulint offset, /* in: least significant 32 bits of file 00581 offset where to read or write */ 00582 ulint offset_high, /* in: most significant 32 bits of 00583 offset */ 00584 ulint n, /* in: number of bytes to read or write */ 00585 fil_node_t* message1,/* in: messages for the aio handler (these 00586 can be used to identify a completed aio 00587 operation); if mode is OS_AIO_SYNC, these 00588 are ignored */ 00589 void* message2); 00590 /**************************************************************************** 00591 Wakes up all async i/o threads so that they know to exit themselves in 00592 shutdown. */ 00593 00594 void 00595 os_aio_wake_all_threads_at_shutdown(void); 00596 /*=====================================*/ 00597 /**************************************************************************** 00598 Waits until there are no pending writes in os_aio_write_array. There can 00599 be other, synchronous, pending writes. */ 00600 00601 void 00602 os_aio_wait_until_no_pending_writes(void); 00603 /*=====================================*/ 00604 /************************************************************************** 00605 Wakes up simulated aio i/o-handler threads if they have something to do. */ 00606 00607 void 00608 os_aio_simulated_wake_handler_threads(void); 00609 /*=======================================*/ 00610 /************************************************************************** 00611 This function can be called if one wants to post a batch of reads and 00612 prefers an i/o-handler thread to handle them all at once later. You must 00613 call os_aio_simulated_wake_handler_threads later to ensure the threads 00614 are not left sleeping! */ 00615 00616 void 00617 os_aio_simulated_put_read_threads_to_sleep(void); 00618 /*============================================*/ 00619 00620 #ifdef WIN_ASYNC_IO 00621 /************************************************************************** 00622 This function is only used in Windows asynchronous i/o. 00623 Waits for an aio operation to complete. This function is used to wait the 00624 for completed requests. The aio array of pending requests is divided 00625 into segments. The thread specifies which segment or slot it wants to wait 00626 for. NOTE: this function will also take care of freeing the aio slot, 00627 therefore no other thread is allowed to do the freeing! */ 00628 00629 ibool 00630 os_aio_windows_handle( 00631 /*==================*/ 00632 /* out: TRUE if the aio operation succeeded */ 00633 ulint segment, /* in: the number of the segment in the aio 00634 arrays to wait for; segment 0 is the ibuf 00635 i/o thread, segment 1 the log i/o thread, 00636 then follow the non-ibuf read threads, and as 00637 the last are the non-ibuf write threads; if 00638 this is ULINT_UNDEFINED, then it means that 00639 sync aio is used, and this parameter is 00640 ignored */ 00641 ulint pos, /* this parameter is used only in sync aio: 00642 wait for the aio slot at this position */ 00643 fil_node_t**message1, /* out: the messages passed with the aio 00644 request; note that also in the case where 00645 the aio operation failed, these output 00646 parameters are valid and can be used to 00647 restart the operation, for example */ 00648 void** message2, 00649 ulint* type); /* out: OS_FILE_WRITE or ..._READ */ 00650 #endif 00651 00652 /* Currently we do not use Posix async i/o */ 00653 #ifdef POSIX_ASYNC_IO 00654 /************************************************************************** 00655 This function is only used in Posix asynchronous i/o. Waits for an aio 00656 operation to complete. */ 00657 00658 ibool 00659 os_aio_posix_handle( 00660 /*================*/ 00661 /* out: TRUE if the aio operation succeeded */ 00662 ulint array_no, /* in: array number 0 - 3 */ 00663 fil_node_t**message1, /* out: the messages passed with the aio 00664 request; note that also in the case where 00665 the aio operation failed, these output 00666 parameters are valid and can be used to 00667 restart the operation, for example */ 00668 void** message2); 00669 #endif 00670 /************************************************************************** 00671 Does simulated aio. This function should be called by an i/o-handler 00672 thread. */ 00673 00674 ibool 00675 os_aio_simulated_handle( 00676 /*====================*/ 00677 /* out: TRUE if the aio operation succeeded */ 00678 ulint segment, /* in: the number of the segment in the aio 00679 arrays to wait for; segment 0 is the ibuf 00680 i/o thread, segment 1 the log i/o thread, 00681 then follow the non-ibuf read threads, and as 00682 the last are the non-ibuf write threads */ 00683 fil_node_t**message1, /* out: the messages passed with the aio 00684 request; note that also in the case where 00685 the aio operation failed, these output 00686 parameters are valid and can be used to 00687 restart the operation, for example */ 00688 void** message2, 00689 ulint* type); /* out: OS_FILE_WRITE or ..._READ */ 00690 /************************************************************************** 00691 Validates the consistency of the aio system. */ 00692 00693 ibool 00694 os_aio_validate(void); 00695 /*=================*/ 00696 /* out: TRUE if ok */ 00697 /************************************************************************** 00698 Prints info of the aio arrays. */ 00699 00700 void 00701 os_aio_print( 00702 /*=========*/ 00703 FILE* file); /* in: file where to print */ 00704 /************************************************************************** 00705 Refreshes the statistics used to print per-second averages. */ 00706 00707 void 00708 os_aio_refresh_stats(void); 00709 /*======================*/ 00710 00711 #ifdef UNIV_DEBUG 00712 /************************************************************************** 00713 Checks that all slots in the system have been freed, that is, there are 00714 no pending io operations. */ 00715 00716 ibool 00717 os_aio_all_slots_free(void); 00718 /*=======================*/ 00719 #endif /* UNIV_DEBUG */ 00720 00721 /*********************************************************************** 00722 This function returns information about the specified file */ 00723 ibool 00724 os_file_get_status( 00725 /*===============*/ 00726 /* out: TRUE if stat information found */ 00727 const char* path, /* in: pathname of the file */ 00728 os_file_stat_t* stat_info); /* information of a file in a directory */ 00729 00730 #endif
1.4.7

