Commit 1dffa9d9 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-17441: Rename buf_pool_t::io_buf from buf_pool->tmp_arr

Make buf_pool_t::io_buf_t() a more proper class.

buf_pool_t::io_buf_t::io_buf_t(): Silence the GCC 8 -Wclass-memaccess
warning for initializing slots[], which no longer is a plain old datatype
(POD) due to the std::atomic member.
parent a9c23066
...@@ -121,6 +121,7 @@ struct set_numa_interleave_t ...@@ -121,6 +121,7 @@ struct set_numa_interleave_t
#include "snappy-c.h" #include "snappy-c.h"
#endif #endif
#ifndef UNIV_INNOCHECKSUM
inline void* aligned_malloc(size_t size, size_t align) { inline void* aligned_malloc(size_t size, size_t align) {
void *result; void *result;
#ifdef _MSC_VER #ifdef _MSC_VER
...@@ -144,6 +145,16 @@ inline void aligned_free(void *ptr) { ...@@ -144,6 +145,16 @@ inline void aligned_free(void *ptr) {
#endif #endif
} }
buf_pool_t::io_buf_t::~io_buf_t()
{
for (buf_tmp_buffer_t* s = slots, *e = slots + n_slots; s != e; s++) {
aligned_free(s->crypt_buf);
aligned_free(s->comp_buf);
}
ut_free(slots);
}
#endif /* !UNIV_INNOCHECKSUM */
/* /*
IMPLEMENTATION OF THE BUFFER POOL IMPLEMENTATION OF THE BUFFER POOL
================================= =================================
...@@ -416,16 +427,9 @@ on the io_type */ ...@@ -416,16 +427,9 @@ on the io_type */
@return reserved buffer slot */ @return reserved buffer slot */
static buf_tmp_buffer_t* buf_pool_reserve_tmp_slot(buf_pool_t* buf_pool) static buf_tmp_buffer_t* buf_pool_reserve_tmp_slot(buf_pool_t* buf_pool)
{ {
for (ulint i = 0; i < buf_pool->tmp_arr->n_slots; i++) { buf_tmp_buffer_t* slot = buf_pool->io_buf.reserve();
buf_tmp_buffer_t* slot = &buf_pool->tmp_arr->slots[i]; ut_a(slot);
if (slot->acquire()) { return slot;
return slot;
}
}
/* We assume that free slot is found */
ut_error;
return NULL;
} }
/** Reserve a buffer for encryption, decryption or decompression. /** Reserve a buffer for encryption, decryption or decompression.
...@@ -1963,12 +1967,9 @@ buf_pool_init_instance( ...@@ -1963,12 +1967,9 @@ buf_pool_init_instance(
new(&buf_pool->single_scan_itr) LRUItr(buf_pool, &buf_pool->mutex); new(&buf_pool->single_scan_itr) LRUItr(buf_pool, &buf_pool->mutex);
/* Initialize the temporal memory array and slots */ /* Initialize the temporal memory array and slots */
buf_pool->tmp_arr = (buf_tmp_array_t *)ut_malloc_nokey(sizeof(buf_tmp_array_t)); new(&buf_pool->io_buf) buf_pool_t::io_buf_t(
memset(buf_pool->tmp_arr, 0, sizeof(buf_tmp_array_t)); (srv_n_read_io_threads + srv_n_write_io_threads)
ulint n_slots = (srv_n_read_io_threads + srv_n_write_io_threads) * (8 * OS_AIO_N_PENDING_IOS_PER_THREAD); * (8 * OS_AIO_N_PENDING_IOS_PER_THREAD));
buf_pool->tmp_arr->n_slots = n_slots;
buf_pool->tmp_arr->slots = (buf_tmp_buffer_t*)ut_malloc_nokey(sizeof(buf_tmp_buffer_t) * n_slots);
memset(buf_pool->tmp_arr->slots, 0, (sizeof(buf_tmp_buffer_t) * n_slots));
buf_pool_mutex_exit(buf_pool); buf_pool_mutex_exit(buf_pool);
...@@ -2046,26 +2047,7 @@ buf_pool_free_instance( ...@@ -2046,26 +2047,7 @@ buf_pool_free_instance(
hash_table_free(buf_pool->page_hash); hash_table_free(buf_pool->page_hash);
hash_table_free(buf_pool->zip_hash); hash_table_free(buf_pool->zip_hash);
/* Free all used temporary slots */ buf_pool->io_buf.~io_buf_t();
if (buf_pool->tmp_arr) {
for(ulint i = 0; i < buf_pool->tmp_arr->n_slots; i++) {
buf_tmp_buffer_t* slot = &(buf_pool->tmp_arr->slots[i]);
if (slot && slot->crypt_buf) {
aligned_free(slot->crypt_buf);
slot->crypt_buf = NULL;
}
if (slot && slot->comp_buf) {
aligned_free(slot->comp_buf);
slot->comp_buf = NULL;
}
}
ut_free(buf_pool->tmp_arr->slots);
ut_free(buf_pool->tmp_arr);
buf_pool->tmp_arr = NULL;
}
buf_pool->allocator.~ut_allocator(); buf_pool->allocator.~ut_allocator();
} }
......
...@@ -2072,17 +2072,6 @@ struct buf_buddy_stat_t { ...@@ -2072,17 +2072,6 @@ struct buf_buddy_stat_t {
ib_uint64_t relocated_usec; ib_uint64_t relocated_usec;
}; };
/** @brief The temporary memory array structure.
NOTE! The definition appears here only for other modules of this
directory (buf) to see it. Do not use from outside! */
typedef struct {
ulint n_slots; /*!< Total number of slots */
buf_tmp_buffer_t *slots; /*!< Pointer to the slots in the
array */
} buf_tmp_array_t;
/** @brief The buffer pool structure. /** @brief The buffer pool structure.
NOTE! The definition appears here only for other modules of this NOTE! The definition appears here only for other modules of this
...@@ -2284,20 +2273,47 @@ struct buf_pool_t{ ...@@ -2284,20 +2273,47 @@ struct buf_pool_t{
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
UT_LIST_BASE_NODE_T(buf_buddy_free_t) zip_free[BUF_BUDDY_SIZES_MAX]; UT_LIST_BASE_NODE_T(buf_buddy_free_t) zip_free[BUF_BUDDY_SIZES_MAX];
/*!< buddy free lists */ /*!< buddy free lists */
#if BUF_BUDDY_LOW > UNIV_ZIP_SIZE_MIN
# error "BUF_BUDDY_LOW > UNIV_ZIP_SIZE_MIN"
#endif
/* @} */
buf_page_t* watch; buf_page_t* watch;
/*!< Sentinel records for buffer /*!< Sentinel records for buffer
pool watches. Protected by pool watches. Protected by
buf_pool->mutex. */ buf_pool->mutex. */
buf_tmp_array_t* tmp_arr; /** Temporary memory for page_compressed and encrypted I/O */
/*!< Array for temporal memory struct io_buf_t {
used in compression and encryption */ /** number of elements in slots[] */
const ulint n_slots;
/** array of slots */
buf_tmp_buffer_t* const slots;
io_buf_t() = delete;
/** Constructor */
explicit io_buf_t(ulint n_slots) :
n_slots(n_slots),
slots(static_cast<buf_tmp_buffer_t*>(
ut_malloc_nokey(n_slots
* sizeof *slots)))
{
memset((void*) slots, 0, n_slots * sizeof *slots);
}
#if BUF_BUDDY_LOW > UNIV_ZIP_SIZE_MIN ~io_buf_t();
# error "BUF_BUDDY_LOW > UNIV_ZIP_SIZE_MIN"
#endif /** Reserve a buffer */
/* @} */ buf_tmp_buffer_t* reserve()
{
for (buf_tmp_buffer_t* s = slots, *e = slots + n_slots;
s != e; s++) {
if (s->acquire()) return s;
}
return NULL;
}
} io_buf;
}; };
/** Print the given buf_pool_t object. /** Print the given buf_pool_t object.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment