|
1 | 1 | /*****************************************************************************
|
2 | 2 |
|
3 | 3 | Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved.
|
4 |
| -Copyright (c) 2015, 2017, MariaDB Corporation. |
| 4 | +Copyright (c) 2015, 2020, MariaDB Corporation. |
5 | 5 |
|
6 | 6 | This program is free software; you can redistribute it and/or modify it under
|
7 | 7 | the terms of the GNU General Public License as published by the Free Software
|
@@ -292,19 +292,22 @@ buf_read_ahead_random(
|
292 | 292 | return(0);
|
293 | 293 | }
|
294 | 294 |
|
295 |
| - /* Remember the tablespace version before we ask te tablespace size |
296 |
| - below: if DISCARD + IMPORT changes the actual .ibd file meanwhile, we |
297 |
| - do not try to read outside the bounds of the tablespace! */ |
| 295 | + if (fil_space_t *s = fil_space_acquire_for_io(space)) { |
| 296 | + /* Remember the tablespace version along with the |
| 297 | + tablespace size: if DISCARD + IMPORT changes the |
| 298 | + actual .ibd file meanwhile, we do not try to read |
| 299 | + outside the bounds of the tablespace! */ |
| 300 | + tablespace_version = s->tablespace_version; |
298 | 301 |
|
299 |
| - tablespace_version = fil_space_get_version(space); |
300 |
| - |
301 |
| - low = (offset / buf_read_ahead_random_area) |
302 |
| - * buf_read_ahead_random_area; |
303 |
| - high = (offset / buf_read_ahead_random_area + 1) |
304 |
| - * buf_read_ahead_random_area; |
305 |
| - if (high > fil_space_get_size(space)) { |
| 302 | + low = (offset / buf_read_ahead_random_area) |
| 303 | + * buf_read_ahead_random_area; |
| 304 | + high = (offset / buf_read_ahead_random_area + 1) |
| 305 | + * buf_read_ahead_random_area; |
| 306 | + high = s->max_page_number_for_io(high); |
306 | 307 |
|
307 |
| - high = fil_space_get_size(space); |
| 308 | + fil_space_release_for_io(s); |
| 309 | + } else { |
| 310 | + return 0; |
308 | 311 | }
|
309 | 312 |
|
310 | 313 | buf_pool_mutex_enter(buf_pool);
|
@@ -435,22 +438,16 @@ buf_read_page(
|
435 | 438 | ulint zip_size,
|
436 | 439 | ulint offset)
|
437 | 440 | {
|
438 |
| - ib_int64_t tablespace_version; |
439 |
| - ulint count; |
440 | 441 | dberr_t err = DB_SUCCESS;
|
441 | 442 |
|
442 |
| - tablespace_version = fil_space_get_version(space_id); |
443 |
| - |
444 | 443 | FilSpace space(space_id, true);
|
445 | 444 |
|
446 | 445 | if (space()) {
|
447 |
| - |
448 |
| - /* We do the i/o in the synchronous aio mode to save thread |
449 |
| - switches: hence TRUE */ |
450 |
| - count = buf_read_page_low(&err, true, BUF_READ_ANY_PAGE, space_id, |
451 |
| - zip_size, FALSE, |
452 |
| - tablespace_version, offset); |
453 |
| - |
| 446 | + ulint count = buf_read_page_low(&err, /*sync=*/true, |
| 447 | + BUF_READ_ANY_PAGE, |
| 448 | + space_id, zip_size, FALSE, |
| 449 | + space()->tablespace_version, |
| 450 | + offset); |
454 | 451 | srv_stats.buf_pool_reads.add(count);
|
455 | 452 | }
|
456 | 453 |
|
@@ -619,21 +616,30 @@ buf_read_ahead_linear(
|
619 | 616 | return(0);
|
620 | 617 | }
|
621 | 618 |
|
622 |
| - /* Remember the tablespace version before we ask te tablespace size |
623 |
| - below: if DISCARD + IMPORT changes the actual .ibd file meanwhile, we |
624 |
| - do not try to read outside the bounds of the tablespace! */ |
| 619 | + uint32_t space_high_limit = 0; |
625 | 620 |
|
626 |
| - tablespace_version = fil_space_get_version(space); |
| 621 | + if (fil_space_t *s = fil_space_acquire_for_io(space)) { |
| 622 | + /* Remember the tablespace version along with the |
| 623 | + tablespace size: if DISCARD + IMPORT changes the |
| 624 | + actual .ibd file meanwhile, we do not try to read |
| 625 | + outside the bounds of the tablespace! */ |
| 626 | + tablespace_version = s->tablespace_version; |
627 | 627 |
|
628 |
| - buf_pool_mutex_enter(buf_pool); |
| 628 | + space_high_limit = s->max_page_number_for_io(ULINT_UNDEFINED); |
629 | 629 |
|
630 |
| - if (high > fil_space_get_size(space)) { |
631 |
| - buf_pool_mutex_exit(buf_pool); |
| 630 | + fil_space_release_for_io(s); |
| 631 | + } else { |
| 632 | + return 0; |
| 633 | + } |
| 634 | + |
| 635 | + if (high > space_high_limit) { |
632 | 636 | /* The area is not whole, return */
|
633 | 637 |
|
634 | 638 | return(0);
|
635 | 639 | }
|
636 | 640 |
|
| 641 | + buf_pool_mutex_enter(buf_pool); |
| 642 | + |
637 | 643 | if (buf_pool->n_pend_reads
|
638 | 644 | > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
|
639 | 645 | buf_pool_mutex_exit(buf_pool);
|
@@ -754,7 +760,7 @@ buf_read_ahead_linear(
|
754 | 760 | return(0);
|
755 | 761 | }
|
756 | 762 |
|
757 |
| - if (high > fil_space_get_size(space)) { |
| 763 | + if (high > space_high_limit) { |
758 | 764 | /* The area is not whole, return */
|
759 | 765 |
|
760 | 766 | return(0);
|
|
0 commit comments