diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-10-26 16:04:12 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-10-26 17:53:54 +0200 |
commit | 118e258aaac5da75a2ac4556201aaea3688fac67 (patch) | |
tree | 9153ac366b4791fd1f9ed515fff770f5974bf8b9 /storage/innobase/buf | |
parent | 45ed9dd957eebc7fc84feb2509f4aa6baa908a95 (diff) | |
download | mariadb-git-118e258aaac5da75a2ac4556201aaea3688fac67.tar.gz |
MDEV-23855: Shrink fil_space_t
Merge n_pending_ios, n_pending_ops to std::atomic<uint32_t> n_pending.
Change some more fil_space_t members to uint32_t to reduce
the memory footprint.
fil_space_t::add(), fil_ibd_create(): Attach the already opened
handle to the tablespace, and enforce the fil_system.n_open limit.
dict_boot(): Initialize fil_system.max_assigned_id.
srv_boot(): Call srv_thread_pool_init() before anything else,
so that files should be opened in the correct mode on Windows.
fil_ibd_create(): Create the file in OS_FILE_AIO mode, just like
fil_node_open_file_low() does it.
dict_table_t::is_accessible(): Replaces fil_table_accessible().
Reviewed by: Vladislav Vaintroub
Diffstat (limited to 'storage/innobase/buf')
-rw-r--r-- | storage/innobase/buf/buf0buf.cc | 25 | ||||
-rw-r--r-- | storage/innobase/buf/buf0dblwr.cc | 16 | ||||
-rw-r--r-- | storage/innobase/buf/buf0dump.cc | 32 | ||||
-rw-r--r-- | storage/innobase/buf/buf0flu.cc | 22 | ||||
-rw-r--r-- | storage/innobase/buf/buf0rea.cc | 43 |
5 files changed, 52 insertions, 86 deletions
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 2046ffd4273..2cdd36a8b60 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -415,7 +415,7 @@ static bool buf_tmp_page_decrypt(byte* tmp_frame, byte* src_frame) static bool buf_page_decrypt_after_read(buf_page_t *bpage, const fil_node_t &node) { - ut_ad(node.space->pending_io()); + ut_ad(node.space->referenced()); ut_ad(node.space->id == bpage->id().space()); const auto flags = node.space->flags; @@ -475,7 +475,7 @@ decompress_with_slot: slot->release(); ut_ad(!write_size || fil_page_type_validate(node.space, dst_frame)); - ut_ad(node.space->pending_io()); + ut_ad(node.space->referenced()); return write_size != 0; } @@ -516,7 +516,7 @@ decrypt_failed: goto decompress; } - ut_ad(node.space->pending_io()); + ut_ad(node.space->referenced()); return true; } #endif /* !UNIV_INNOCHECKSUM */ @@ -2768,7 +2768,7 @@ buf_zip_decompress( ulint size = page_zip_get_size(&block->page.zip); /* The tablespace will not be found if this function is called during IMPORT. */ - fil_space_t* space= fil_space_t::get_for_io(block->page.id().space()); + fil_space_t* space= fil_space_t::get(block->page.id().space()); const unsigned key_version = mach_read_from_4( frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); fil_space_crypt_t* crypt_data = space ? space->crypt_data : NULL; @@ -2805,7 +2805,7 @@ buf_zip_decompress( if (page_zip_decompress(&block->page.zip, block->frame, TRUE)) { if (space) { - space->release_for_io(); + space->release(); } return(TRUE); } @@ -2824,7 +2824,7 @@ buf_zip_decompress( /* Copy to uncompressed storage. */ memcpy(block->frame, frame, block->zip_size()); if (space) { - space->release_for_io(); + space->release(); } return(TRUE); @@ -2848,7 +2848,7 @@ err_exit: dict_set_corrupted_by_space(space); } - space->release_for_io(); + space->release(); } return(FALSE); @@ -3160,10 +3160,10 @@ lookup: asserting. */ if (page_id.space() == TRX_SYS_SPACE) { } else if (page_id.space() == SRV_TMP_SPACE_ID) { - } else if (fil_space_t* space= fil_space_t::get_for_io( + } else if (fil_space_t* space= fil_space_t::get( page_id.space())) { bool set = dict_set_corrupted_by_space(space); - space->release_for_io(); + space->release(); if (set) { return NULL; } @@ -3374,8 +3374,7 @@ re_evict: if (mode != BUF_GET_IF_IN_POOL && mode != BUF_GET_IF_IN_POOL_OR_WATCH) { } else if (!ibuf_debug) { - } else if (fil_space_t* space - = fil_space_t::get_for_io(page_id.space())) { + } else if (fil_space_t* space = fil_space_t::get(page_id.space())) { /* Try to evict the block from the buffer pool, to use the insert buffer (change buffer) as much as possible. */ @@ -3386,7 +3385,7 @@ re_evict: /* Blocks cannot be relocated or enter or exit the buf_pool while we are holding the buf_pool.mutex. */ const bool evicted = buf_LRU_free_page(&fix_block->page, true); - space->release_for_io(); + space->release(); if (evicted) { hash_lock = buf_pool.page_hash.lock_get(fold); @@ -4108,7 +4107,7 @@ after decryption normal page checksum does not match. static dberr_t buf_page_check_corrupt(buf_page_t *bpage, const fil_node_t &node) { - ut_ad(node.space->pending_io()); + ut_ad(node.space->referenced()); byte* dst_frame = (bpage->zip.data) ? bpage->zip.data : ((buf_block_t*) bpage)->frame; diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 6b1a32d8930..eb460af2de2 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -363,7 +363,7 @@ void buf_dblwr_t::recover() continue; } - fil_space_t *space= fil_space_t::get_for_io(space_id); + fil_space_t *space= fil_space_t::get(space_id); if (!space) /* The tablespace that this page once belonged to does not exist */ @@ -379,7 +379,7 @@ void buf_dblwr_t::recover() << " is beyond the end of tablespace " << space->name << " (" << space->size << " pages)"; next_page: - space->release_for_io(); + space->release(); continue; } @@ -420,7 +420,7 @@ next_page: /* Write the good page from the doublewrite buffer to the intended position. */ - space->reacquire_for_io(); + space->reacquire(); fio= space->io(IORequestWrite, os_offset_t{page_id.page_no()} * physical_size, physical_size, page); @@ -506,10 +506,10 @@ static void buf_dblwr_check_page_lsn(const page_t* page, const fil_space_t& s) static void buf_dblwr_check_page_lsn(const buf_page_t &b, const byte *page) { - if (fil_space_t *space= fil_space_t::get_for_io(b.id().space())) + if (fil_space_t *space= fil_space_t::get(b.id().space())) { buf_dblwr_check_page_lsn(page, *space); - space->release_for_io(); + space->release(); } } @@ -583,7 +583,7 @@ bool buf_dblwr_t::flush_buffered_writes(const ulint size) } #endif /* UNIV_DEBUG */ /* Write out the first block of the doublewrite buffer */ - ut_a(fil_system.sys_space->acquire_for_io()); + ut_a(fil_system.sys_space->acquire()); fil_system.sys_space->io(IORequestWrite, os_offset_t{block1.page_no()} << srv_page_size_shift, @@ -593,7 +593,7 @@ bool buf_dblwr_t::flush_buffered_writes(const ulint size) if (old_first_free > size) { /* Write out the second block of the doublewrite buffer. */ - ut_a(fil_system.sys_space->acquire_for_io()); + ut_a(fil_system.sys_space->acquire()); fil_system.sys_space->io(IORequestWrite, os_offset_t{block2.page_no()} << srv_page_size_shift, @@ -687,7 +687,7 @@ void buf_dblwr_t::add_to_batch(fil_space_t *space, const IORequest &request, ut_ad(request.bpage); ut_ad(request.bpage->in_file()); ut_ad(space->id == request.bpage->id().space()); - ut_ad(space->pending_io()); + ut_ad(space->referenced()); ut_ad(!srv_read_only_mode); const ulint buf_size= 2 * block_size(); diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index 19a9e09e4a1..c62c0112e92 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -621,19 +621,11 @@ buf_load() ulint last_check_time = 0; ulint last_activity_cnt = 0; - /* Avoid calling the expensive fil_space_acquire_silent() for each + /* Avoid calling the expensive fil_space_t::get() for each page within the same tablespace. dump[] is sorted by (space, page), so all pages from a given tablespace are consecutive. */ ulint cur_space_id = dump[0].space(); - fil_space_t* space = fil_space_acquire_silent(cur_space_id); - if (space) { - bool ok = space->acquire_for_io(); - space->release(); - if (!ok) { - space = nullptr; - } - } - + fil_space_t* space = fil_space_t::get(cur_space_id); ulint zip_size = space ? space->zip_size() : 0; PSI_stage_progress* pfs_stage_progress __attribute__((unused)) @@ -653,24 +645,16 @@ buf_load() if (this_space_id != cur_space_id) { if (space) { - space->release_for_io(); + space->release(); } cur_space_id = this_space_id; - space = fil_space_acquire_silent(cur_space_id); + space = fil_space_t::get(cur_space_id); if (!space) { continue; } - bool ok = space->acquire_for_io(); - space->release(); - - if (!ok) { - space = nullptr; - continue; - } - zip_size = space->zip_size(); } @@ -684,17 +668,17 @@ buf_load() } if (space->is_stopping()) { - space->release_for_io(); + space->release(); space = nullptr; continue; } - space->reacquire_for_io(); + space->reacquire(); buf_read_page_background(space, dump[i], zip_size, true); if (buf_load_abort_flag) { if (space) { - space->release_for_io(); + space->release(); } buf_load_abort_flag = false; ut_free(dump); @@ -722,7 +706,7 @@ buf_load() } if (space) { - space->release_for_io(); + space->release(); } ut_free(dump); diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 25523ab53f1..f671aadeb4e 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -786,7 +786,7 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) (space == fil_system.temp_space)); ut_ad(space->purpose == FIL_TYPE_TABLESPACE || space->atomic_write_supported); - ut_ad(space->pending_io()); + ut_ad(space->referenced()); rw_lock_t *rw_lock; @@ -854,7 +854,7 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) buf_release_freed_page(&block->page); else { - space->reacquire_for_io(); + space->reacquire(); ut_ad(status == buf_page_t::NORMAL || status == buf_page_t::INIT_ON_FLUSH); size_t size, orig_size; IORequest::Type type= lru ? IORequest::WRITE_LRU : IORequest::WRITE_ASYNC; @@ -1029,7 +1029,7 @@ static void buf_flush_freed_pages(fil_space_t *space) if (punch_hole) { - space->reacquire_for_io(); + space->reacquire(); space->io(IORequest(IORequest::PUNCH_RANGE), os_offset_t{range.first} * physical_size, (range.last - range.first + 1) * physical_size, @@ -1039,7 +1039,7 @@ static void buf_flush_freed_pages(fil_space_t *space) { for (os_offset_t i= range.first; i <= range.last; i++) { - space->reacquire_for_io(); + space->reacquire(); space->io(IORequest(IORequest::WRITE_ASYNC), i * physical_size, physical_size, const_cast<byte*>(field_ref_zero)); @@ -1170,7 +1170,7 @@ static ulint buf_free_from_unzip_LRU_list_batch(ulint max) @retval nullptr if the pages for this tablespace should be discarded */ static fil_space_t *buf_flush_space(const uint32_t id) { - fil_space_t *space= fil_space_t::get_for_io(id); + fil_space_t *space= fil_space_t::get(id); if (space) buf_flush_freed_pages(space); return space; @@ -1261,7 +1261,7 @@ static void buf_flush_LRU_list_batch(ulint max, flush_counters_t *n) if (last_space_id != space_id) { if (space) - space->release_for_io(); + space->release(); space= buf_flush_space(space_id); last_space_id= space_id; } @@ -1270,7 +1270,7 @@ static void buf_flush_LRU_list_batch(ulint max, flush_counters_t *n) } else if (space->is_stopping()) { - space->release_for_io(); + space->release(); space= nullptr; } @@ -1298,7 +1298,7 @@ reacquire_mutex: buf_pool.lru_hp.set(nullptr); if (space) - space->release_for_io(); + space->release(); /* We keep track of all flushes happening as part of LRU flush. When estimating the desired rate at which flush_list should be flushed, @@ -1393,7 +1393,7 @@ static ulint buf_do_flush_list_batch(ulint max_n, lsn_t lsn) if (last_space_id != space_id) { if (space) - space->release_for_io(); + space->release(); space= buf_flush_space(space_id); last_space_id= space_id; } @@ -1402,7 +1402,7 @@ static ulint buf_do_flush_list_batch(ulint max_n, lsn_t lsn) } else if (space->is_stopping()) { - space->release_for_io(); + space->release(); space= nullptr; } @@ -1431,7 +1431,7 @@ reacquire_mutex: mysql_mutex_unlock(&buf_pool.flush_list_mutex); if (space) - space->release_for_io(); + space->release(); if (scanned) MONITOR_INC_VALUE_CUMULATIVE(MONITOR_FLUSH_BATCH_SCANNED, diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index daea53ec130..2f59f1ae4d5 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -288,7 +288,7 @@ buf_read_page_low( << page_id; ut_ad(0); nothing_read: - space->release_for_io(); + space->release(); return false; } @@ -358,7 +358,7 @@ nothing_read: /* The i/o was already completed in space->io() */ *err = buf_page_read_complete(bpage, *fio.node); - space->release_for_io(); + space->release(); if (*err != DB_SUCCESS) { return false; @@ -402,7 +402,7 @@ buf_read_ahead_random(const page_id_t page_id, ulint zip_size, bool ibuf) if (buf_pool.n_pend_reads > buf_pool.curr_size / BUF_READ_AHEAD_PEND_LIMIT) return 0; - fil_space_t* space= fil_space_acquire(page_id.space()); + fil_space_t* space= fil_space_t::get(page_id.space()); if (!space) return 0; @@ -431,7 +431,7 @@ no_read_ahead: return 0; read_ahead: - if (!space->acquire_for_io()) + if (!space->acquire_if_not_stopped()) goto no_read_ahead; /* Read all the suitable blocks within the area */ @@ -444,7 +444,7 @@ read_ahead: if (space->is_stopping()) break; dberr_t err; - space->reacquire_for_io(); + space->reacquire(); if (buf_read_page_low(&err, space, false, ibuf_mode, i, zip_size, false)) count++; } @@ -453,7 +453,6 @@ read_ahead: DBUG_PRINT("ib_buf", ("random read-ahead %zu pages from %s: %u", count, space->chain.start->name, low.page_no())); - space->release_for_io(); space->release(); /* Read ahead is considered one I/O operation for the purpose of @@ -478,22 +477,13 @@ after decryption normal page checksum does not match. @retval DB_TABLESPACE_DELETED if tablespace .ibd file is missing */ dberr_t buf_read_page(const page_id_t page_id, ulint zip_size) { - fil_space_t *space= fil_space_acquire(page_id.space()); + fil_space_t *space= fil_space_t::get(page_id.space()); if (!space) { ib::info() << "trying to read page " << page_id << " in nonexisting or being-dropped tablespace"; return DB_TABLESPACE_DELETED; } - else if (!space->acquire_for_io()) - { - ib::warn() << "unable to read " << page_id << " from tablespace " - << space->name; - space->release(); - return DB_PAGE_CORRUPTED; - } - - space->release(); dberr_t err; if (buf_read_page_low(&err, space, true, BUF_READ_ANY_PAGE, @@ -607,22 +597,15 @@ buf_read_ahead_linear(const page_id_t page_id, ulint zip_size, bool ibuf) read-ahead, as that could break the ibuf page access order */ return 0; - fil_space_t *space= fil_space_acquire(page_id.space()); + fil_space_t *space= fil_space_t::get(page_id.space()); if (!space) return 0; - else - { - bool ok= space->acquire_for_io(); - space->release(); - if (!ok) - return 0; - } if (high_1.page_no() > space->last_page_number()) { /* The area is not whole. */ fail: - space->release_for_io(); + space->release(); return 0; } @@ -721,7 +704,7 @@ failed: if (space->is_stopping()) break; dberr_t err; - space->reacquire_for_io(); + space->reacquire(); count+= buf_read_page_low(&err, space, false, ibuf_mode, new_low, zip_size, false); } @@ -730,7 +713,7 @@ failed: DBUG_PRINT("ib_buf", ("random read-ahead %zu pages from %s: %u", count, space->chain.start->name, new_low.page_no())); - space->release_for_io(); + space->release(); /* Read ahead is considered one I/O operation for the purpose of LRU policy decision. */ @@ -747,7 +730,7 @@ highest page number the last in the array @param[in] n number of page numbers in the array */ void buf_read_recv_pages(ulint space_id, const uint32_t* page_nos, ulint n) { - fil_space_t* space = fil_space_t::get_for_io(space_id); + fil_space_t* space = fil_space_t::get(space_id); if (!space) { /* The tablespace is missing or unreadable: do nothing */ @@ -784,7 +767,7 @@ void buf_read_recv_pages(ulint space_id, const uint32_t* page_nos, ulint n) } dberr_t err; - space->reacquire_for_io(); + space->reacquire(); buf_read_page_low(&err, space, false, BUF_READ_ANY_PAGE, cur_page_id, zip_size, true); @@ -798,5 +781,5 @@ void buf_read_recv_pages(ulint space_id, const uint32_t* page_nos, ulint n) DBUG_PRINT("ib_buf", ("recovery read (%u pages) for %s", n, space->chain.start->name)); - space->release_for_io(); + space->release(); } |