diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-11-16 18:16:53 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-11-18 17:44:33 +0200 |
commit | db915f738709a1988420e73522f5a3e6515d17e9 (patch) | |
tree | e02230e638bd7682a4ee64d7fec6e4601184aa20 /storage/innobase | |
parent | 02e72f7b44499ddfdae434b51cc4148e321147d7 (diff) | |
download | mariadb-git-db915f738709a1988420e73522f5a3e6515d17e9.tar.gz |
MDEV-27058: Move buf_page_t::slot to IORequest::slot
MDEV-23855 and MDEV-23399 already moved some transient data fields
from buffer pool page descriptors to IORequest, but the write buffer
of PAGE_COMPRESSED or ENCRYPTED tables was missed. Since is only needed
during asynchronous page write requests, it belongs to IORequest.
Diffstat (limited to 'storage/innobase')
-rw-r--r-- | storage/innobase/buf/buf0dblwr.cc | 25 | ||||
-rw-r--r-- | storage/innobase/buf/buf0flu.cc | 50 | ||||
-rw-r--r-- | storage/innobase/fil/fil0fil.cc | 2 | ||||
-rw-r--r-- | storage/innobase/include/buf0buf.h | 5 | ||||
-rw-r--r-- | storage/innobase/include/buf0buf.ic | 19 | ||||
-rw-r--r-- | storage/innobase/include/os0file.h | 17 |
6 files changed, 51 insertions, 67 deletions
diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 447fba38323..b8371864e16 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -594,8 +594,8 @@ bool buf_dblwr_t::flush_buffered_writes(const ulint size) ut_d(buf_dblwr_check_page_lsn(*bpage, write_buf + len2)); } #endif /* UNIV_DEBUG */ - const IORequest request(nullptr, fil_system.sys_space->chain.start, - IORequest::DBLWR_BATCH); + const IORequest request{nullptr, nullptr, fil_system.sys_space->chain.start, + IORequest::DBLWR_BATCH}; ut_a(fil_system.sys_space->acquire()); if (multi_batch) { @@ -614,6 +614,16 @@ bool buf_dblwr_t::flush_buffered_writes(const ulint size) return true; } +static void *get_frame(const IORequest &request) +{ + if (request.slot) + return request.slot->out_buf; + const buf_page_t *bpage= request.bpage; + return bpage->zip.data + ? bpage->zip.data + : reinterpret_cast<const buf_block_t*>(bpage)->frame; +} + void buf_dblwr_t::flush_buffered_writes_completed(const IORequest &request) { ut_ad(this == &buf_dblwr); @@ -651,9 +661,8 @@ void buf_dblwr_t::flush_buffered_writes_completed(const IORequest &request) buf_page_t* bpage= e.request.bpage; ut_ad(bpage->in_file()); - /* We request frame here to get correct buffer in case of - encryption and/or page compression */ - void *frame= buf_page_get_frame(bpage); + void *frame= get_frame(e.request); + ut_ad(frame); auto e_size= e.size; @@ -732,13 +741,9 @@ void buf_dblwr_t::add_to_batch(const IORequest &request, size_t size) byte *p= active_slot->write_buf + srv_page_size * active_slot->first_free; - /* We request frame here to get correct buffer in case of - encryption and/or page compression */ - void *frame= buf_page_get_frame(request.bpage); - /* "frame" is at least 1024-byte aligned for ROW_FORMAT=COMPRESSED pages, and at least srv_page_size (4096-byte) for everything else. */ - memcpy_aligned<UNIV_ZIP_SIZE_MIN>(p, frame, size); + memcpy_aligned<UNIV_ZIP_SIZE_MIN>(p, get_frame(request), size); /* fil_page_compress() for page_compressed guarantees 256-byte alignment */ memset_aligned<256>(p + size, 0, srv_page_size - size); /* FIXME: Inform the compiler that "size" and "srv_page_size - size" diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 725f18ec25f..2fd60a79602 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -353,11 +353,8 @@ void buf_page_write_complete(const IORequest &request) } } - if (bpage->slot) - { - bpage->slot->release(); - bpage->slot= nullptr; - } + if (request.slot) + request.slot->release(); if (UNIV_UNLIKELY(MONITOR_IS_ON(MONITOR_MODULE_BUF_PAGE))) buf_page_monitor(bpage, BUF_IO_WRITE); @@ -622,10 +619,11 @@ a page is written to disk. @return page frame to be written to file (may be src_frame or an encrypted/compressed copy of it) */ static byte *buf_page_encrypt(fil_space_t* space, buf_page_t* bpage, byte* s, - size_t *size) + buf_tmp_buffer_t **slot, size_t *size) { ut_ad(bpage->status != buf_page_t::FREED); ut_ad(space->id == bpage->id().space()); + ut_ad(!*slot); ut_d(fil_page_type_validate(space, s)); const uint32_t page_no= bpage->id().page_no(); @@ -681,31 +679,25 @@ static byte *buf_page_encrypt(fil_space_t* space, buf_page_t* bpage, byte* s, ut_ad(!bpage->zip_size() || !page_compressed); /* Find free slot from temporary memory array */ - buf_tmp_buffer_t *slot= buf_pool.io_buf_reserve(); - ut_a(slot); - slot->allocate(); - slot->out_buf= NULL; - bpage->slot= slot; + *slot= buf_pool.io_buf_reserve(); + ut_a(*slot); + (*slot)->allocate(); - byte *d= slot->crypt_buf; + byte *d= (*slot)->crypt_buf; if (!page_compressed) { not_compressed: - byte *tmp= space->purpose == FIL_TYPE_TEMPORARY + d= space->purpose == FIL_TYPE_TEMPORARY ? buf_tmp_page_encrypt(page_no, s, d) : fil_space_encrypt(space, page_no, s, d); - - slot->out_buf= d= tmp; - - ut_d(fil_page_type_validate(space, tmp)); } else { ut_ad(space->purpose != FIL_TYPE_TEMPORARY); /* First we compress the page content */ - buf_tmp_reserve_compression_buf(slot); - byte *tmp= slot->comp_buf; + buf_tmp_reserve_compression_buf(*slot); + byte *tmp= (*slot)->comp_buf; ulint len= fil_page_compress(s, tmp, space->flags, fil_space_get_block_size(space, page_no), encrypted); @@ -733,7 +725,7 @@ not_compressed: ut_d(fil_page_type_validate(space, tmp)); if (encrypted) - tmp = fil_space_encrypt(space, page_no, tmp, d); + tmp= fil_space_encrypt(space, page_no, tmp, d); if (full_crc32) { @@ -742,10 +734,11 @@ not_compressed: ut_ad(!buf_page_is_corrupted(true, tmp, space->flags)); } - slot->out_buf= d= tmp; + d= tmp; } ut_d(fil_page_type_validate(space, d)); + (*slot)->out_buf= d; return d; } @@ -860,6 +853,7 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) size_t orig_size; #endif IORequest::Type type= lru ? IORequest::WRITE_LRU : IORequest::WRITE_ASYNC; + buf_tmp_buffer_t *slot= nullptr; if (UNIV_UNLIKELY(!rw_lock)) /* ROW_FORMAT=COMPRESSED */ { @@ -870,7 +864,7 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) orig_size= size; #endif buf_flush_update_zip_checksum(frame, size); - frame= buf_page_encrypt(space, bpage, frame, &size); + frame= buf_page_encrypt(space, bpage, frame, &slot, &size); ut_ad(size == bpage->zip_size()); } else @@ -886,14 +880,15 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) /* innodb_checksum_algorithm=full_crc32 is not implemented for ROW_FORMAT=COMPRESSED pages. */ ut_ad(!frame); - page= buf_page_encrypt(space, bpage, page, &size); + page= buf_page_encrypt(space, bpage, page, &slot, &size); buf_flush_init_for_writing(block, page, nullptr, true); } else { buf_flush_init_for_writing(block, page, frame ? &bpage->zip : nullptr, false); - page= buf_page_encrypt(space, bpage, frame ? frame : page, &size); + page= buf_page_encrypt(space, bpage, frame ? frame : page, + &slot, &size); } #if defined HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE || defined _WIN32 @@ -908,7 +903,7 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) } } #endif - frame=page; + frame= page; } ut_ad(status == bpage->status); @@ -925,11 +920,12 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) if (lsn > log_sys.get_flushed_lsn()) log_write_up_to(lsn, true); } - space->io(IORequest(type, bpage), + space->io(IORequest{type, bpage, slot}, bpage->physical_offset(), size, frame, bpage); } else - buf_dblwr.add_to_batch(IORequest(bpage, space->chain.start, type), size); + buf_dblwr.add_to_batch(IORequest{bpage, slot, space->chain.start, type}, + size); } /* Increment the I/O operation count used for selecting LRU policy. */ diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index adb4bdef1c5..32bafb14684 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -2867,7 +2867,7 @@ fail: goto release_sync_write; } else { /* Queue the aio request */ - err = os_aio(IORequest(bpage, node, type.type), + err = os_aio(IORequest{bpage, type.slot, node, type.type}, buf, offset, len); } diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index ad06b17466d..fce5702c171 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -663,10 +663,6 @@ public: state == BUF_BLOCK_ZIP_PAGE and zip.data == NULL means an active buf_pool.watch */ - - buf_tmp_buffer_t* slot; /*!< Slot for temporary memory - used for encryption/compression - or NULL */ #ifdef UNIV_DEBUG /** whether this->list is in buf_pool.zip_hash; protected by buf_pool.mutex */ bool in_zip_hash; @@ -755,7 +751,6 @@ public: freed_page_clock= 0; access_time= 0; oldest_modification_= 0; - slot= nullptr; ibuf_exist= false; status= NORMAL; ut_d(in_zip_hash= false); diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic index 30fd0b2b1f9..bdca5b66392 100644 --- a/storage/innobase/include/buf0buf.ic +++ b/storage/innobase/include/buf0buf.ic @@ -227,25 +227,6 @@ buf_page_release_latch( } } -/********************************************************************//** -Get buf frame. */ -UNIV_INLINE -void * -buf_page_get_frame( -/*===============*/ - const buf_page_t* bpage) /*!< in: buffer pool page */ -{ - /* In encryption/compression buffer pool page may contain extra - buffer where result is stored. */ - if (bpage->slot && bpage->slot->out_buf) { - return bpage->slot->out_buf; - } else if (bpage->zip.data) { - return bpage->zip.data; - } else { - return ((buf_block_t*) bpage)->frame; - } -} - /** Calculate aligned buffer pool size based on srv_buf_pool_chunk_unit, if needed. @param[in] size size in bytes diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index 7e190b340de..17680f9b3dc 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -51,6 +51,8 @@ extern bool os_has_said_disk_full; /** File offset in bytes */ typedef ib_uint64_t os_offset_t; +class buf_tmp_buffer_t; + #ifdef _WIN32 /** We define always WIN_ASYNC_IO, and check at run-time whether @@ -206,11 +208,13 @@ public: PUNCH_RANGE= WRITE_SYNC | 128, }; - constexpr IORequest(buf_page_t *bpage, fil_node_t *node, Type type) : - bpage(bpage), node(node), type(type) {} + constexpr IORequest(buf_page_t *bpage, buf_tmp_buffer_t *slot, + fil_node_t *node, Type type) : + bpage(bpage), slot(slot), node(node), type(type) {} - constexpr IORequest(Type type= READ_SYNC, buf_page_t *bpage= nullptr) : - bpage(bpage), type(type) {} + constexpr IORequest(Type type= READ_SYNC, buf_page_t *bpage= nullptr, + buf_tmp_buffer_t *slot= nullptr) : + bpage(bpage), slot(slot), type(type) {} bool is_read() const { return (type & READ_SYNC) != 0; } bool is_write() const { return (type & WRITE_SYNC) != 0; } @@ -237,7 +241,10 @@ private: public: /** Page to be written on write operation */ - buf_page_t* const bpage= nullptr; + buf_page_t *const bpage= nullptr; + + /** Memory to be used for encrypted or page_compressed pages */ + buf_tmp_buffer_t *const slot= nullptr; /** File descriptor */ fil_node_t *const node= nullptr; |