#include "buf0rea.h"#include "fil0fil.h"#include "mtr0mtr.h"#include "buf0buf.h"#include "buf0flu.h"#include "buf0lru.h"#include "ibuf0ibuf.h"#include "log0recv.h"#include "trx0sys.h"#include "os0file.h"#include "srv0start.h"Include dependency graph for buf0rea.c:

Go to the source code of this file.
Defines | |
| #define | BUF_READ_AHEAD_RANDOM_AREA BUF_READ_AHEAD_AREA |
| #define | BUF_READ_AHEAD_RANDOM_THRESHOLD (5 + BUF_READ_AHEAD_RANDOM_AREA / 8) |
| #define | BUF_READ_AHEAD_LINEAR_AREA BUF_READ_AHEAD_AREA |
| #define | BUF_READ_AHEAD_LINEAR_THRESHOLD (3 * BUF_READ_AHEAD_LINEAR_AREA / 8) |
| #define | BUF_READ_AHEAD_PEND_LIMIT 2 |
Functions | |
| static ulint | buf_read_page_low (ulint *err, ibool sync, ulint mode, ulint space, ib_longlong tablespace_version, ulint offset) |
| static ulint | buf_read_ahead_random (ulint space, ulint offset) |
| ulint | buf_read_page (ulint space, ulint offset) |
| ulint | buf_read_ahead_linear (ulint space, ulint offset) |
| void | buf_read_ibuf_merge_pages (ibool sync, ulint *space_ids, ib_longlong *space_versions, ulint *page_nos, ulint n_stored) |
| void | buf_read_recv_pages (ibool sync, ulint space, ulint *page_nos, ulint n_stored) |
Variables | |
| ulint | srv_read_ahead_rnd |
| ulint | srv_read_ahead_seq |
| ulint | srv_buf_pool_reads |
| #define BUF_READ_AHEAD_LINEAR_AREA BUF_READ_AHEAD_AREA |
| #define BUF_READ_AHEAD_LINEAR_THRESHOLD (3 * BUF_READ_AHEAD_LINEAR_AREA / 8) |
| #define BUF_READ_AHEAD_PEND_LIMIT 2 |
Definition at line 44 of file buf0rea.c.
Referenced by buf_read_ahead_linear(), buf_read_ahead_random(), and buf_read_ibuf_merge_pages().
| #define BUF_READ_AHEAD_RANDOM_AREA BUF_READ_AHEAD_AREA |
| #define BUF_READ_AHEAD_RANDOM_THRESHOLD (5 + BUF_READ_AHEAD_RANDOM_AREA / 8) |
Definition at line 373 of file buf0rea.c.
References yaSSL::block, buf_page_hash_get(), buf_pool, BUF_READ_AHEAD_LINEAR_AREA, BUF_READ_AHEAD_PEND_LIMIT, count, buf_pool_struct::curr_size, err, fil_space_get_size(), fil_space_get_version(), ibuf_bitmap_page(), buf_block_struct::LRU_position, buf_pool_struct::mutex, mutex_enter, mutex_exit(), buf_pool_struct::n_pend_reads, NULL, srv_startup_is_before_trx_rollback_phase, trx_sys_hdr_page(), and ut_ulint_cmp().
Referenced by buf_page_optimistic_get_func().
00375 : number of page read requests issued */ 00376 ulint space, /* in: space id */ 00377 ulint offset) /* in: page number of a page; NOTE: the current thread 00378 must want access to this page (see NOTE 3 above) */ 00379 { 00380 ib_longlong tablespace_version; 00381 buf_block_t* block; 00382 buf_frame_t* frame; 00383 buf_block_t* pred_block = NULL; 00384 ulint pred_offset; 00385 ulint succ_offset; 00386 ulint count; 00387 int asc_or_desc; 00388 ulint new_offset; 00389 ulint fail_count; 00390 ulint ibuf_mode; 00391 ulint low, high; 00392 ulint err; 00393 ulint i; 00394 00395 if (srv_startup_is_before_trx_rollback_phase) { 00396 /* No read-ahead to avoid thread deadlocks */ 00397 return(0); 00398 } 00399 00400 if (ibuf_bitmap_page(offset) || trx_sys_hdr_page(space, offset)) { 00401 00402 /* If it is an ibuf bitmap page or trx sys hdr, we do 00403 no read-ahead, as that could break the ibuf page access 00404 order */ 00405 00406 return(0); 00407 } 00408 00409 low = (offset / BUF_READ_AHEAD_LINEAR_AREA) 00410 * BUF_READ_AHEAD_LINEAR_AREA; 00411 high = (offset / BUF_READ_AHEAD_LINEAR_AREA + 1) 00412 * BUF_READ_AHEAD_LINEAR_AREA; 00413 00414 if ((offset != low) && (offset != high - 1)) { 00415 /* This is not a border page of the area: return */ 00416 00417 return(0); 00418 } 00419 00420 /* Remember the tablespace version before we ask te tablespace size 00421 below: if DISCARD + IMPORT changes the actual .ibd file meanwhile, we 00422 do not try to read outside the bounds of the tablespace! */ 00423 00424 tablespace_version = fil_space_get_version(space); 00425 00426 mutex_enter(&(buf_pool->mutex)); 00427 00428 if (high > fil_space_get_size(space)) { 00429 mutex_exit(&(buf_pool->mutex)); 00430 /* The area is not whole, return */ 00431 00432 return(0); 00433 } 00434 00435 if (buf_pool->n_pend_reads > 00436 buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { 00437 mutex_exit(&(buf_pool->mutex)); 00438 00439 return(0); 00440 } 00441 00442 /* Check that almost all pages in the area have been accessed; if 00443 offset == low, the accesses must be in a descending order, otherwise, 00444 in an ascending order. */ 00445 00446 asc_or_desc = 1; 00447 00448 if (offset == low) { 00449 asc_or_desc = -1; 00450 } 00451 00452 fail_count = 0; 00453 00454 for (i = low; i < high; i++) { 00455 block = buf_page_hash_get(space, i); 00456 00457 if ((block == NULL) || !block->accessed) { 00458 /* Not accessed */ 00459 fail_count++; 00460 00461 } else if (pred_block 00462 && (ut_ulint_cmp(block->LRU_position, 00463 pred_block->LRU_position) 00464 != asc_or_desc)) { 00465 /* Accesses not in the right order */ 00466 00467 fail_count++; 00468 pred_block = block; 00469 } 00470 } 00471 00472 if (fail_count > BUF_READ_AHEAD_LINEAR_AREA - 00473 BUF_READ_AHEAD_LINEAR_THRESHOLD) { 00474 /* Too many failures: return */ 00475 00476 mutex_exit(&(buf_pool->mutex)); 00477 00478 return(0); 00479 } 00480 00481 /* If we got this far, we know that enough pages in the area have 00482 been accessed in the right order: linear read-ahead can be sensible */ 00483 00484 block = buf_page_hash_get(space, offset); 00485 00486 if (block == NULL) { 00487 mutex_exit(&(buf_pool->mutex)); 00488 00489 return(0); 00490 } 00491 00492 frame = block->frame; 00493 00494 /* Read the natural predecessor and successor page addresses from 00495 the page; NOTE that because the calling thread may have an x-latch 00496 on the page, we do not acquire an s-latch on the page, this is to 00497 prevent deadlocks. Even if we read values which are nonsense, the 00498 algorithm will work. */ 00499 00500 pred_offset = fil_page_get_prev(frame); 00501 succ_offset = fil_page_get_next(frame); 00502 00503 mutex_exit(&(buf_pool->mutex)); 00504 00505 if ((offset == low) && (succ_offset == offset + 1)) { 00506 00507 /* This is ok, we can continue */ 00508 new_offset = pred_offset; 00509 00510 } else if ((offset == high - 1) && (pred_offset == offset - 1)) { 00511 00512 /* This is ok, we can continue */ 00513 new_offset = succ_offset; 00514 } else { 00515 /* Successor or predecessor not in the right order */ 00516 00517 return(0); 00518 } 00519 00520 low = (new_offset / BUF_READ_AHEAD_LINEAR_AREA) 00521 * BUF_READ_AHEAD_LINEAR_AREA; 00522 high = (new_offset / BUF_READ_AHEAD_LINEAR_AREA + 1) 00523 * BUF_READ_AHEAD_LINEAR_AREA; 00524 00525 if ((new_offset != low) && (new_offset != high - 1)) { 00526 /* This is not a border page of the area: return */ 00527 00528 return(0); 00529 } 00530 00531 if (high > fil_space_get_size(space)) { 00532 /* The area is not whole, return */ 00533 00534 return(0); 00535 } 00536 00537 /* If we got this far, read-ahead can be sensible: do it */ 00538 00539 if (ibuf_inside()) { 00540 ibuf_mode = BUF_READ_IBUF_PAGES_ONLY; 00541 } else { 00542 ibuf_mode = BUF_READ_ANY_PAGE; 00543 } 00544 00545 count = 0; 00546 00547 /* Since Windows XP seems to schedule the i/o handler thread 00548 very eagerly, and consequently it does not wait for the 00549 full read batch to be posted, we use special heuristics here */ 00550 00551 os_aio_simulated_put_read_threads_to_sleep(); 00552 00553 for (i = low; i < high; i++) { 00554 /* It is only sensible to do read-ahead in the non-sync 00555 aio mode: hence FALSE as the first parameter */ 00556 00557 if (!ibuf_bitmap_page(i)) { 00558 count += buf_read_page_low(&err, FALSE, ibuf_mode 00559 | OS_AIO_SIMULATED_WAKE_LATER, 00560 space, tablespace_version, i); 00561 if (err == DB_TABLESPACE_DELETED) { 00562 ut_print_timestamp(stderr); 00563 fprintf(stderr, 00564 " InnoDB: Warning: in linear readahead trying to access tablespace\n" 00565 "InnoDB: %lu page no. %lu,\n" 00566 "InnoDB: but the tablespace does not exist or is just being dropped.\n", 00567 (ulong) space, (ulong) i); 00568 } 00569 } 00570 } 00571 00572 /* In simulated aio we wake the aio handler threads only after 00573 queuing all aio requests, in native aio the following call does 00574 nothing: */ 00575 00576 os_aio_simulated_wake_handler_threads(); 00577 00578 /* Flush pages from the end of the LRU list if necessary */ 00579 buf_flush_free_margin(); 00580 00581 #ifdef UNIV_DEBUG 00582 if (buf_debug_prints && (count > 0)) { 00583 fprintf(stderr, 00584 "LINEAR read-ahead space %lu offset %lu pages %lu\n", 00585 (ulong) space, (ulong) offset, (ulong) count); 00586 } 00587 #endif /* UNIV_DEBUG */ 00588 00589 ++srv_read_ahead_seq; 00590 return(count); 00591 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 170 of file buf0rea.c.
References yaSSL::block, buf_LRU_get_recent_limit(), buf_page_hash_get(), buf_pool, BUF_READ_AHEAD_PEND_LIMIT, BUF_READ_AHEAD_RANDOM_AREA, count, buf_pool_struct::curr_size, err, fil_space_get_size(), fil_space_get_version(), ibuf_bitmap_page(), buf_pool_struct::mutex, mutex_enter, mutex_exit(), buf_pool_struct::n_pend_reads, srv_startup_is_before_trx_rollback_phase, and trx_sys_hdr_page().
Referenced by buf_read_page().
00172 : number of page read requests issued; NOTE 00173 that if we read ibuf pages, it may happen that 00174 the page at the given page number does not get 00175 read even if we return a value > 0! */ 00176 ulint space, /* in: space id */ 00177 ulint offset) /* in: page number of a page which the current thread 00178 wants to access */ 00179 { 00180 ib_longlong tablespace_version; 00181 buf_block_t* block; 00182 ulint recent_blocks = 0; 00183 ulint count; 00184 ulint LRU_recent_limit; 00185 ulint ibuf_mode; 00186 ulint low, high; 00187 ulint err; 00188 ulint i; 00189 00190 if (srv_startup_is_before_trx_rollback_phase) { 00191 /* No read-ahead to avoid thread deadlocks */ 00192 return(0); 00193 } 00194 00195 if (ibuf_bitmap_page(offset) || trx_sys_hdr_page(space, offset)) { 00196 00197 /* If it is an ibuf bitmap page or trx sys hdr, we do 00198 no read-ahead, as that could break the ibuf page access 00199 order */ 00200 00201 return(0); 00202 } 00203 00204 /* Remember the tablespace version before we ask te tablespace size 00205 below: if DISCARD + IMPORT changes the actual .ibd file meanwhile, we 00206 do not try to read outside the bounds of the tablespace! */ 00207 00208 tablespace_version = fil_space_get_version(space); 00209 00210 low = (offset / BUF_READ_AHEAD_RANDOM_AREA) 00211 * BUF_READ_AHEAD_RANDOM_AREA; 00212 high = (offset / BUF_READ_AHEAD_RANDOM_AREA + 1) 00213 * BUF_READ_AHEAD_RANDOM_AREA; 00214 if (high > fil_space_get_size(space)) { 00215 00216 high = fil_space_get_size(space); 00217 } 00218 00219 /* Get the minimum LRU_position field value for an initial segment 00220 of the LRU list, to determine which blocks have recently been added 00221 to the start of the list. */ 00222 00223 LRU_recent_limit = buf_LRU_get_recent_limit(); 00224 00225 mutex_enter(&(buf_pool->mutex)); 00226 00227 if (buf_pool->n_pend_reads > 00228 buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { 00229 mutex_exit(&(buf_pool->mutex)); 00230 00231 return(0); 00232 } 00233 00234 /* Count how many blocks in the area have been recently accessed, 00235 that is, reside near the start of the LRU list. */ 00236 00237 for (i = low; i < high; i++) { 00238 block = buf_page_hash_get(space, i); 00239 00240 if ((block) 00241 && (block->LRU_position > LRU_recent_limit) 00242 && block->accessed) { 00243 00244 recent_blocks++; 00245 } 00246 } 00247 00248 mutex_exit(&(buf_pool->mutex)); 00249 00250 if (recent_blocks < BUF_READ_AHEAD_RANDOM_THRESHOLD) { 00251 /* Do nothing */ 00252 00253 return(0); 00254 } 00255 00256 /* Read all the suitable blocks within the area */ 00257 00258 if (ibuf_inside()) { 00259 ibuf_mode = BUF_READ_IBUF_PAGES_ONLY; 00260 } else { 00261 ibuf_mode = BUF_READ_ANY_PAGE; 00262 } 00263 00264 count = 0; 00265 00266 for (i = low; i < high; i++) { 00267 /* It is only sensible to do read-ahead in the non-sync aio 00268 mode: hence FALSE as the first parameter */ 00269 00270 if (!ibuf_bitmap_page(i)) { 00271 count += buf_read_page_low(&err, FALSE, ibuf_mode 00272 | OS_AIO_SIMULATED_WAKE_LATER, 00273 space, tablespace_version, i); 00274 if (err == DB_TABLESPACE_DELETED) { 00275 ut_print_timestamp(stderr); 00276 fprintf(stderr, 00277 " InnoDB: Warning: in random readahead trying to access tablespace\n" 00278 "InnoDB: %lu page no. %lu,\n" 00279 "InnoDB: but the tablespace does not exist or is just being dropped.\n", 00280 (ulong) space, (ulong) i); 00281 } 00282 } 00283 } 00284 00285 /* In simulated aio we wake the aio handler threads only after 00286 queuing all aio requests, in native aio the following call does 00287 nothing: */ 00288 00289 os_aio_simulated_wake_handler_threads(); 00290 00291 #ifdef UNIV_DEBUG 00292 if (buf_debug_prints && (count > 0)) { 00293 fprintf(stderr, 00294 "Random read-ahead space %lu offset %lu pages %lu\n", 00295 (ulong) space, (ulong) offset, 00296 (ulong) count); 00297 } 00298 #endif /* UNIV_DEBUG */ 00299 00300 ++srv_read_ahead_rnd; 00301 return(count); 00302 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void buf_read_ibuf_merge_pages | ( | ibool | sync, | |
| ulint * | space_ids, | |||
| ib_longlong * | space_versions, | |||
| ulint * | page_nos, | |||
| ulint | n_stored | |||
| ) |
Definition at line 599 of file buf0rea.c.
References buf_flush_free_margin(), buf_pool, BUF_READ_AHEAD_PEND_LIMIT, BUF_READ_ANY_PAGE, buf_read_page_low(), buf_pool_struct::curr_size, DB_TABLESPACE_DELETED, err, FALSE, ibuf_inside(), ibuf_merge_or_delete_for_page(), buf_pool_struct::n_pend_reads, NULL, os_aio_simulated_wake_handler_threads(), os_thread_sleep(), TRUE, UNIV_PAGE_SIZE, ut_a, and ut_ad.
Referenced by ibuf_insert_low().
00601 : TRUE if the caller wants this function 00602 to wait for the highest address page to get 00603 read in, before this function returns */ 00604 ulint* space_ids, /* in: array of space ids */ 00605 ib_longlong* space_versions,/* in: the spaces must have this version 00606 number (timestamp), otherwise we discard the 00607 read; we use this to cancel reads if 00608 DISCARD + IMPORT may have changed the 00609 tablespace size */ 00610 ulint* page_nos, /* in: array of page numbers to read, with the 00611 highest page number the last in the array */ 00612 ulint n_stored) /* in: number of page numbers in the array */ 00613 { 00614 ulint err; 00615 ulint i; 00616 00617 ut_ad(!ibuf_inside()); 00618 #ifdef UNIV_IBUF_DEBUG 00619 ut_a(n_stored < UNIV_PAGE_SIZE); 00620 #endif 00621 while (buf_pool->n_pend_reads > 00622 buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { 00623 os_thread_sleep(500000); 00624 } 00625 00626 for (i = 0; i < n_stored; i++) { 00627 if ((i + 1 == n_stored) && sync) { 00628 buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, 00629 space_ids[i], space_versions[i], page_nos[i]); 00630 } else { 00631 buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE, 00632 space_ids[i], space_versions[i], page_nos[i]); 00633 } 00634 00635 if (err == DB_TABLESPACE_DELETED) { 00636 /* We have deleted or are deleting the single-table 00637 tablespace: remove the entries for that page */ 00638 00639 ibuf_merge_or_delete_for_page(NULL, space_ids[i], 00640 page_nos[i], FALSE); 00641 } 00642 } 00643 00644 os_aio_simulated_wake_handler_threads(); 00645 00646 /* Flush pages from the end of the LRU list if necessary */ 00647 buf_flush_free_margin(); 00648 00649 #ifdef UNIV_DEBUG 00650 if (buf_debug_prints) { 00651 fprintf(stderr, 00652 "Ibuf merge read-ahead space %lu pages %lu\n", 00653 (ulong) space_ids[0], (ulong) n_stored); 00654 } 00655 #endif /* UNIV_DEBUG */ 00656 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 312 of file buf0rea.c.
References buf_flush_free_margin(), buf_read_ahead_random(), BUF_READ_ANY_PAGE, buf_read_page_low(), count, DB_TABLESPACE_DELETED, err, fil_space_get_version(), srv_buf_pool_reads, TRUE, and ut_print_timestamp().
Referenced by buf_page_get_gen().
00314 : number of page read requests issued: this can 00315 be > 1 if read-ahead occurred */ 00316 ulint space, /* in: space id */ 00317 ulint offset) /* in: page number */ 00318 { 00319 ib_longlong tablespace_version; 00320 ulint count; 00321 ulint count2; 00322 ulint err; 00323 00324 tablespace_version = fil_space_get_version(space); 00325 00326 count = buf_read_ahead_random(space, offset); 00327 00328 /* We do the i/o in the synchronous aio mode to save thread 00329 switches: hence TRUE */ 00330 00331 count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space, 00332 tablespace_version, offset); 00333 srv_buf_pool_reads+= count2; 00334 if (err == DB_TABLESPACE_DELETED) { 00335 ut_print_timestamp(stderr); 00336 fprintf(stderr, 00337 " InnoDB: Error: trying to access tablespace %lu page no. %lu,\n" 00338 "InnoDB: but the tablespace does not exist or is just being dropped.\n", 00339 (ulong) space, (ulong) offset); 00340 } 00341 00342 /* Flush pages from the end of the LRU list if necessary */ 00343 buf_flush_free_margin(); 00344 00345 return(count + count2); 00346 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static ulint buf_read_page_low | ( | ulint * | err, | |
| ibool | sync, | |||
| ulint | mode, | |||
| ulint | space, | |||
| ib_longlong | tablespace_version, | |||
| ulint | offset | |||
| ) | [static] |
Definition at line 53 of file buf0rea.c.
References yaSSL::block, trx_doublewrite_struct::block1, trx_doublewrite_struct::block2, BUF_BLOCK_FILE_PAGE, buf_page_init_for_read(), buf_page_io_complete(), DB_SUCCESS, fil_io(), ibuf_bitmap_page(), NULL, OS_AIO_SIMULATED_WAKE_LATER, OS_FILE_READ, TRUE, trx_doublewrite, TRX_SYS_DOUBLEWRITE_BLOCK_SIZE, trx_sys_hdr_page(), TRX_SYS_SPACE, UNIV_PAGE_SIZE, ut_a, and ut_print_timestamp().
Referenced by buf_read_ibuf_merge_pages(), buf_read_page(), and buf_read_recv_pages().
00055 : 1 if a read request was queued, 0 if the page 00056 already resided in buf_pool, or if the page is in 00057 the doublewrite buffer blocks in which case it is never 00058 read into the pool, or if the tablespace does not 00059 exist or is being dropped */ 00060 ulint* err, /* out: DB_SUCCESS or DB_TABLESPACE_DELETED if we are 00061 trying to read from a non-existent tablespace, or a 00062 tablespace which is just now being dropped */ 00063 ibool sync, /* in: TRUE if synchronous aio is desired */ 00064 ulint mode, /* in: BUF_READ_IBUF_PAGES_ONLY, ..., 00065 ORed to OS_AIO_SIMULATED_WAKE_LATER (see below 00066 at read-ahead functions) */ 00067 ulint space, /* in: space id */ 00068 ib_longlong tablespace_version, /* in: if the space memory object has 00069 this timestamp different from what we are giving here, 00070 treat the tablespace as dropped; this is a timestamp we 00071 use to stop dangling page reads from a tablespace 00072 which we have DISCARDed + IMPORTed back */ 00073 ulint offset) /* in: page number */ 00074 { 00075 buf_block_t* block; 00076 ulint wake_later; 00077 00078 *err = DB_SUCCESS; 00079 00080 wake_later = mode & OS_AIO_SIMULATED_WAKE_LATER; 00081 mode = mode & ~OS_AIO_SIMULATED_WAKE_LATER; 00082 00083 if (trx_doublewrite && space == TRX_SYS_SPACE 00084 && ( (offset >= trx_doublewrite->block1 00085 && offset < trx_doublewrite->block1 00086 + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) 00087 || (offset >= trx_doublewrite->block2 00088 && offset < trx_doublewrite->block2 00089 + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE))) { 00090 ut_print_timestamp(stderr); 00091 fprintf(stderr, 00092 " InnoDB: Warning: trying to read doublewrite buffer page %lu\n", 00093 (ulong) offset); 00094 00095 return(0); 00096 } 00097 00098 #ifdef UNIV_LOG_DEBUG 00099 if (space % 2 == 1) { 00100 /* We are updating a replicate space while holding the 00101 log mutex: the read must be handled before other reads 00102 which might incur ibuf operations and thus write to the log */ 00103 00104 fputs("Log debug: reading replicate page in sync mode\n", 00105 stderr); 00106 00107 sync = TRUE; 00108 } 00109 #endif 00110 if (ibuf_bitmap_page(offset) || trx_sys_hdr_page(space, offset)) { 00111 00112 /* Trx sys header is so low in the latching order that we play 00113 safe and do not leave the i/o-completion to an asynchronous 00114 i/o-thread. Ibuf bitmap pages must always be read with 00115 syncronous i/o, to make sure they do not get involved in 00116 thread deadlocks. */ 00117 00118 sync = TRUE; 00119 } 00120 00121 /* The following call will also check if the tablespace does not exist 00122 or is being dropped; if we succeed in initing the page in the buffer 00123 pool for read, then DISCARD cannot proceed until the read has 00124 completed */ 00125 block = buf_page_init_for_read(err, mode, space, tablespace_version, 00126 offset); 00127 if (block == NULL) { 00128 00129 return(0); 00130 } 00131 00132 #ifdef UNIV_DEBUG 00133 if (buf_debug_prints) { 00134 fprintf(stderr, 00135 "Posting read request for page %lu, sync %lu\n", 00136 (ulong) offset, 00137 (ulong) sync); 00138 } 00139 #endif 00140 00141 ut_a(block->state == BUF_BLOCK_FILE_PAGE); 00142 00143 *err = fil_io(OS_FILE_READ | wake_later, 00144 sync, space, 00145 offset, 0, UNIV_PAGE_SIZE, 00146 (void*)block->frame, (void*)block); 00147 ut_a(*err == DB_SUCCESS); 00148 00149 if (sync) { 00150 /* The i/o is already completed when we arrive from 00151 fil_read */ 00152 buf_page_io_complete(block); 00153 } 00154 00155 return(1); 00156 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 662 of file buf0rea.c.
References buf_pool, BUF_READ_ANY_PAGE, buf_read_page_low(), count, err, FALSE, fil_space_get_version(), buf_pool_struct::n_pend_reads, os_aio_print_debug, os_aio_simulated_wake_handler_threads(), OS_AIO_SIMULATED_WAKE_LATER, os_file_n_pending_preads, os_thread_sleep(), recv_n_pool_free_frames, and TRUE.
00664 : TRUE if the caller wants this function 00665 to wait for the highest address page to get 00666 read in, before this function returns */ 00667 ulint space, /* in: space id */ 00668 ulint* page_nos, /* in: array of page numbers to read, with the 00669 highest page number the last in the array */ 00670 ulint n_stored) /* in: number of page numbers in the array */ 00671 { 00672 ib_longlong tablespace_version; 00673 ulint count; 00674 ulint err; 00675 ulint i; 00676 00677 tablespace_version = fil_space_get_version(space); 00678 00679 for (i = 0; i < n_stored; i++) { 00680 00681 count = 0; 00682 00683 os_aio_print_debug = FALSE; 00684 00685 while (buf_pool->n_pend_reads >= recv_n_pool_free_frames / 2) { 00686 00687 os_aio_simulated_wake_handler_threads(); 00688 os_thread_sleep(500000); 00689 00690 count++; 00691 00692 if (count > 100) { 00693 fprintf(stderr, 00694 "InnoDB: Error: InnoDB has waited for 50 seconds for pending\n" 00695 "InnoDB: reads to the buffer pool to be finished.\n" 00696 "InnoDB: Number of pending reads %lu, pending pread calls %lu\n", 00697 (ulong) buf_pool->n_pend_reads, 00698 (ulong)os_file_n_pending_preads); 00699 00700 os_aio_print_debug = TRUE; 00701 } 00702 } 00703 00704 os_aio_print_debug = FALSE; 00705 00706 if ((i + 1 == n_stored) && sync) { 00707 buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space, 00708 tablespace_version, page_nos[i]); 00709 } else { 00710 buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE 00711 | OS_AIO_SIMULATED_WAKE_LATER, 00712 space, tablespace_version, page_nos[i]); 00713 } 00714 } 00715 00716 os_aio_simulated_wake_handler_threads(); 00717 00718 /* Flush pages from the end of the LRU list if necessary */ 00719 buf_flush_free_margin(); 00720 00721 #ifdef UNIV_DEBUG 00722 if (buf_debug_prints) { 00723 fprintf(stderr, 00724 "Recovery applies read-ahead pages %lu\n", (ulong) n_stored); 00725 } 00726 #endif /* UNIV_DEBUG */ 00727 }
Here is the call graph for this function:

Definition at line 237 of file srv0srv.c.
Referenced by buf_read_page(), and srv_export_innodb_status().
1.4.7

