00001 /****************************************************** 00002 The low-level file system 00003 00004 (c) 1995 Innobase Oy 00005 00006 Created 10/25/1995 Heikki Tuuri 00007 *******************************************************/ 00008 00009 #ifndef fil0fil_h 00010 #define fil0fil_h 00011 00012 #include "univ.i" 00013 #include "sync0rw.h" 00014 #include "dict0types.h" 00015 #include "ibuf0types.h" 00016 #include "ut0byte.h" 00017 #include "os0file.h" 00018 00019 /* When mysqld is run, the default directory "." is the mysqld datadir, but in 00020 ibbackup we must set it explicitly; the patgh must NOT contain the trailing 00021 '/' or '\' */ 00022 extern const char* fil_path_to_mysql_datadir; 00023 00024 /* Initial size of a single-table tablespace in pages */ 00025 #define FIL_IBD_FILE_INITIAL_SIZE 4 00026 00027 /* 'null' (undefined) page offset in the context of file spaces */ 00028 #define FIL_NULL ULINT32_UNDEFINED 00029 00030 /* Space address data type; this is intended to be used when 00031 addresses accurate to a byte are stored in file pages. If the page part 00032 of the address is FIL_NULL, the address is considered undefined. */ 00033 00034 typedef byte fil_faddr_t; /* 'type' definition in C: an address 00035 stored in a file page is a string of bytes */ 00036 #define FIL_ADDR_PAGE 0 /* first in address is the page offset */ 00037 #define FIL_ADDR_BYTE 4 /* then comes 2-byte byte offset within page*/ 00038 00039 #define FIL_ADDR_SIZE 6 /* address size is 6 bytes */ 00040 00041 /* A struct for storing a space address FIL_ADDR, when it is used 00042 in C program data structures. */ 00043 00044 typedef struct fil_addr_struct fil_addr_t; 00045 struct fil_addr_struct{ 00046 ulint page; /* page number within a space */ 00047 ulint boffset; /* byte offset within the page */ 00048 }; 00049 00050 /* Null file address */ 00051 extern fil_addr_t fil_addr_null; 00052 00053 /* The byte offsets on a file page for various variables */ 00054 #define FIL_PAGE_SPACE_OR_CHKSUM 0 /* in < MySQL-4.0.14 space id the 00055 page belongs to (== 0) but in later 00056 versions the 'new' checksum of the 00057 page */ 00058 #define FIL_PAGE_OFFSET 4 /* page offset inside space */ 00059 #define FIL_PAGE_PREV 8 /* if there is a 'natural' predecessor 00060 of the page, its offset. 00061 Otherwise FIL_NULL. 00062 This field is not set on BLOB pages, 00063 which are stored as a singly-linked 00064 list. See also FIL_PAGE_NEXT. */ 00065 #define FIL_PAGE_NEXT 12 /* if there is a 'natural' successor 00066 of the page, its offset. 00067 Otherwise FIL_NULL. 00068 B-tree index pages 00069 (FIL_PAGE_TYPE contains FIL_PAGE_INDEX) 00070 on the same PAGE_LEVEL are maintained 00071 as a doubly linked list via 00072 FIL_PAGE_PREV and FIL_PAGE_NEXT 00073 in the collation order of the 00074 smallest user record on each page. */ 00075 #define FIL_PAGE_LSN 16 /* lsn of the end of the newest 00076 modification log record to the page */ 00077 #define FIL_PAGE_TYPE 24 /* file page type: FIL_PAGE_INDEX,..., 00078 2 bytes. 00079 00080 The contents of this field can only 00081 be trusted in the following case: 00082 if the page is an uncompressed 00083 B-tree index page, then it is 00084 guaranteed that the value is 00085 FIL_PAGE_INDEX. 00086 The opposite does not hold. 00087 00088 In tablespaces created by 00089 MySQL/InnoDB 5.1.7 or later, the 00090 contents of this field is valid 00091 for all uncompressed pages. */ 00092 #define FIL_PAGE_FILE_FLUSH_LSN 26 /* this is only defined for the 00093 first page in a data file: the file 00094 has been flushed to disk at least up 00095 to this lsn */ 00096 #define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID 34 /* starting from 4.1.x this 00097 contains the space id of the page */ 00098 #define FIL_PAGE_DATA 38 /* start of the data on the page */ 00099 00100 /* File page trailer */ 00101 #define FIL_PAGE_END_LSN_OLD_CHKSUM 8 /* the low 4 bytes of this are used 00102 to store the page checksum, the 00103 last 4 bytes should be identical 00104 to the last 4 bytes of FIL_PAGE_LSN */ 00105 #define FIL_PAGE_DATA_END 8 00106 00107 /* File page types (values of FIL_PAGE_TYPE) */ 00108 #define FIL_PAGE_INDEX 17855 /* B-tree node */ 00109 #define FIL_PAGE_UNDO_LOG 2 /* Undo log page */ 00110 #define FIL_PAGE_INODE 3 /* Index node */ 00111 #define FIL_PAGE_IBUF_FREE_LIST 4 /* Insert buffer free list */ 00112 /* File page types introduced in MySQL/InnoDB 5.1.7 */ 00113 #define FIL_PAGE_TYPE_ALLOCATED 0 /* Freshly allocated page */ 00114 #define FIL_PAGE_IBUF_BITMAP 5 /* Insert buffer bitmap */ 00115 #define FIL_PAGE_TYPE_SYS 6 /* System page */ 00116 #define FIL_PAGE_TYPE_TRX_SYS 7 /* Transaction system data */ 00117 #define FIL_PAGE_TYPE_FSP_HDR 8 /* File space header */ 00118 #define FIL_PAGE_TYPE_XDES 9 /* Extent descriptor page */ 00119 #define FIL_PAGE_TYPE_BLOB 10 /* Uncompressed BLOB page */ 00120 00121 /* Space types */ 00122 #define FIL_TABLESPACE 501 00123 #define FIL_LOG 502 00124 00125 extern ulint fil_n_log_flushes; 00126 00127 extern ulint fil_n_pending_log_flushes; 00128 extern ulint fil_n_pending_tablespace_flushes; 00129 00130 00131 /*********************************************************************** 00132 Returns the version number of a tablespace, -1 if not found. */ 00133 00134 ib_longlong 00135 fil_space_get_version( 00136 /*==================*/ 00137 /* out: version number, -1 if the tablespace does not 00138 exist in the memory cache */ 00139 ulint id); /* in: space id */ 00140 /*********************************************************************** 00141 Returns the latch of a file space. */ 00142 00143 rw_lock_t* 00144 fil_space_get_latch( 00145 /*================*/ 00146 /* out: latch protecting storage allocation */ 00147 ulint id); /* in: space id */ 00148 /*********************************************************************** 00149 Returns the type of a file space. */ 00150 00151 ulint 00152 fil_space_get_type( 00153 /*===============*/ 00154 /* out: FIL_TABLESPACE or FIL_LOG */ 00155 ulint id); /* in: space id */ 00156 /*********************************************************************** 00157 Returns the ibuf data of a file space. */ 00158 00159 ibuf_data_t* 00160 fil_space_get_ibuf_data( 00161 /*====================*/ 00162 /* out: ibuf data for this space */ 00163 ulint id); /* in: space id */ 00164 /*********************************************************************** 00165 Appends a new file to the chain of files of a space. File must be closed. */ 00166 00167 void 00168 fil_node_create( 00169 /*============*/ 00170 const char* name, /* in: file name (file must be closed) */ 00171 ulint size, /* in: file size in database blocks, rounded 00172 downwards to an integer */ 00173 ulint id, /* in: space id where to append */ 00174 ibool is_raw);/* in: TRUE if a raw device or 00175 a raw disk partition */ 00176 /******************************************************************** 00177 Drops files from the start of a file space, so that its size is cut by 00178 the amount given. */ 00179 00180 void 00181 fil_space_truncate_start( 00182 /*=====================*/ 00183 ulint id, /* in: space id */ 00184 ulint trunc_len); /* in: truncate by this much; it is an error 00185 if this does not equal to the combined size of 00186 some initial files in the space */ 00187 /*********************************************************************** 00188 Creates a space memory object and puts it to the 'fil system' hash table. If 00189 there is an error, prints an error message to the .err log. */ 00190 00191 ibool 00192 fil_space_create( 00193 /*=============*/ 00194 /* out: TRUE if success */ 00195 const char* name, /* in: space name */ 00196 ulint id, /* in: space id */ 00197 ulint purpose);/* in: FIL_TABLESPACE, or FIL_LOG if log */ 00198 /*********************************************************************** 00199 Frees a space object from a the tablespace memory cache. Closes the files in 00200 the chain but does not delete them. */ 00201 00202 ibool 00203 fil_space_free( 00204 /*===========*/ 00205 /* out: TRUE if success */ 00206 ulint id); /* in: space id */ 00207 /*********************************************************************** 00208 Returns the size of the space in pages. The tablespace must be cached in the 00209 memory cache. */ 00210 00211 ulint 00212 fil_space_get_size( 00213 /*===============*/ 00214 /* out: space size, 0 if space not found */ 00215 ulint id); /* in: space id */ 00216 /*********************************************************************** 00217 Checks if the pair space, page_no refers to an existing page in a tablespace 00218 file space. The tablespace must be cached in the memory cache. */ 00219 00220 ibool 00221 fil_check_adress_in_tablespace( 00222 /*===========================*/ 00223 /* out: TRUE if the address is meaningful */ 00224 ulint id, /* in: space id */ 00225 ulint page_no);/* in: page number */ 00226 /******************************************************************** 00227 Initializes the tablespace memory cache. */ 00228 00229 void 00230 fil_init( 00231 /*=====*/ 00232 ulint max_n_open); /* in: max number of open files */ 00233 /*********************************************************************** 00234 Opens all log files and system tablespace data files. They stay open until the 00235 database server shutdown. This should be called at a server startup after the 00236 space objects for the log and the system tablespace have been created. The 00237 purpose of this operation is to make sure we never run out of file descriptors 00238 if we need to read from the insert buffer or to write to the log. */ 00239 00240 void 00241 fil_open_log_and_system_tablespace_files(void); 00242 /*==========================================*/ 00243 /*********************************************************************** 00244 Closes all open files. There must not be any pending i/o's or not flushed 00245 modifications in the files. */ 00246 00247 void 00248 fil_close_all_files(void); 00249 /*=====================*/ 00250 /*********************************************************************** 00251 Sets the max tablespace id counter if the given number is bigger than the 00252 previous value. */ 00253 00254 void 00255 fil_set_max_space_id_if_bigger( 00256 /*===========================*/ 00257 ulint max_id);/* in: maximum known id */ 00258 /******************************************************************** 00259 Initializes the ibuf data structure for space 0 == the system tablespace. 00260 This can be called after the file space headers have been created and the 00261 dictionary system has been initialized. */ 00262 00263 void 00264 fil_ibuf_init_at_db_start(void); 00265 /*===========================*/ 00266 /******************************************************************** 00267 Writes the flushed lsn and the latest archived log number to the page 00268 header of the first page of each data file in the system tablespace. */ 00269 00270 ulint 00271 fil_write_flushed_lsn_to_data_files( 00272 /*================================*/ 00273 /* out: DB_SUCCESS or error number */ 00274 dulint lsn, /* in: lsn to write */ 00275 ulint arch_log_no); /* in: latest archived log file number */ 00276 /*********************************************************************** 00277 Reads the flushed lsn and arch no fields from a data file at database 00278 startup. */ 00279 00280 void 00281 fil_read_flushed_lsn_and_arch_log_no( 00282 /*=================================*/ 00283 os_file_t data_file, /* in: open data file */ 00284 ibool one_read_already, /* in: TRUE if min and max parameters 00285 below already contain sensible data */ 00286 #ifdef UNIV_LOG_ARCHIVE 00287 ulint* min_arch_log_no, /* in/out: */ 00288 ulint* max_arch_log_no, /* in/out: */ 00289 #endif /* UNIV_LOG_ARCHIVE */ 00290 dulint* min_flushed_lsn, /* in/out: */ 00291 dulint* max_flushed_lsn); /* in/out: */ 00292 /*********************************************************************** 00293 Increments the count of pending insert buffer page merges, if space is not 00294 being deleted. */ 00295 00296 ibool 00297 fil_inc_pending_ibuf_merges( 00298 /*========================*/ 00299 /* out: TRUE if being deleted, and ibuf merges should 00300 be skipped */ 00301 ulint id); /* in: space id */ 00302 /*********************************************************************** 00303 Decrements the count of pending insert buffer page merges. */ 00304 00305 void 00306 fil_decr_pending_ibuf_merges( 00307 /*=========================*/ 00308 ulint id); /* in: space id */ 00309 /*********************************************************************** 00310 Parses the body of a log record written about an .ibd file operation. That is, 00311 the log record part after the standard (type, space id, page no) header of the 00312 log record. 00313 00314 If desired, also replays the delete or rename operation if the .ibd file 00315 exists and the space id in it matches. Replays the create operation if a file 00316 at that path does not exist yet. If the database directory for the file to be 00317 created does not exist, then we create the directory, too. 00318 00319 Note that ibbackup --apply-log sets fil_path_to_mysql_datadir to point to the 00320 datadir that we should use in replaying the file operations. */ 00321 00322 byte* 00323 fil_op_log_parse_or_replay( 00324 /*=======================*/ 00325 /* out: end of log record, or NULL if the 00326 record was not completely contained between 00327 ptr and end_ptr */ 00328 byte* ptr, /* in: buffer containing the log record body, 00329 or an initial segment of it, if the record does 00330 not fir completely between ptr and end_ptr */ 00331 byte* end_ptr, /* in: buffer end */ 00332 ulint type, /* in: the type of this log record */ 00333 ibool do_replay, /* in: TRUE if we want to replay the 00334 operation, and not just parse the log record */ 00335 ulint space_id); /* in: if do_replay is TRUE, the space id of 00336 the tablespace in question; otherwise 00337 ignored */ 00338 /*********************************************************************** 00339 Deletes a single-table tablespace. The tablespace must be cached in the 00340 memory cache. */ 00341 00342 ibool 00343 fil_delete_tablespace( 00344 /*==================*/ 00345 /* out: TRUE if success */ 00346 ulint id); /* in: space id */ 00347 /*********************************************************************** 00348 Discards a single-table tablespace. The tablespace must be cached in the 00349 memory cache. Discarding is like deleting a tablespace, but 00350 1) we do not drop the table from the data dictionary; 00351 2) we remove all insert buffer entries for the tablespace immediately; in DROP 00352 TABLE they are only removed gradually in the background; 00353 3) when the user does IMPORT TABLESPACE, the tablespace will have the same id 00354 as it originally had. */ 00355 00356 ibool 00357 fil_discard_tablespace( 00358 /*===================*/ 00359 /* out: TRUE if success */ 00360 ulint id); /* in: space id */ 00361 /*********************************************************************** 00362 Renames a single-table tablespace. The tablespace must be cached in the 00363 tablespace memory cache. */ 00364 00365 ibool 00366 fil_rename_tablespace( 00367 /*==================*/ 00368 /* out: TRUE if success */ 00369 const char* old_name, /* in: old table name in the standard 00370 databasename/tablename format of 00371 InnoDB, or NULL if we do the rename 00372 based on the space id only */ 00373 ulint id, /* in: space id */ 00374 const char* new_name); /* in: new table name in the standard 00375 databasename/tablename format 00376 of InnoDB */ 00377 00378 /*********************************************************************** 00379 Creates a new single-table tablespace to a database directory of MySQL. 00380 Database directories are under the 'datadir' of MySQL. The datadir is the 00381 directory of a running mysqld program. We can refer to it by simply the 00382 path '.'. Tables created with CREATE TEMPORARY TABLE we place in the temp 00383 dir of the mysqld server. */ 00384 00385 ulint 00386 fil_create_new_single_table_tablespace( 00387 /*===================================*/ 00388 /* out: DB_SUCCESS or error code */ 00389 ulint* space_id, /* in/out: space id; if this is != 0, 00390 then this is an input parameter, 00391 otherwise output */ 00392 const char* tablename, /* in: the table name in the usual 00393 databasename/tablename format 00394 of InnoDB, or a dir path to a temp 00395 table */ 00396 ibool is_temp, /* in: TRUE if a table created with 00397 CREATE TEMPORARY TABLE */ 00398 ulint size); /* in: the initial size of the 00399 tablespace file in pages, 00400 must be >= FIL_IBD_FILE_INITIAL_SIZE */ 00401 /************************************************************************ 00402 Tries to open a single-table tablespace and optionally checks the space id is 00403 right in it. If does not succeed, prints an error message to the .err log. This 00404 function is used to open a tablespace when we start up mysqld, and also in 00405 IMPORT TABLESPACE. 00406 NOTE that we assume this operation is used either at the database startup 00407 or under the protection of the dictionary mutex, so that two users cannot 00408 race here. This operation does not leave the file associated with the 00409 tablespace open, but closes it after we have looked at the space id in it. */ 00410 00411 ibool 00412 fil_open_single_table_tablespace( 00413 /*=============================*/ 00414 /* out: TRUE if success */ 00415 ibool check_space_id, /* in: should we check that the space 00416 id in the file is right; we assume 00417 that this function runs much faster 00418 if no check is made, since accessing 00419 the file inode probably is much 00420 faster (the OS caches them) than 00421 accessing the first page of the file */ 00422 ulint id, /* in: space id */ 00423 const char* name); /* in: table name in the 00424 databasename/tablename format */ 00425 /************************************************************************ 00426 It is possible, though very improbable, that the lsn's in the tablespace to be 00427 imported have risen above the current system lsn, if a lengthy purge, ibuf 00428 merge, or rollback was performed on a backup taken with ibbackup. If that is 00429 the case, reset page lsn's in the file. We assume that mysqld was shut down 00430 after it performed these cleanup operations on the .ibd file, so that it at 00431 the shutdown stamped the latest lsn to the FIL_PAGE_FILE_FLUSH_LSN in the 00432 first page of the .ibd file, and we can determine whether we need to reset the 00433 lsn's just by looking at that flush lsn. */ 00434 00435 ibool 00436 fil_reset_too_high_lsns( 00437 /*====================*/ 00438 /* out: TRUE if success */ 00439 const char* name, /* in: table name in the 00440 databasename/tablename format */ 00441 dulint current_lsn); /* in: reset lsn's if the lsn stamped 00442 to FIL_PAGE_FILE_FLUSH_LSN in the 00443 first page is too high */ 00444 /************************************************************************ 00445 At the server startup, if we need crash recovery, scans the database 00446 directories under the MySQL datadir, looking for .ibd files. Those files are 00447 single-table tablespaces. We need to know the space id in each of them so that 00448 we know into which file we should look to check the contents of a page stored 00449 in the doublewrite buffer, also to know where to apply log records where the 00450 space id is != 0. */ 00451 00452 ulint 00453 fil_load_single_table_tablespaces(void); 00454 /*===================================*/ 00455 /* out: DB_SUCCESS or error number */ 00456 /************************************************************************ 00457 If we need crash recovery, and we have called 00458 fil_load_single_table_tablespaces() and dict_load_single_table_tablespaces(), 00459 we can call this function to print an error message of orphaned .ibd files 00460 for which there is not a data dictionary entry with a matching table name 00461 and space id. */ 00462 00463 void 00464 fil_print_orphaned_tablespaces(void); 00465 /*================================*/ 00466 /*********************************************************************** 00467 Returns TRUE if a single-table tablespace does not exist in the memory cache, 00468 or is being deleted there. */ 00469 00470 ibool 00471 fil_tablespace_deleted_or_being_deleted_in_mem( 00472 /*===========================================*/ 00473 /* out: TRUE if does not exist or is being\ 00474 deleted */ 00475 ulint id, /* in: space id */ 00476 ib_longlong version);/* in: tablespace_version should be this; if 00477 you pass -1 as the value of this, then this 00478 parameter is ignored */ 00479 /*********************************************************************** 00480 Returns TRUE if a single-table tablespace exists in the memory cache. */ 00481 00482 ibool 00483 fil_tablespace_exists_in_mem( 00484 /*=========================*/ 00485 /* out: TRUE if exists */ 00486 ulint id); /* in: space id */ 00487 /*********************************************************************** 00488 Returns TRUE if a matching tablespace exists in the InnoDB tablespace memory 00489 cache. Note that if we have not done a crash recovery at the database startup, 00490 there may be many tablespaces which are not yet in the memory cache. */ 00491 00492 ibool 00493 fil_space_for_table_exists_in_mem( 00494 /*==============================*/ 00495 /* out: TRUE if a matching tablespace 00496 exists in the memory cache */ 00497 ulint id, /* in: space id */ 00498 const char* name, /* in: table name in the standard 00499 'databasename/tablename' format or 00500 the dir path to a temp table */ 00501 ibool is_temp, /* in: TRUE if created with CREATE 00502 TEMPORARY TABLE */ 00503 ibool mark_space, /* in: in crash recovery, at database 00504 startup we mark all spaces which have 00505 an associated table in the InnoDB 00506 data dictionary, so that 00507 we can print a warning about orphaned 00508 tablespaces */ 00509 ibool print_error_if_does_not_exist); 00510 /* in: print detailed error 00511 information to the .err log if a 00512 matching tablespace is not found from 00513 memory */ 00514 /************************************************************************** 00515 Tries to extend a data file so that it would accommodate the number of pages 00516 given. The tablespace must be cached in the memory cache. If the space is big 00517 enough already, does nothing. */ 00518 00519 ibool 00520 fil_extend_space_to_desired_size( 00521 /*=============================*/ 00522 /* out: TRUE if success */ 00523 ulint* actual_size, /* out: size of the space after extension; 00524 if we ran out of disk space this may be lower 00525 than the desired size */ 00526 ulint space_id, /* in: space id */ 00527 ulint size_after_extend);/* in: desired size in pages after the 00528 extension; if the current space size is bigger 00529 than this already, the function does nothing */ 00530 #ifdef UNIV_HOTBACKUP 00531 /************************************************************************ 00532 Extends all tablespaces to the size stored in the space header. During the 00533 ibbackup --apply-log phase we extended the spaces on-demand so that log records 00534 could be appllied, but that may have left spaces still too small compared to 00535 the size stored in the space header. */ 00536 00537 void 00538 fil_extend_tablespaces_to_stored_len(void); 00539 /*======================================*/ 00540 #endif 00541 /*********************************************************************** 00542 Tries to reserve free extents in a file space. */ 00543 00544 ibool 00545 fil_space_reserve_free_extents( 00546 /*===========================*/ 00547 /* out: TRUE if succeed */ 00548 ulint id, /* in: space id */ 00549 ulint n_free_now, /* in: number of free extents now */ 00550 ulint n_to_reserve); /* in: how many one wants to reserve */ 00551 /*********************************************************************** 00552 Releases free extents in a file space. */ 00553 00554 void 00555 fil_space_release_free_extents( 00556 /*===========================*/ 00557 ulint id, /* in: space id */ 00558 ulint n_reserved); /* in: how many one reserved */ 00559 /*********************************************************************** 00560 Gets the number of reserved extents. If the database is silent, this number 00561 should be zero. */ 00562 00563 ulint 00564 fil_space_get_n_reserved_extents( 00565 /*=============================*/ 00566 ulint id); /* in: space id */ 00567 /************************************************************************ 00568 Reads or writes data. This operation is asynchronous (aio). */ 00569 00570 ulint 00571 fil_io( 00572 /*===*/ 00573 /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED 00574 if we are trying to do i/o on a tablespace 00575 which does not exist */ 00576 ulint type, /* in: OS_FILE_READ or OS_FILE_WRITE, 00577 ORed to OS_FILE_LOG, if a log i/o 00578 and ORed to OS_AIO_SIMULATED_WAKE_LATER 00579 if simulated aio and we want to post a 00580 batch of i/os; NOTE that a simulated batch 00581 may introduce hidden chances of deadlocks, 00582 because i/os are not actually handled until 00583 all have been posted: use with great 00584 caution! */ 00585 ibool sync, /* in: TRUE if synchronous aio is desired */ 00586 ulint space_id, /* in: space id */ 00587 ulint block_offset, /* in: offset in number of blocks */ 00588 ulint byte_offset, /* in: remainder of offset in bytes; in 00589 aio this must be divisible by the OS block 00590 size */ 00591 ulint len, /* in: how many bytes to read or write; this 00592 must not cross a file boundary; in aio this 00593 must be a block size multiple */ 00594 void* buf, /* in/out: buffer where to store read data 00595 or from where to write; in aio this must be 00596 appropriately aligned */ 00597 void* message); /* in: message for aio handler if non-sync 00598 aio used, else ignored */ 00599 /************************************************************************ 00600 Reads data from a space to a buffer. Remember that the possible incomplete 00601 blocks at the end of file are ignored: they are not taken into account when 00602 calculating the byte offset within a space. */ 00603 00604 ulint 00605 fil_read( 00606 /*=====*/ 00607 /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED 00608 if we are trying to do i/o on a tablespace 00609 which does not exist */ 00610 ibool sync, /* in: TRUE if synchronous aio is desired */ 00611 ulint space_id, /* in: space id */ 00612 ulint block_offset, /* in: offset in number of blocks */ 00613 ulint byte_offset, /* in: remainder of offset in bytes; in aio 00614 this must be divisible by the OS block size */ 00615 ulint len, /* in: how many bytes to read; this must not 00616 cross a file boundary; in aio this must be a 00617 block size multiple */ 00618 void* buf, /* in/out: buffer where to store data read; 00619 in aio this must be appropriately aligned */ 00620 void* message); /* in: message for aio handler if non-sync 00621 aio used, else ignored */ 00622 /************************************************************************ 00623 Writes data to a space from a buffer. Remember that the possible incomplete 00624 blocks at the end of file are ignored: they are not taken into account when 00625 calculating the byte offset within a space. */ 00626 00627 ulint 00628 fil_write( 00629 /*======*/ 00630 /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED 00631 if we are trying to do i/o on a tablespace 00632 which does not exist */ 00633 ibool sync, /* in: TRUE if synchronous aio is desired */ 00634 ulint space_id, /* in: space id */ 00635 ulint block_offset, /* in: offset in number of blocks */ 00636 ulint byte_offset, /* in: remainder of offset in bytes; in aio 00637 this must be divisible by the OS block size */ 00638 ulint len, /* in: how many bytes to write; this must 00639 not cross a file boundary; in aio this must 00640 be a block size multiple */ 00641 void* buf, /* in: buffer from which to write; in aio 00642 this must be appropriately aligned */ 00643 void* message); /* in: message for aio handler if non-sync 00644 aio used, else ignored */ 00645 /************************************************************************** 00646 Waits for an aio operation to complete. This function is used to write the 00647 handler for completed requests. The aio array of pending requests is divided 00648 into segments (see os0file.c for more info). The thread specifies which 00649 segment it wants to wait for. */ 00650 00651 void 00652 fil_aio_wait( 00653 /*=========*/ 00654 ulint segment); /* in: the number of the segment in the aio 00655 array to wait for */ 00656 /************************************************************************** 00657 Flushes to disk possible writes cached by the OS. If the space does not exist 00658 or is being dropped, does not do anything. */ 00659 00660 void 00661 fil_flush( 00662 /*======*/ 00663 ulint space_id); /* in: file space id (this can be a group of 00664 log files or a tablespace of the database) */ 00665 /************************************************************************** 00666 Flushes to disk writes in file spaces of the given type possibly cached by 00667 the OS. */ 00668 00669 void 00670 fil_flush_file_spaces( 00671 /*==================*/ 00672 ulint purpose); /* in: FIL_TABLESPACE, FIL_LOG */ 00673 /********************************************************************** 00674 Checks the consistency of the tablespace cache. */ 00675 00676 ibool 00677 fil_validate(void); 00678 /*==============*/ 00679 /* out: TRUE if ok */ 00680 /************************************************************************ 00681 Returns TRUE if file address is undefined. */ 00682 00683 ibool 00684 fil_addr_is_null( 00685 /*=============*/ 00686 /* out: TRUE if undefined */ 00687 fil_addr_t addr); /* in: address */ 00688 /************************************************************************ 00689 Accessor functions for a file page */ 00690 00691 ulint 00692 fil_page_get_prev(byte* page); 00693 ulint 00694 fil_page_get_next(byte* page); 00695 /************************************************************************* 00696 Sets the file page type. */ 00697 00698 void 00699 fil_page_set_type( 00700 /*==============*/ 00701 byte* page, /* in: file page */ 00702 ulint type); /* in: type */ 00703 /************************************************************************* 00704 Gets the file page type. */ 00705 00706 ulint 00707 fil_page_get_type( 00708 /*==============*/ 00709 /* out: type; NOTE that if the type has not been 00710 written to page, the return value not defined */ 00711 byte* page); /* in: file page */ 00712 00713 00714 typedef struct fil_space_struct fil_space_t; 00715 00716 #endif
1.4.7

