42 #define BUF_READ_AHEAD_LINEAR_AREA BUF_READ_AHEAD_AREA
47 #define BUF_READ_AHEAD_PEND_LIMIT 2
73 ib_int64_t tablespace_version,
86 mode = mode & ~OS_AIO_SIMULATED_WAKE_LATER;
90 && offset < trx_doublewrite->block1
93 && offset < trx_doublewrite->block2
97 " InnoDB: Warning: trying to read"
98 " doublewrite buffer page %lu\n",
120 bpage = buf_page_init_for_read(err, mode, space, zip_size, unzip,
121 tablespace_version, offset);
128 if (buf_debug_prints) {
130 "Posting read request for page %lu, sync %lu\n",
140 sync, space, zip_size, offset, 0, zip_size,
146 sync, space, 0, offset, 0, UNIV_PAGE_SIZE,
149 ut_a(*err == DB_SUCCESS);
154 buf_page_io_complete(bpage);
175 ib_int64_t tablespace_version;
179 tablespace_version = fil_space_get_version(space);
186 tablespace_version, offset);
188 if (err == DB_TABLESPACE_DELETED) {
191 " InnoDB: Error: trying to access"
192 " tablespace %lu page no. %lu,\n"
193 "InnoDB: but the tablespace does not exist"
194 " or is just being dropped.\n",
195 (ulong) space, (ulong) offset);
199 buf_flush_free_margin(buf_pool);
233 buf_read_ahead_linear(
241 ib_int64_t tablespace_version;
255 const ulint buf_read_ahead_linear_area
256 = BUF_READ_AHEAD_LINEAR_AREA(buf_pool);
259 if ((srv_read_ahead & 2) ==
false) {
268 low = (offset / buf_read_ahead_linear_area)
269 * buf_read_ahead_linear_area;
270 high = (offset / buf_read_ahead_linear_area + 1)
271 * buf_read_ahead_linear_area;
273 if ((offset != low) && (offset != high - 1)) {
293 tablespace_version = fil_space_get_version(space);
297 if (high > fil_space_get_size(space)) {
305 > buf_pool->
curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
323 threshold =
ut_min((64 - srv_read_ahead_threshold),
328 for (i = low; i < high; i++) {
335 }
else if (pred_bpage) {
348 if (res != 0 && res != asc_or_desc) {
353 if (fail_count > threshold) {
393 pred_offset = fil_page_get_prev(frame);
394 succ_offset = fil_page_get_next(frame);
398 if ((offset == low) && (succ_offset == offset + 1)) {
401 new_offset = pred_offset;
403 }
else if ((offset == high - 1) && (pred_offset == offset - 1)) {
406 new_offset = succ_offset;
413 low = (new_offset / buf_read_ahead_linear_area)
414 * buf_read_ahead_linear_area;
415 high = (new_offset / buf_read_ahead_linear_area + 1)
416 * buf_read_ahead_linear_area;
418 if ((new_offset != low) && (new_offset != high - 1)) {
424 if (high > fil_space_get_size(space)) {
446 for (i = low; i < high; i++) {
451 count += buf_read_page_low(
454 space, zip_size, FALSE, tablespace_version, i);
455 if (err == DB_TABLESPACE_DELETED) {
458 " InnoDB: Warning: in"
459 " linear readahead trying to access\n"
460 "InnoDB: tablespace %lu page %lu,\n"
461 "InnoDB: but the tablespace does not"
462 " exist or is just being dropped.\n",
463 (ulong) space, (ulong) i);
475 buf_flush_free_margin(buf_pool);
478 if (buf_debug_prints && (count > 0)) {
480 "LINEAR read-ahead space %lu offset %lu pages %lu\n",
481 (ulong) space, (ulong) offset, (ulong) count);
499 buf_read_ibuf_merge_pages(
506 const ulint* space_ids,
507 const ib_int64_t* space_versions,
514 const ulint* page_nos,
523 ut_ad(!ibuf_inside());
524 #ifdef UNIV_IBUF_DEBUG
525 ut_a(n_stored < UNIV_PAGE_SIZE);
528 for (i = 0; i < n_stored; i++) {
531 ulint zip_size = fil_space_get_zip_size(space_ids[i]);
533 buf_pool =
buf_pool_get(space_ids[i], space_versions[i]);
536 > buf_pool->
curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
540 if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) {
542 goto tablespace_deleted;
545 buf_read_page_low(&err, sync && (i + 1 == n_stored),
547 zip_size, TRUE, space_versions[i],
550 if (UNIV_UNLIKELY(err == DB_TABLESPACE_DELETED)) {
555 ibuf_merge_or_delete_for_page(NULL, space_ids[i],
564 buf_flush_free_margins();
567 if (buf_debug_prints) {
569 "Ibuf merge read-ahead space %lu pages %lu\n",
570 (ulong) space_ids[0], (ulong) n_stored);
589 const ulint* page_nos,
596 ib_int64_t tablespace_version;
601 zip_size = fil_space_get_zip_size(space);
603 if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) {
610 tablespace_version = fil_space_get_version(space);
612 for (i = 0; i < n_stored; i++) {
628 "InnoDB: Error: InnoDB has waited for"
629 " 10 seconds for pending\n"
630 "InnoDB: reads to the buffer pool to"
632 "InnoDB: Number of pending reads %lu,"
633 " pending pread calls %lu\n",
643 if ((i + 1 == n_stored) && sync) {
645 zip_size, TRUE, tablespace_version,
650 space, zip_size, TRUE,
651 tablespace_version, page_nos[i]);
658 buf_flush_free_margins();
661 if (buf_debug_prints) {
663 "Recovery applies read-ahead pages %lu\n",