You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

735 lines
26 KiB

20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
Merge r102 from hotbackup/trunk. Corrected some comments. os_file_create_tmpfile(): Remove the implementation from InnoDB Hot Backup. In InnoDB Hot Backup builds, do not define dict_casedn_str(), which is invoked in fil_load_single_table_tablespace() on Windows. This function depends on innobase_casedn_str() and my_casedn_str(). Define btr_check_node_ptr() and data_error only #ifdef UNIV_DEBUG. They are only being used in ut_ad() assertions. Replace the occurrences of the type uint with ulint, because InnoDB Hot Backup does not define any uint data type. Disable lock_validate() in InnoDB Hot Backup builds. Disable some unused static variables of srv0srv.c in InnoDB Hot Backup builds. Disable some srv_table_...() functions in InnoDB Hot Backup builds. Disable some unused static variables in srv0start.c in InnoDB Hot Backup builds. Disable io_handler_thread() in InnoDB Hot Backup builds. Disable srv_calc_low32() and srv_calc_high32() in InnoDB Hot Backup builds to avoid warnings about unused functions. In fil_node_open_file(), avoid bogus assertions in InnoDB Hot Backup builds. In fil_load_single_table_tablespace(), remove the call to dict_casedn_str(), as it depends on MySQL code. Copy the code of recv_reset_log_files_for_backup() from InnoDB Hot Backup. Disable innobase_mysql_cmp(), cmp_whole_field(), cmp_data_data_slow(), cmp_dtuple_rec_with_match() and cmp_rec_rec_with_match() in InnoDB Hot Backup builds, as they depend on MySQL code. Adapt dtype_set_mblen() and dtype_get_fixed_size() for InnoDB Hot Backup builds, assuming that they will only be called on system tables, which do not contain multi-byte characters. Disable the static functions row_ins_set_exclusive_rec_lock() and row_ins_dupl_error_with_rec() in InnoDB Hot Backup builds to avoid warnings about unused functions. In row_sel_field_store_in_mysql_format(), disable some UTF-8 related assertions #ifndef UNIV_RELEASE_NOT_YET_STABLE.
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
  1. /******************************************************
  2. The interface to the operating system file io
  3. (c) 1995 Innobase Oy
  4. Created 10/21/1995 Heikki Tuuri
  5. *******************************************************/
  6. #ifndef os0file_h
  7. #define os0file_h
  8. #include "univ.i"
  9. #ifndef __WIN__
  10. #include <dirent.h>
  11. #include <sys/stat.h>
  12. #include <time.h>
  13. #endif
  14. typedef struct fil_node_struct fil_node_t;
  15. #ifdef UNIV_DO_FLUSH
  16. extern ibool os_do_not_call_flush_at_each_write;
  17. #endif /* UNIV_DO_FLUSH */
  18. extern ibool os_has_said_disk_full;
  19. extern ibool os_aio_print_debug;
  20. extern ulint os_file_n_pending_preads;
  21. extern ulint os_file_n_pending_pwrites;
  22. extern ulint os_n_pending_reads;
  23. extern ulint os_n_pending_writes;
  24. #ifdef __WIN__
  25. /* We define always WIN_ASYNC_IO, and check at run-time whether
  26. the OS actually supports it: Win 95 does not, NT does. */
  27. #define WIN_ASYNC_IO
  28. #define UNIV_NON_BUFFERED_IO
  29. #endif
  30. #ifdef __WIN__
  31. #define os_file_t HANDLE
  32. #else
  33. typedef int os_file_t;
  34. #endif
  35. extern ulint os_innodb_umask;
  36. /* If this flag is TRUE, then we will use the native aio of the
  37. OS (provided we compiled Innobase with it in), otherwise we will
  38. use simulated aio we build below with threads */
  39. extern ibool os_aio_use_native_aio;
  40. #define OS_FILE_SECTOR_SIZE 512
  41. /* The next value should be smaller or equal to the smallest sector size used
  42. on any disk. A log block is required to be a portion of disk which is written
  43. so that if the start and the end of a block get written to disk, then the
  44. whole block gets written. This should be true even in most cases of a crash:
  45. if this fails for a log block, then it is equivalent to a media failure in the
  46. log. */
  47. #define OS_FILE_LOG_BLOCK_SIZE 512
  48. /* Options for file_create */
  49. #define OS_FILE_OPEN 51
  50. #define OS_FILE_CREATE 52
  51. #define OS_FILE_OVERWRITE 53
  52. #define OS_FILE_OPEN_RAW 54
  53. #define OS_FILE_CREATE_PATH 55
  54. #define OS_FILE_OPEN_RETRY 56 /* for os_file_create() on
  55. the first ibdata file */
  56. #define OS_FILE_READ_ONLY 333
  57. #define OS_FILE_READ_WRITE 444
  58. #define OS_FILE_READ_ALLOW_DELETE 555 /* for ibbackup */
  59. /* Options for file_create */
  60. #define OS_FILE_AIO 61
  61. #define OS_FILE_NORMAL 62
  62. /* Types for file create */
  63. #define OS_DATA_FILE 100
  64. #define OS_LOG_FILE 101
  65. /* Error codes from os_file_get_last_error */
  66. #define OS_FILE_NOT_FOUND 71
  67. #define OS_FILE_DISK_FULL 72
  68. #define OS_FILE_ALREADY_EXISTS 73
  69. #define OS_FILE_PATH_ERROR 74
  70. #define OS_FILE_AIO_RESOURCES_RESERVED 75 /* wait for OS aio resources
  71. to become available again */
  72. #define OS_FILE_SHARING_VIOLATION 76
  73. #define OS_FILE_ERROR_NOT_SPECIFIED 77
  74. /* 78 is used in the plugin */
  75. #define OS_FILE_OPERATION_ABORTED 79
  76. /* Types for aio operations */
  77. #define OS_FILE_READ 10
  78. #define OS_FILE_WRITE 11
  79. #define OS_FILE_LOG 256 /* This can be ORed to type */
  80. #define OS_AIO_N_PENDING_IOS_PER_THREAD 32 /* Win NT does not allow more
  81. than 64 */
  82. /* Modes for aio operations */
  83. #define OS_AIO_NORMAL 21 /* Normal asynchronous i/o not for ibuf
  84. pages or ibuf bitmap pages */
  85. #define OS_AIO_IBUF 22 /* Asynchronous i/o for ibuf pages or ibuf
  86. bitmap pages */
  87. #define OS_AIO_LOG 23 /* Asynchronous i/o for the log */
  88. #define OS_AIO_SYNC 24 /* Asynchronous i/o where the calling thread
  89. will itself wait for the i/o to complete,
  90. doing also the job of the i/o-handler thread;
  91. can be used for any pages, ibuf or non-ibuf.
  92. This is used to save CPU time, as we can do
  93. with fewer thread switches. Plain synchronous
  94. i/o is not as good, because it must serialize
  95. the file seek and read or write, causing a
  96. bottleneck for parallelism. */
  97. #define OS_AIO_SIMULATED_WAKE_LATER 512 /* This can be ORed to mode
  98. in the call of os_aio(...),
  99. if the caller wants to post several i/o
  100. requests in a batch, and only after that
  101. wake the i/o-handler thread; this has
  102. effect only in simulated aio */
  103. #define OS_WIN31 1
  104. #define OS_WIN95 2
  105. #define OS_WINNT 3
  106. #define OS_WIN2000 4
  107. extern ulint os_n_file_reads;
  108. extern ulint os_n_file_writes;
  109. extern ulint os_n_fsyncs;
  110. /* File types for directory entry data type */
  111. enum os_file_type_enum{
  112. OS_FILE_TYPE_UNKNOWN = 0,
  113. OS_FILE_TYPE_FILE, /* regular file */
  114. OS_FILE_TYPE_DIR, /* directory */
  115. OS_FILE_TYPE_LINK /* symbolic link */
  116. };
  117. typedef enum os_file_type_enum os_file_type_t;
  118. /* Maximum path string length in bytes when referring to tables with in the
  119. './databasename/tablename.ibd' path format; we can allocate at least 2 buffers
  120. of this size from the thread stack; that is why this should not be made much
  121. bigger than 4000 bytes */
  122. #define OS_FILE_MAX_PATH 4000
  123. /* Struct used in fetching information of a file in a directory */
  124. struct os_file_stat_struct{
  125. char name[OS_FILE_MAX_PATH]; /* path to a file */
  126. os_file_type_t type; /* file type */
  127. ib_longlong size; /* file size */
  128. time_t ctime; /* creation time */
  129. time_t mtime; /* modification time */
  130. time_t atime; /* access time */
  131. };
  132. typedef struct os_file_stat_struct os_file_stat_t;
  133. #ifdef __WIN__
  134. typedef HANDLE os_file_dir_t; /* directory stream */
  135. #else
  136. typedef DIR* os_file_dir_t; /* directory stream */
  137. #endif
  138. /***************************************************************************
  139. Gets the operating system version. Currently works only on Windows. */
  140. ulint
  141. os_get_os_version(void);
  142. /*===================*/
  143. /* out: OS_WIN95, OS_WIN31, OS_WINNT, or OS_WIN2000 */
  144. /********************************************************************
  145. Creates the seek mutexes used in positioned reads and writes. */
  146. void
  147. os_io_init_simple(void);
  148. /*===================*/
  149. /***************************************************************************
  150. Creates a temporary file. This function is like tmpfile(3), but
  151. the temporary file is created in the MySQL temporary directory.
  152. On Netware, this function is like tmpfile(3), because the C run-time
  153. library of Netware does not expose the delete-on-close flag. */
  154. FILE*
  155. os_file_create_tmpfile(void);
  156. /*========================*/
  157. /* out: temporary file handle, or NULL on error */
  158. /***************************************************************************
  159. The os_file_opendir() function opens a directory stream corresponding to the
  160. directory named by the dirname argument. The directory stream is positioned
  161. at the first entry. In both Unix and Windows we automatically skip the '.'
  162. and '..' items at the start of the directory listing. */
  163. os_file_dir_t
  164. os_file_opendir(
  165. /*============*/
  166. /* out: directory stream, NULL if
  167. error */
  168. const char* dirname, /* in: directory name; it must not
  169. contain a trailing '\' or '/' */
  170. ibool error_is_fatal);/* in: TRUE if we should treat an
  171. error as a fatal error; if we try to
  172. open symlinks then we do not wish a
  173. fatal error if it happens not to be
  174. a directory */
  175. /***************************************************************************
  176. Closes a directory stream. */
  177. int
  178. os_file_closedir(
  179. /*=============*/
  180. /* out: 0 if success, -1 if failure */
  181. os_file_dir_t dir); /* in: directory stream */
  182. /***************************************************************************
  183. This function returns information of the next file in the directory. We jump
  184. over the '.' and '..' entries in the directory. */
  185. int
  186. os_file_readdir_next_file(
  187. /*======================*/
  188. /* out: 0 if ok, -1 if error, 1 if at the end
  189. of the directory */
  190. const char* dirname,/* in: directory name or path */
  191. os_file_dir_t dir, /* in: directory stream */
  192. os_file_stat_t* info); /* in/out: buffer where the info is returned */
  193. /*********************************************************************
  194. This function attempts to create a directory named pathname. The new directory
  195. gets default permissions. On Unix, the permissions are (0770 & ~umask). If the
  196. directory exists already, nothing is done and the call succeeds, unless the
  197. fail_if_exists arguments is true. */
  198. ibool
  199. os_file_create_directory(
  200. /*=====================*/
  201. /* out: TRUE if call succeeds,
  202. FALSE on error */
  203. const char* pathname, /* in: directory name as
  204. null-terminated string */
  205. ibool fail_if_exists);/* in: if TRUE, pre-existing directory
  206. is treated as an error. */
  207. /********************************************************************
  208. A simple function to open or create a file. */
  209. os_file_t
  210. os_file_create_simple(
  211. /*==================*/
  212. /* out, own: handle to the file, not defined
  213. if error, error number can be retrieved with
  214. os_file_get_last_error */
  215. const char* name, /* in: name of the file or path as a
  216. null-terminated string */
  217. ulint create_mode,/* in: OS_FILE_OPEN if an existing file is
  218. opened (if does not exist, error), or
  219. OS_FILE_CREATE if a new file is created
  220. (if exists, error), or
  221. OS_FILE_CREATE_PATH if new file
  222. (if exists, error) and subdirectories along
  223. its path are created (if needed)*/
  224. ulint access_type,/* in: OS_FILE_READ_ONLY or
  225. OS_FILE_READ_WRITE */
  226. ibool* success);/* out: TRUE if succeed, FALSE if error */
  227. /********************************************************************
  228. A simple function to open or create a file. */
  229. os_file_t
  230. os_file_create_simple_no_error_handling(
  231. /*====================================*/
  232. /* out, own: handle to the file, not defined
  233. if error, error number can be retrieved with
  234. os_file_get_last_error */
  235. const char* name, /* in: name of the file or path as a
  236. null-terminated string */
  237. ulint create_mode,/* in: OS_FILE_OPEN if an existing file
  238. is opened (if does not exist, error), or
  239. OS_FILE_CREATE if a new file is created
  240. (if exists, error) */
  241. ulint access_type,/* in: OS_FILE_READ_ONLY,
  242. OS_FILE_READ_WRITE, or
  243. OS_FILE_READ_ALLOW_DELETE; the last option is
  244. used by a backup program reading the file */
  245. ibool* success);/* out: TRUE if succeed, FALSE if error */
  246. /********************************************************************
  247. Opens an existing file or creates a new. */
  248. os_file_t
  249. os_file_create(
  250. /*===========*/
  251. /* out, own: handle to the file, not defined
  252. if error, error number can be retrieved with
  253. os_file_get_last_error */
  254. const char* name, /* in: name of the file or path as a
  255. null-terminated string */
  256. ulint create_mode,/* in: OS_FILE_OPEN if an existing file
  257. is opened (if does not exist, error), or
  258. OS_FILE_CREATE if a new file is created
  259. (if exists, error),
  260. OS_FILE_OVERWRITE if a new file is created
  261. or an old overwritten;
  262. OS_FILE_OPEN_RAW, if a raw device or disk
  263. partition should be opened */
  264. ulint purpose,/* in: OS_FILE_AIO, if asynchronous,
  265. non-buffered i/o is desired,
  266. OS_FILE_NORMAL, if any normal file;
  267. NOTE that it also depends on type, os_aio_..
  268. and srv_.. variables whether we really use
  269. async i/o or unbuffered i/o: look in the
  270. function source code for the exact rules */
  271. ulint type, /* in: OS_DATA_FILE or OS_LOG_FILE */
  272. ibool* success);/* out: TRUE if succeed, FALSE if error */
  273. /***************************************************************************
  274. Deletes a file. The file has to be closed before calling this. */
  275. ibool
  276. os_file_delete(
  277. /*===========*/
  278. /* out: TRUE if success */
  279. const char* name); /* in: file path as a null-terminated string */
  280. /***************************************************************************
  281. Deletes a file if it exists. The file has to be closed before calling this. */
  282. ibool
  283. os_file_delete_if_exists(
  284. /*=====================*/
  285. /* out: TRUE if success */
  286. const char* name); /* in: file path as a null-terminated string */
  287. /***************************************************************************
  288. Renames a file (can also move it to another directory). It is safest that the
  289. file is closed before calling this function. */
  290. ibool
  291. os_file_rename(
  292. /*===========*/
  293. /* out: TRUE if success */
  294. const char* oldpath, /* in: old file path as a
  295. null-terminated string */
  296. const char* newpath); /* in: new file path */
  297. /***************************************************************************
  298. Closes a file handle. In case of error, error number can be retrieved with
  299. os_file_get_last_error. */
  300. ibool
  301. os_file_close(
  302. /*==========*/
  303. /* out: TRUE if success */
  304. os_file_t file); /* in, own: handle to a file */
  305. /***************************************************************************
  306. Closes a file handle. */
  307. ibool
  308. os_file_close_no_error_handling(
  309. /*============================*/
  310. /* out: TRUE if success */
  311. os_file_t file); /* in, own: handle to a file */
  312. /***************************************************************************
  313. Gets a file size. */
  314. ibool
  315. os_file_get_size(
  316. /*=============*/
  317. /* out: TRUE if success */
  318. os_file_t file, /* in: handle to a file */
  319. ulint* size, /* out: least significant 32 bits of file
  320. size */
  321. ulint* size_high);/* out: most significant 32 bits of size */
  322. /***************************************************************************
  323. Gets file size as a 64-bit integer ib_longlong. */
  324. ib_longlong
  325. os_file_get_size_as_iblonglong(
  326. /*===========================*/
  327. /* out: size in bytes, -1 if error */
  328. os_file_t file); /* in: handle to a file */
  329. /***************************************************************************
  330. Write the specified number of zeros to a newly created file. */
  331. ibool
  332. os_file_set_size(
  333. /*=============*/
  334. /* out: TRUE if success */
  335. const char* name, /* in: name of the file or path as a
  336. null-terminated string */
  337. os_file_t file, /* in: handle to a file */
  338. ulint size, /* in: least significant 32 bits of file
  339. size */
  340. ulint size_high);/* in: most significant 32 bits of size */
  341. /***************************************************************************
  342. Truncates a file at its current position. */
  343. ibool
  344. os_file_set_eof(
  345. /*============*/
  346. /* out: TRUE if success */
  347. FILE* file); /* in: file to be truncated */
  348. /***************************************************************************
  349. Flushes the write buffers of a given file to the disk. */
  350. ibool
  351. os_file_flush(
  352. /*==========*/
  353. /* out: TRUE if success */
  354. os_file_t file); /* in, own: handle to a file */
  355. /***************************************************************************
  356. Retrieves the last error number if an error occurs in a file io function.
  357. The number should be retrieved before any other OS calls (because they may
  358. overwrite the error number). If the number is not known to this program,
  359. the OS error number + 100 is returned. */
  360. ulint
  361. os_file_get_last_error(
  362. /*===================*/
  363. /* out: error number, or OS error
  364. number + 100 */
  365. ibool report_all_errors); /* in: TRUE if we want an error message
  366. printed of all errors */
  367. /***********************************************************************
  368. Requests a synchronous read operation. */
  369. ibool
  370. os_file_read(
  371. /*=========*/
  372. /* out: TRUE if request was
  373. successful, FALSE if fail */
  374. os_file_t file, /* in: handle to a file */
  375. void* buf, /* in: buffer where to read */
  376. ulint offset, /* in: least significant 32 bits of file
  377. offset where to read */
  378. ulint offset_high,/* in: most significant 32 bits of
  379. offset */
  380. ulint n); /* in: number of bytes to read */
  381. /***********************************************************************
  382. Rewind file to its start, read at most size - 1 bytes from it to str, and
  383. NUL-terminate str. All errors are silently ignored. This function is
  384. mostly meant to be used with temporary files. */
  385. void
  386. os_file_read_string(
  387. /*================*/
  388. FILE* file, /* in: file to read from */
  389. char* str, /* in: buffer where to read */
  390. ulint size); /* in: size of buffer */
  391. /***********************************************************************
  392. Requests a synchronous positioned read operation. This function does not do
  393. any error handling. In case of error it returns FALSE. */
  394. ibool
  395. os_file_read_no_error_handling(
  396. /*===========================*/
  397. /* out: TRUE if request was
  398. successful, FALSE if fail */
  399. os_file_t file, /* in: handle to a file */
  400. void* buf, /* in: buffer where to read */
  401. ulint offset, /* in: least significant 32 bits of file
  402. offset where to read */
  403. ulint offset_high,/* in: most significant 32 bits of
  404. offset */
  405. ulint n); /* in: number of bytes to read */
  406. /***********************************************************************
  407. Requests a synchronous write operation. */
  408. ibool
  409. os_file_write(
  410. /*==========*/
  411. /* out: TRUE if request was
  412. successful, FALSE if fail */
  413. const char* name, /* in: name of the file or path as a
  414. null-terminated string */
  415. os_file_t file, /* in: handle to a file */
  416. const void* buf, /* in: buffer from which to write */
  417. ulint offset, /* in: least significant 32 bits of file
  418. offset where to write */
  419. ulint offset_high,/* in: most significant 32 bits of
  420. offset */
  421. ulint n); /* in: number of bytes to write */
  422. /***********************************************************************
  423. Check the existence and type of the given file. */
  424. ibool
  425. os_file_status(
  426. /*===========*/
  427. /* out: TRUE if call succeeded */
  428. const char* path, /* in: pathname of the file */
  429. ibool* exists, /* out: TRUE if file exists */
  430. os_file_type_t* type); /* out: type of the file (if it exists) */
  431. /********************************************************************
  432. The function os_file_dirname returns a directory component of a
  433. null-terminated pathname string. In the usual case, dirname returns
  434. the string up to, but not including, the final '/', and basename
  435. is the component following the final '/'. Trailing '/' charac
  436. ters are not counted as part of the pathname.
  437. If path does not contain a slash, dirname returns the string ".".
  438. Concatenating the string returned by dirname, a "/", and the basename
  439. yields a complete pathname.
  440. The return value is a copy of the directory component of the pathname.
  441. The copy is allocated from heap. It is the caller responsibility
  442. to free it after it is no longer needed.
  443. The following list of examples (taken from SUSv2) shows the strings
  444. returned by dirname and basename for different paths:
  445. path dirname basename
  446. "/usr/lib" "/usr" "lib"
  447. "/usr/" "/" "usr"
  448. "usr" "." "usr"
  449. "/" "/" "/"
  450. "." "." "."
  451. ".." "." ".."
  452. */
  453. char*
  454. os_file_dirname(
  455. /*============*/
  456. /* out, own: directory component of the
  457. pathname */
  458. const char* path); /* in: pathname */
  459. /********************************************************************
  460. Creates all missing subdirectories along the given path. */
  461. ibool
  462. os_file_create_subdirs_if_needed(
  463. /*=============================*/
  464. /* out: TRUE if call succeeded
  465. FALSE otherwise */
  466. const char* path); /* in: path name */
  467. /****************************************************************************
  468. Initializes the asynchronous io system. Creates separate aio array for
  469. non-ibuf read and write, a third aio array for the ibuf i/o, with just one
  470. segment, two aio arrays for log reads and writes with one segment, and a
  471. synchronous aio array of the specified size. The combined number of segments
  472. in the three first aio arrays is the parameter n_segments given to the
  473. function. The caller must create an i/o handler thread for each segment in
  474. the four first arrays, but not for the sync aio array. */
  475. void
  476. os_aio_init(
  477. /*========*/
  478. ulint n, /* in: maximum number of pending aio operations
  479. allowed; n must be divisible by n_segments */
  480. ulint n_segments, /* in: combined number of segments in the four
  481. first aio arrays; must be >= 4 */
  482. ulint n_slots_sync); /* in: number of slots in the sync aio array */
  483. /***********************************************************************
  484. Requests an asynchronous i/o operation. */
  485. ibool
  486. os_aio(
  487. /*===*/
  488. /* out: TRUE if request was queued
  489. successfully, FALSE if fail */
  490. ulint type, /* in: OS_FILE_READ or OS_FILE_WRITE */
  491. ulint mode, /* in: OS_AIO_NORMAL, ..., possibly ORed
  492. to OS_AIO_SIMULATED_WAKE_LATER: the
  493. last flag advises this function not to wake
  494. i/o-handler threads, but the caller will
  495. do the waking explicitly later, in this
  496. way the caller can post several requests in
  497. a batch; NOTE that the batch must not be
  498. so big that it exhausts the slots in aio
  499. arrays! NOTE that a simulated batch
  500. may introduce hidden chances of deadlocks,
  501. because i/os are not actually handled until
  502. all have been posted: use with great
  503. caution! */
  504. const char* name, /* in: name of the file or path as a
  505. null-terminated string */
  506. os_file_t file, /* in: handle to a file */
  507. void* buf, /* in: buffer where to read or from which
  508. to write */
  509. ulint offset, /* in: least significant 32 bits of file
  510. offset where to read or write */
  511. ulint offset_high, /* in: most significant 32 bits of
  512. offset */
  513. ulint n, /* in: number of bytes to read or write */
  514. fil_node_t* message1,/* in: messages for the aio handler (these
  515. can be used to identify a completed aio
  516. operation); if mode is OS_AIO_SYNC, these
  517. are ignored */
  518. void* message2);
  519. /****************************************************************************
  520. Wakes up all async i/o threads so that they know to exit themselves in
  521. shutdown. */
  522. void
  523. os_aio_wake_all_threads_at_shutdown(void);
  524. /*=====================================*/
  525. /****************************************************************************
  526. Waits until there are no pending writes in os_aio_write_array. There can
  527. be other, synchronous, pending writes. */
  528. void
  529. os_aio_wait_until_no_pending_writes(void);
  530. /*=====================================*/
  531. /**************************************************************************
  532. Wakes up simulated aio i/o-handler threads if they have something to do. */
  533. void
  534. os_aio_simulated_wake_handler_threads(void);
  535. /*=======================================*/
  536. /**************************************************************************
  537. This function can be called if one wants to post a batch of reads and
  538. prefers an i/o-handler thread to handle them all at once later. You must
  539. call os_aio_simulated_wake_handler_threads later to ensure the threads
  540. are not left sleeping! */
  541. void
  542. os_aio_simulated_put_read_threads_to_sleep(void);
  543. /*============================================*/
  544. #ifdef WIN_ASYNC_IO
  545. /**************************************************************************
  546. This function is only used in Windows asynchronous i/o.
  547. Waits for an aio operation to complete. This function is used to wait the
  548. for completed requests. The aio array of pending requests is divided
  549. into segments. The thread specifies which segment or slot it wants to wait
  550. for. NOTE: this function will also take care of freeing the aio slot,
  551. therefore no other thread is allowed to do the freeing! */
  552. ibool
  553. os_aio_windows_handle(
  554. /*==================*/
  555. /* out: TRUE if the aio operation succeeded */
  556. ulint segment, /* in: the number of the segment in the aio
  557. arrays to wait for; segment 0 is the ibuf
  558. i/o thread, segment 1 the log i/o thread,
  559. then follow the non-ibuf read threads, and as
  560. the last are the non-ibuf write threads; if
  561. this is ULINT_UNDEFINED, then it means that
  562. sync aio is used, and this parameter is
  563. ignored */
  564. ulint pos, /* this parameter is used only in sync aio:
  565. wait for the aio slot at this position */
  566. fil_node_t**message1, /* out: the messages passed with the aio
  567. request; note that also in the case where
  568. the aio operation failed, these output
  569. parameters are valid and can be used to
  570. restart the operation, for example */
  571. void** message2,
  572. ulint* type); /* out: OS_FILE_WRITE or ..._READ */
  573. #endif
  574. /* Currently we do not use Posix async i/o */
  575. #ifdef POSIX_ASYNC_IO
  576. /**************************************************************************
  577. This function is only used in Posix asynchronous i/o. Waits for an aio
  578. operation to complete. */
  579. ibool
  580. os_aio_posix_handle(
  581. /*================*/
  582. /* out: TRUE if the aio operation succeeded */
  583. ulint array_no, /* in: array number 0 - 3 */
  584. fil_node_t**message1, /* out: the messages passed with the aio
  585. request; note that also in the case where
  586. the aio operation failed, these output
  587. parameters are valid and can be used to
  588. restart the operation, for example */
  589. void** message2);
  590. #endif
  591. /**************************************************************************
  592. Does simulated aio. This function should be called by an i/o-handler
  593. thread. */
  594. ibool
  595. os_aio_simulated_handle(
  596. /*====================*/
  597. /* out: TRUE if the aio operation succeeded */
  598. ulint segment, /* in: the number of the segment in the aio
  599. arrays to wait for; segment 0 is the ibuf
  600. i/o thread, segment 1 the log i/o thread,
  601. then follow the non-ibuf read threads, and as
  602. the last are the non-ibuf write threads */
  603. fil_node_t**message1, /* out: the messages passed with the aio
  604. request; note that also in the case where
  605. the aio operation failed, these output
  606. parameters are valid and can be used to
  607. restart the operation, for example */
  608. void** message2,
  609. ulint* type); /* out: OS_FILE_WRITE or ..._READ */
  610. /**************************************************************************
  611. Validates the consistency of the aio system. */
  612. ibool
  613. os_aio_validate(void);
  614. /*=================*/
  615. /* out: TRUE if ok */
  616. /**************************************************************************
  617. Prints info of the aio arrays. */
  618. void
  619. os_aio_print(
  620. /*=========*/
  621. FILE* file); /* in: file where to print */
  622. /**************************************************************************
  623. Refreshes the statistics used to print per-second averages. */
  624. void
  625. os_aio_refresh_stats(void);
  626. /*======================*/
  627. #ifdef UNIV_DEBUG
  628. /**************************************************************************
  629. Checks that all slots in the system have been freed, that is, there are
  630. no pending io operations. */
  631. ibool
  632. os_aio_all_slots_free(void);
  633. /*=======================*/
  634. #endif /* UNIV_DEBUG */
  635. /***********************************************************************
  636. This function returns information about the specified file */
  637. ibool
  638. os_file_get_status(
  639. /*===============*/
  640. /* out: TRUE if stat
  641. information found */
  642. const char* path, /* in: pathname of the file */
  643. os_file_stat_t* stat_info); /* information of a file in a
  644. directory */
  645. #endif