diff options
Diffstat (limited to 'storage/innobase/buf/buf0flu.cc')
-rw-r--r-- | storage/innobase/buf/buf0flu.cc | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index e15f6e622e0..468fa4bae3e 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -1030,63 +1030,58 @@ static page_id_t buf_flush_check_neighbors(const fil_space_t &space, return i; } -MY_ATTRIBUTE((nonnull, warn_unused_result)) -/** Write punch-hole or zeroes of the freed ranges when -innodb_immediate_scrub_data_uncompressed from the freed ranges. -@param space tablespace which may contain ranges of freed pages -@param writable whether the tablespace is writable +MY_ATTRIBUTE((warn_unused_result)) +/** Apply freed_ranges to the file. +@param writable whether the file is writable @return number of pages written or hole-punched */ -static uint32_t buf_flush_freed_pages(fil_space_t *space, bool writable) +uint32_t fil_space_t::flush_freed(bool writable) { - const bool punch_hole= space->chain.start->punch_hole == 1; + const bool punch_hole= chain.start->punch_hole == 1; if (!punch_hole && !srv_immediate_scrub_data_uncompressed) return 0; mysql_mutex_assert_not_owner(&buf_pool.flush_list_mutex); mysql_mutex_assert_not_owner(&buf_pool.mutex); - space->freed_range_mutex.lock(); - if (space->freed_ranges.empty() || - log_sys.get_flushed_lsn() < space->get_last_freed_lsn()) + freed_range_mutex.lock(); + if (freed_ranges.empty() || log_sys.get_flushed_lsn() < get_last_freed_lsn()) { - space->freed_range_mutex.unlock(); + freed_range_mutex.unlock(); return 0; } - const unsigned physical_size{space->physical_size()}; + const unsigned physical{physical_size()}; - range_set freed_ranges= std::move(space->freed_ranges); + range_set freed= std::move(freed_ranges); uint32_t written= 0; if (!writable); else if (punch_hole) { - for (const auto &range : freed_ranges) + for (const auto &range : freed) { written+= range.last - range.first + 1; - space->reacquire(); - space->io(IORequest(IORequest::PUNCH_RANGE), - os_offset_t{range.first} * physical_size, - (range.last - range.first + 1) * physical_size, - nullptr); + reacquire(); + io(IORequest(IORequest::PUNCH_RANGE), + os_offset_t{range.first} * physical, + (range.last - range.first + 1) * physical, nullptr); } } else { - for (const auto &range : freed_ranges) + for (const auto &range : freed) { written+= range.last - range.first + 1; for (os_offset_t i= range.first; i <= range.last; i++) { - space->reacquire(); - space->io(IORequest(IORequest::WRITE_ASYNC), - i * physical_size, physical_size, - const_cast<byte*>(field_ref_zero)); + reacquire(); + io(IORequest(IORequest::WRITE_ASYNC), i * physical, physical, + const_cast<byte*>(field_ref_zero)); } } } - space->freed_range_mutex.unlock(); + freed_range_mutex.unlock(); return written; } @@ -1214,7 +1209,7 @@ static ulint buf_free_from_unzip_LRU_list_batch(ulint max) static std::pair<fil_space_t*, uint32_t> buf_flush_space(const uint32_t id) { if (fil_space_t *space= fil_space_t::get(id)) - return {space, buf_flush_freed_pages(space, true)}; + return {space, space->flush_freed(true)}; return {nullptr, 0}; } @@ -1596,7 +1591,7 @@ bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed) bool acquired= space->acquire(); { - const uint32_t written{buf_flush_freed_pages(space, acquired)}; + const uint32_t written{space->flush_freed(acquired)}; mysql_mutex_lock(&buf_pool.mutex); if (written) buf_pool.stat.n_pages_written+= written; |