Skip to content

Commit db915f7

Browse files
committed
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.
1 parent 02e72f7 commit db915f7

File tree

7 files changed

+52
-68
lines changed

7 files changed

+52
-68
lines changed

storage/innobase/buf/buf0dblwr.cc

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,8 @@ bool buf_dblwr_t::flush_buffered_writes(const ulint size)
594594
ut_d(buf_dblwr_check_page_lsn(*bpage, write_buf + len2));
595595
}
596596
#endif /* UNIV_DEBUG */
597-
const IORequest request(nullptr, fil_system.sys_space->chain.start,
598-
IORequest::DBLWR_BATCH);
597+
const IORequest request{nullptr, nullptr, fil_system.sys_space->chain.start,
598+
IORequest::DBLWR_BATCH};
599599
ut_a(fil_system.sys_space->acquire());
600600
if (multi_batch)
601601
{
@@ -614,6 +614,16 @@ bool buf_dblwr_t::flush_buffered_writes(const ulint size)
614614
return true;
615615
}
616616

617+
static void *get_frame(const IORequest &request)
618+
{
619+
if (request.slot)
620+
return request.slot->out_buf;
621+
const buf_page_t *bpage= request.bpage;
622+
return bpage->zip.data
623+
? bpage->zip.data
624+
: reinterpret_cast<const buf_block_t*>(bpage)->frame;
625+
}
626+
617627
void buf_dblwr_t::flush_buffered_writes_completed(const IORequest &request)
618628
{
619629
ut_ad(this == &buf_dblwr);
@@ -651,9 +661,8 @@ void buf_dblwr_t::flush_buffered_writes_completed(const IORequest &request)
651661
buf_page_t* bpage= e.request.bpage;
652662
ut_ad(bpage->in_file());
653663

654-
/* We request frame here to get correct buffer in case of
655-
encryption and/or page compression */
656-
void *frame= buf_page_get_frame(bpage);
664+
void *frame= get_frame(e.request);
665+
ut_ad(frame);
657666

658667
auto e_size= e.size;
659668

@@ -732,13 +741,9 @@ void buf_dblwr_t::add_to_batch(const IORequest &request, size_t size)
732741

733742
byte *p= active_slot->write_buf + srv_page_size * active_slot->first_free;
734743

735-
/* We request frame here to get correct buffer in case of
736-
encryption and/or page compression */
737-
void *frame= buf_page_get_frame(request.bpage);
738-
739744
/* "frame" is at least 1024-byte aligned for ROW_FORMAT=COMPRESSED pages,
740745
and at least srv_page_size (4096-byte) for everything else. */
741-
memcpy_aligned<UNIV_ZIP_SIZE_MIN>(p, frame, size);
746+
memcpy_aligned<UNIV_ZIP_SIZE_MIN>(p, get_frame(request), size);
742747
/* fil_page_compress() for page_compressed guarantees 256-byte alignment */
743748
memset_aligned<256>(p + size, 0, srv_page_size - size);
744749
/* FIXME: Inform the compiler that "size" and "srv_page_size - size"

storage/innobase/buf/buf0flu.cc

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,8 @@ void buf_page_write_complete(const IORequest &request)
353353
}
354354
}
355355

356-
if (bpage->slot)
357-
{
358-
bpage->slot->release();
359-
bpage->slot= nullptr;
360-
}
356+
if (request.slot)
357+
request.slot->release();
361358

362359
if (UNIV_UNLIKELY(MONITOR_IS_ON(MONITOR_MODULE_BUF_PAGE)))
363360
buf_page_monitor(bpage, BUF_IO_WRITE);
@@ -622,10 +619,11 @@ a page is written to disk.
622619
@return page frame to be written to file
623620
(may be src_frame or an encrypted/compressed copy of it) */
624621
static byte *buf_page_encrypt(fil_space_t* space, buf_page_t* bpage, byte* s,
625-
size_t *size)
622+
buf_tmp_buffer_t **slot, size_t *size)
626623
{
627624
ut_ad(bpage->status != buf_page_t::FREED);
628625
ut_ad(space->id == bpage->id().space());
626+
ut_ad(!*slot);
629627

630628
ut_d(fil_page_type_validate(space, s));
631629
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,
681679

682680
ut_ad(!bpage->zip_size() || !page_compressed);
683681
/* Find free slot from temporary memory array */
684-
buf_tmp_buffer_t *slot= buf_pool.io_buf_reserve();
685-
ut_a(slot);
686-
slot->allocate();
687-
slot->out_buf= NULL;
688-
bpage->slot= slot;
682+
*slot= buf_pool.io_buf_reserve();
683+
ut_a(*slot);
684+
(*slot)->allocate();
689685

690-
byte *d= slot->crypt_buf;
686+
byte *d= (*slot)->crypt_buf;
691687

692688
if (!page_compressed)
693689
{
694690
not_compressed:
695-
byte *tmp= space->purpose == FIL_TYPE_TEMPORARY
691+
d= space->purpose == FIL_TYPE_TEMPORARY
696692
? buf_tmp_page_encrypt(page_no, s, d)
697693
: fil_space_encrypt(space, page_no, s, d);
698-
699-
slot->out_buf= d= tmp;
700-
701-
ut_d(fil_page_type_validate(space, tmp));
702694
}
703695
else
704696
{
705697
ut_ad(space->purpose != FIL_TYPE_TEMPORARY);
706698
/* First we compress the page content */
707-
buf_tmp_reserve_compression_buf(slot);
708-
byte *tmp= slot->comp_buf;
699+
buf_tmp_reserve_compression_buf(*slot);
700+
byte *tmp= (*slot)->comp_buf;
709701
ulint len= fil_page_compress(s, tmp, space->flags,
710702
fil_space_get_block_size(space, page_no),
711703
encrypted);
@@ -733,7 +725,7 @@ static byte *buf_page_encrypt(fil_space_t* space, buf_page_t* bpage, byte* s,
733725
ut_d(fil_page_type_validate(space, tmp));
734726

735727
if (encrypted)
736-
tmp = fil_space_encrypt(space, page_no, tmp, d);
728+
tmp= fil_space_encrypt(space, page_no, tmp, d);
737729

738730
if (full_crc32)
739731
{
@@ -742,10 +734,11 @@ static byte *buf_page_encrypt(fil_space_t* space, buf_page_t* bpage, byte* s,
742734
ut_ad(!buf_page_is_corrupted(true, tmp, space->flags));
743735
}
744736

745-
slot->out_buf= d= tmp;
737+
d= tmp;
746738
}
747739

748740
ut_d(fil_page_type_validate(space, d));
741+
(*slot)->out_buf= d;
749742
return d;
750743
}
751744

@@ -860,6 +853,7 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space)
860853
size_t orig_size;
861854
#endif
862855
IORequest::Type type= lru ? IORequest::WRITE_LRU : IORequest::WRITE_ASYNC;
856+
buf_tmp_buffer_t *slot= nullptr;
863857

864858
if (UNIV_UNLIKELY(!rw_lock)) /* ROW_FORMAT=COMPRESSED */
865859
{
@@ -870,7 +864,7 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space)
870864
orig_size= size;
871865
#endif
872866
buf_flush_update_zip_checksum(frame, size);
873-
frame= buf_page_encrypt(space, bpage, frame, &size);
867+
frame= buf_page_encrypt(space, bpage, frame, &slot, &size);
874868
ut_ad(size == bpage->zip_size());
875869
}
876870
else
@@ -886,14 +880,15 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space)
886880
/* innodb_checksum_algorithm=full_crc32 is not implemented for
887881
ROW_FORMAT=COMPRESSED pages. */
888882
ut_ad(!frame);
889-
page= buf_page_encrypt(space, bpage, page, &size);
883+
page= buf_page_encrypt(space, bpage, page, &slot, &size);
890884
buf_flush_init_for_writing(block, page, nullptr, true);
891885
}
892886
else
893887
{
894888
buf_flush_init_for_writing(block, page, frame ? &bpage->zip : nullptr,
895889
false);
896-
page= buf_page_encrypt(space, bpage, frame ? frame : page, &size);
890+
page= buf_page_encrypt(space, bpage, frame ? frame : page,
891+
&slot, &size);
897892
}
898893

899894
#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)
908903
}
909904
}
910905
#endif
911-
frame=page;
906+
frame= page;
912907
}
913908

914909
ut_ad(status == bpage->status);
@@ -925,11 +920,12 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space)
925920
if (lsn > log_sys.get_flushed_lsn())
926921
log_write_up_to(lsn, true);
927922
}
928-
space->io(IORequest(type, bpage),
923+
space->io(IORequest{type, bpage, slot},
929924
bpage->physical_offset(), size, frame, bpage);
930925
}
931926
else
932-
buf_dblwr.add_to_batch(IORequest(bpage, space->chain.start, type), size);
927+
buf_dblwr.add_to_batch(IORequest{bpage, slot, space->chain.start, type},
928+
size);
933929
}
934930

935931
/* Increment the I/O operation count used for selecting LRU policy. */

storage/innobase/fil/fil0fil.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2867,7 +2867,7 @@ fil_io_t fil_space_t::io(const IORequest &type, os_offset_t offset, size_t len,
28672867
goto release_sync_write;
28682868
} else {
28692869
/* Queue the aio request */
2870-
err = os_aio(IORequest(bpage, node, type.type),
2870+
err = os_aio(IORequest{bpage, type.slot, node, type.type},
28712871
buf, offset, len);
28722872
}
28732873

storage/innobase/include/buf0buf.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -663,10 +663,6 @@ class buf_page_t
663663
state == BUF_BLOCK_ZIP_PAGE and
664664
zip.data == NULL means an active
665665
buf_pool.watch */
666-
667-
buf_tmp_buffer_t* slot; /*!< Slot for temporary memory
668-
used for encryption/compression
669-
or NULL */
670666
#ifdef UNIV_DEBUG
671667
/** whether this->list is in buf_pool.zip_hash; protected by buf_pool.mutex */
672668
bool in_zip_hash;
@@ -755,7 +751,6 @@ class buf_page_t
755751
freed_page_clock= 0;
756752
access_time= 0;
757753
oldest_modification_= 0;
758-
slot= nullptr;
759754
ibuf_exist= false;
760755
status= NORMAL;
761756
ut_d(in_zip_hash= false);

storage/innobase/include/buf0buf.ic

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -227,25 +227,6 @@ buf_page_release_latch(
227227
}
228228
}
229229

230-
/********************************************************************//**
231-
Get buf frame. */
232-
UNIV_INLINE
233-
void *
234-
buf_page_get_frame(
235-
/*===============*/
236-
const buf_page_t* bpage) /*!< in: buffer pool page */
237-
{
238-
/* In encryption/compression buffer pool page may contain extra
239-
buffer where result is stored. */
240-
if (bpage->slot && bpage->slot->out_buf) {
241-
return bpage->slot->out_buf;
242-
} else if (bpage->zip.data) {
243-
return bpage->zip.data;
244-
} else {
245-
return ((buf_block_t*) bpage)->frame;
246-
}
247-
}
248-
249230
/** Calculate aligned buffer pool size based on srv_buf_pool_chunk_unit,
250231
if needed.
251232
@param[in] size size in bytes

storage/innobase/include/os0file.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ extern bool os_has_said_disk_full;
5151
/** File offset in bytes */
5252
typedef ib_uint64_t os_offset_t;
5353

54+
class buf_tmp_buffer_t;
55+
5456
#ifdef _WIN32
5557

5658
/** We define always WIN_ASYNC_IO, and check at run-time whether
@@ -206,11 +208,13 @@ class IORequest
206208
PUNCH_RANGE= WRITE_SYNC | 128,
207209
};
208210

209-
constexpr IORequest(buf_page_t *bpage, fil_node_t *node, Type type) :
210-
bpage(bpage), node(node), type(type) {}
211+
constexpr IORequest(buf_page_t *bpage, buf_tmp_buffer_t *slot,
212+
fil_node_t *node, Type type) :
213+
bpage(bpage), slot(slot), node(node), type(type) {}
211214

212-
constexpr IORequest(Type type= READ_SYNC, buf_page_t *bpage= nullptr) :
213-
bpage(bpage), type(type) {}
215+
constexpr IORequest(Type type= READ_SYNC, buf_page_t *bpage= nullptr,
216+
buf_tmp_buffer_t *slot= nullptr) :
217+
bpage(bpage), slot(slot), type(type) {}
214218

215219
bool is_read() const { return (type & READ_SYNC) != 0; }
216220
bool is_write() const { return (type & WRITE_SYNC) != 0; }
@@ -237,7 +241,10 @@ class IORequest
237241

238242
public:
239243
/** Page to be written on write operation */
240-
buf_page_t* const bpage= nullptr;
244+
buf_page_t *const bpage= nullptr;
245+
246+
/** Memory to be used for encrypted or page_compressed pages */
247+
buf_tmp_buffer_t *const slot= nullptr;
241248

242249
/** File descriptor */
243250
fil_node_t *const node= nullptr;

tpool/tpool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ enum class aio_opcode
117117
AIO_PREAD,
118118
AIO_PWRITE
119119
};
120-
constexpr size_t MAX_AIO_USERDATA_LEN= 3 * sizeof(void*);
120+
constexpr size_t MAX_AIO_USERDATA_LEN= 4 * sizeof(void*);
121121

122122
/** IO control block, includes parameters for the IO, and the callback*/
123123

0 commit comments

Comments
 (0)