diff options
Diffstat (limited to 'storage/xtradb/buf/buf0rea.cc')
-rw-r--r-- | storage/xtradb/buf/buf0rea.cc | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/storage/xtradb/buf/buf0rea.cc b/storage/xtradb/buf/buf0rea.cc index 1ef9162cab9..a962b94c0c2 100644 --- a/storage/xtradb/buf/buf0rea.cc +++ b/storage/xtradb/buf/buf0rea.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2018, MariaDB Corporation. +Copyright (c) 2013, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -344,19 +344,22 @@ buf_read_ahead_random( return(0); } - /* Remember the tablespace version before we ask te tablespace size - below: if DISCARD + IMPORT changes the actual .ibd file meanwhile, we - do not try to read outside the bounds of the tablespace! */ + if (fil_space_t *s = fil_space_acquire_for_io(space)) { + /* Remember the tablespace version along with the + tablespace size: if DISCARD + IMPORT changes the + actual .ibd file meanwhile, we do not try to read + outside the bounds of the tablespace! */ + tablespace_version = s->tablespace_version; - tablespace_version = fil_space_get_version(space); - - low = (offset / buf_read_ahead_random_area) - * buf_read_ahead_random_area; - high = (offset / buf_read_ahead_random_area + 1) - * buf_read_ahead_random_area; - if (high > fil_space_get_size(space)) { + low = (offset / buf_read_ahead_random_area) + * buf_read_ahead_random_area; + high = (offset / buf_read_ahead_random_area + 1) + * buf_read_ahead_random_area; + high = s->max_page_number_for_io(high); - high = fil_space_get_size(space); + fil_space_release_for_io(s); + } else { + return 0; } if (buf_pool->n_pend_reads @@ -495,22 +498,16 @@ buf_read_page( ulint offset, trx_t* trx) { - ib_int64_t tablespace_version; - ulint count; dberr_t err = DB_SUCCESS; - tablespace_version = fil_space_get_version(space_id); - FilSpace space(space_id, true); if (space()) { - - /* We do the i/o in the synchronous aio mode to save thread - switches: hence TRUE */ - count = buf_read_page_low(&err, true, BUF_READ_ANY_PAGE, space_id, - zip_size, FALSE, - tablespace_version, offset, trx); - + ulint count = buf_read_page_low(&err, /*sync=*/true, + BUF_READ_ANY_PAGE, + space_id, zip_size, FALSE, + space()->tablespace_version, + offset, trx); srv_stats.buf_pool_reads.add(count); } @@ -683,13 +680,23 @@ buf_read_ahead_linear( return(0); } - /* Remember the tablespace version before we ask te tablespace size - below: if DISCARD + IMPORT changes the actual .ibd file meanwhile, we - do not try to read outside the bounds of the tablespace! */ + uint32_t space_high_limit = 0; - tablespace_version = fil_space_get_version(space); + if (fil_space_t *s = fil_space_acquire_for_io(space)) { + /* Remember the tablespace version along with the + tablespace size: if DISCARD + IMPORT changes the + actual .ibd file meanwhile, we do not try to read + outside the bounds of the tablespace! */ + tablespace_version = s->tablespace_version; + + space_high_limit = s->max_page_number_for_io(ULINT_UNDEFINED); + + fil_space_release_for_io(s); + } else { + return 0; + } - if (high > fil_space_get_size(space)) { + if (high > space_high_limit) { /* The area is not whole, return */ return(0); @@ -825,7 +832,7 @@ buf_read_ahead_linear( return(0); } - if (high > fil_space_get_size(space)) { + if (high > space_high_limit) { /* The area is not whole, return */ return(0); |