summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-04-27 14:26:43 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-04-28 20:52:22 +0300
commit9ed2b2b2b8ae3bd60f10995d72a6b7c8d7d037e3 (patch)
tree676bfa15065c5916a6b6b784ea09d2e51207004d
parenta90100d756eb046814f5bba54d522f1574c131ba (diff)
downloadmariadb-git-9ed2b2b2b8ae3bd60f10995d72a6b7c8d7d037e3.tar.gz
Do not divide or multiply by srv_page_size
Instead, shift by srv_page_size_shift.
-rw-r--r--extra/innochecksum.cc16
-rw-r--r--extra/mariabackup/xtrabackup.cc21
-rw-r--r--storage/innobase/btr/btr0cur.cc6
-rw-r--r--storage/innobase/buf/buf0buf.cc20
-rw-r--r--storage/innobase/buf/buf0dblwr.cc31
-rw-r--r--storage/innobase/buf/buf0lru.cc4
-rw-r--r--storage/innobase/fil/fil0fil.cc18
-rw-r--r--storage/innobase/fsp/fsp0sysspace.cc15
-rw-r--r--storage/innobase/ha/ha0ha.cc9
-rw-r--r--storage/innobase/handler/ha_innodb.cc12
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.cc10
-rw-r--r--storage/innobase/include/buf0buf.h2
-rw-r--r--storage/innobase/include/buf0buf.ic2
-rw-r--r--storage/innobase/include/fil0fil.h22
-rw-r--r--storage/innobase/include/fsp0fsp.h4
-rw-r--r--storage/innobase/include/fsp0sysspace.h4
-rw-r--r--storage/innobase/include/fsp0types.h25
-rw-r--r--storage/innobase/include/log0log.h6
-rw-r--r--storage/innobase/include/log0recv.h4
-rw-r--r--storage/innobase/include/trx0undo.h2
-rw-r--r--storage/innobase/include/univ.i18
-rw-r--r--storage/innobase/log/log0log.cc23
-rw-r--r--storage/innobase/log/log0recv.cc10
-rw-r--r--storage/innobase/os/os0file.cc8
-rw-r--r--storage/innobase/page/page0cur.cc2
-rw-r--r--storage/innobase/page/page0zip.cc3
-rw-r--r--storage/innobase/row/row0import.cc7
-rw-r--r--storage/innobase/row/row0log.cc6
-rw-r--r--storage/innobase/row/row0trunc.cc3
-rw-r--r--storage/innobase/srv/srv0srv.cc4
-rw-r--r--storage/innobase/srv/srv0start.cc2
-rw-r--r--storage/innobase/trx/trx0purge.cc2
32 files changed, 164 insertions, 157 deletions
diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc
index 6fb4154c6ca..a4d6c361809 100644
--- a/extra/innochecksum.cc
+++ b/extra/innochecksum.cc
@@ -98,6 +98,7 @@ extern ulong srv_checksum_algorithm;
static ulint physical_page_size; /* Page size in bytes on disk. */
static ulint logical_page_size; /* Page size when uncompressed. */
ulong srv_page_size;
+ulong srv_page_size_shift;
page_size_t univ_page_size(0, 0, false);
/* Current page number (0 based). */
unsigned long long cur_page_num;
@@ -308,16 +309,16 @@ const page_size_t
get_page_size(
byte* buf)
{
- const ulint flags = mach_read_from_4(buf + FIL_PAGE_DATA
+ const unsigned flags = mach_read_from_4(buf + FIL_PAGE_DATA
+ FSP_SPACE_FLAGS);
- const ulint ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags);
+ const ulong ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags);
- if (ssize == 0) {
- srv_page_size = UNIV_PAGE_SIZE_ORIG;
- } else {
- srv_page_size = ((UNIV_ZIP_SIZE_MIN >> 1) << ssize);
- }
+ srv_page_size_shift = ssize
+ ? UNIV_ZIP_SIZE_SHIFT_MIN - 1 + ssize
+ : UNIV_PAGE_SIZE_SHIFT_ORIG;
+
+ srv_page_size = 1U << srv_page_size_shift;
univ_page_size.copy_from(
page_size_t(srv_page_size, srv_page_size, false));
@@ -1703,7 +1704,6 @@ int main(
ulint zip_size = page_size.is_compressed() ? page_size.logical() : 0;
logical_page_size = page_size.is_compressed() ? zip_size : 0;
physical_page_size = page_size.physical();
- srv_page_size = (ulong)page_size.logical();
bool is_compressed = FSP_FLAGS_HAS_PAGE_COMPRESSION(flags);
if (page_size.physical() > UNIV_ZIP_SIZE_MIN) {
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index a181a156471..d6d05b99d96 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -1607,11 +1607,11 @@ innodb_init_param(void)
#endif /* BTR_CUR_HASH_ADAPT */
if (innobase_page_size != (1LL << 14)) {
- int n_shift = (int)get_bit_shift((ulint) innobase_page_size);
+ size_t n_shift = get_bit_shift(size_t(innobase_page_size));
if (n_shift >= 12 && n_shift <= UNIV_PAGE_SIZE_SHIFT_MAX) {
- srv_page_size_shift = n_shift;
- srv_page_size = 1 << n_shift;
+ srv_page_size_shift = ulong(n_shift);
+ srv_page_size = 1U << n_shift;
msg("InnoDB: The universal page size of the "
"database is set to %lu.\n", srv_page_size);
} else {
@@ -1621,7 +1621,7 @@ innodb_init_param(void)
}
} else {
srv_page_size_shift = 14;
- srv_page_size = (1 << srv_page_size_shift);
+ srv_page_size = 1U << 14;
}
/* Check that values don't overflow on 32-bit systems. */
@@ -3061,12 +3061,12 @@ static dberr_t xb_assign_undo_space_start()
return DB_ERROR;
}
- buf = static_cast<byte*>(ut_malloc_nokey(2 * srv_page_size));
+ buf = static_cast<byte*>(ut_malloc_nokey(2U << srv_page_size_shift));
page = static_cast<byte*>(ut_align(buf, srv_page_size));
retry:
if (!os_file_read(IORequestRead, file, page,
- TRX_SYS_PAGE_NO * srv_page_size,
+ TRX_SYS_PAGE_NO << srv_page_size_shift,
srv_page_size)) {
msg("mariabackup: Reading TRX_SYS page failed.\n");
error = DB_ERROR;
@@ -3592,8 +3592,8 @@ xb_normalize_init_values(void)
/*==========================*/
{
srv_sys_space.normalize();
- srv_log_buffer_size /= srv_page_size;
- srv_lock_table_size = 5 * (srv_buf_pool_size / srv_page_size);
+ srv_log_buffer_size >>= srv_page_size_shift;
+ srv_lock_table_size = 5 * (srv_buf_pool_size >> srv_page_size_shift);
}
/***********************************************************************
@@ -4249,7 +4249,8 @@ xb_space_create_file(
}
ret = os_file_set_size(path, *file,
- FIL_IBD_FILE_INITIAL_SIZE * srv_page_size);
+ FIL_IBD_FILE_INITIAL_SIZE
+ << srv_page_size_shift);
if (!ret) {
msg("mariabackup: cannot set size for file %s\n", path);
os_file_close(*file);
@@ -4257,7 +4258,7 @@ xb_space_create_file(
return ret;
}
- buf = static_cast<byte *>(malloc(3 * srv_page_size));
+ buf = static_cast<byte *>(malloc(3U << srv_page_size_shift));
/* Align the memory for file i/o if we might have O_DIRECT set */
page = static_cast<byte *>(ut_align(buf, srv_page_size));
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index 3ca61ad2cae..a04c70331ab 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -6709,12 +6709,12 @@ btr_rec_get_externally_stored_len(
btr_rec_get_field_ref(rec, offsets, i)
+ BTR_EXTERN_LEN + 4);
- total_extern_len += ut_calc_align(extern_len,
- srv_page_size);
+ total_extern_len += ut_calc_align(
+ extern_len, ulint(srv_page_size));
}
}
- return(total_extern_len / srv_page_size);
+ return total_extern_len >> srv_page_size_shift;
}
/*******************************************************************//**
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index cecbcc38dd6..f55029c3cf6 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -542,7 +542,8 @@ buf_get_total_list_size_in_bytes(
for statistics purpose */
buf_pools_list_size->LRU_bytes += buf_pool->stat.LRU_bytes;
buf_pools_list_size->unzip_LRU_bytes +=
- UT_LIST_GET_LEN(buf_pool->unzip_LRU) * srv_page_size;
+ UT_LIST_GET_LEN(buf_pool->unzip_LRU)
+ << srv_page_size_shift;
buf_pools_list_size->flush_list_bytes +=
buf_pool->stat.flush_list_bytes;
}
@@ -1544,7 +1545,7 @@ buf_chunk_init(
/* Round down to a multiple of page size,
although it already should be. */
- mem_size = ut_2pow_round(mem_size, srv_page_size);
+ mem_size = ut_2pow_round(mem_size, ulint(srv_page_size));
/* Reserve space for the block descriptors. */
mem_size += ut_2pow_round((mem_size >> srv_page_size_shift)
* (sizeof *block)
@@ -1588,7 +1589,7 @@ buf_chunk_init(
it is bigger, we may allocate more blocks than requested. */
frame = (byte*) ut_align(chunk->mem, srv_page_size);
- chunk->size = chunk->mem_pfx.m_size / srv_page_size
+ chunk->size = (chunk->mem_pfx.m_size >> srv_page_size_shift)
- (frame != chunk->mem);
/* Subtract the space needed for block descriptors. */
@@ -1865,7 +1866,8 @@ buf_pool_init_instance(
ut_min(BUF_READ_AHEAD_PAGES,
ut_2_power_up(buf_pool->curr_size /
BUF_READ_AHEAD_PORTION));
- buf_pool->curr_pool_size = buf_pool->curr_size * srv_page_size;
+ buf_pool->curr_pool_size = buf_pool->curr_size
+ << srv_page_size_shift;
buf_pool->old_size = buf_pool->curr_size;
buf_pool->n_chunks_new = buf_pool->n_chunks;
@@ -2654,7 +2656,7 @@ buf_pool_resize()
ut_ad(srv_buf_pool_chunk_unit > 0);
new_instance_size = srv_buf_pool_size / srv_buf_pool_instances;
- new_instance_size /= srv_page_size;
+ new_instance_size >>= srv_page_size_shift;
buf_resize_status("Resizing buffer pool from " ULINTPF " to "
ULINTPF " (unit=" ULINTPF ").",
@@ -2673,7 +2675,8 @@ buf_pool_resize()
buf_pool->curr_size = new_instance_size;
- buf_pool->n_chunks_new = new_instance_size * srv_page_size
+ buf_pool->n_chunks_new =
+ (new_instance_size << srv_page_size_shift)
/ srv_buf_pool_chunk_unit;
buf_pool_mutex_exit(buf_pool);
@@ -3006,7 +3009,7 @@ calc_buf_pool_size:
ut_2_power_up(buf_pool->curr_size /
BUF_READ_AHEAD_PORTION));
buf_pool->curr_pool_size
- = buf_pool->curr_size * srv_page_size;
+ = buf_pool->curr_size << srv_page_size_shift;
curr_size += buf_pool->curr_pool_size;
buf_pool->old_size = buf_pool->curr_size;
}
@@ -3058,7 +3061,8 @@ calc_buf_pool_size:
buf_resize_status("Resizing also other hash tables.");
/* normalize lock_sys */
- srv_lock_table_size = 5 * (srv_buf_pool_size / srv_page_size);
+ srv_lock_table_size = 5
+ * (srv_buf_pool_size >> srv_page_size_shift);
lock_sys.resize(srv_lock_table_size);
/* normalize btr_search_sys */
diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc
index d70efcb5e84..e219589c4a2 100644
--- a/storage/innobase/buf/buf0dblwr.cc
+++ b/storage/innobase/buf/buf0dblwr.cc
@@ -149,7 +149,7 @@ buf_dblwr_init(
ut_zalloc_nokey(buf_size * sizeof(bool)));
buf_dblwr->write_buf_unaligned = static_cast<byte*>(
- ut_malloc_nokey((1 + buf_size) * srv_page_size));
+ ut_malloc_nokey((1 + buf_size) << srv_page_size_shift));
buf_dblwr->write_buf = static_cast<byte*>(
ut_align(buf_dblwr->write_buf_unaligned,
@@ -214,7 +214,8 @@ too_small:
<< "Cannot create doublewrite buffer: "
"the first file in innodb_data_file_path"
" must be at least "
- << (3 * (FSP_EXTENT_SIZE * srv_page_size) >> 20)
+ << (3 * (FSP_EXTENT_SIZE
+ >> (20U - srv_page_size_shift)))
<< "M.";
mtr.commit();
return(false);
@@ -363,7 +364,7 @@ buf_dblwr_init_or_load_pages(
/* We do the file i/o past the buffer pool */
unaligned_read_buf = static_cast<byte*>(
- ut_malloc_nokey(3 * srv_page_size));
+ ut_malloc_nokey(3U << srv_page_size_shift));
read_buf = static_cast<byte*>(
ut_align(unaligned_read_buf, srv_page_size));
@@ -376,7 +377,7 @@ buf_dblwr_init_or_load_pages(
err = os_file_read(
read_request,
- file, read_buf, TRX_SYS_PAGE_NO * srv_page_size,
+ file, read_buf, TRX_SYS_PAGE_NO << srv_page_size_shift,
srv_page_size);
if (err != DB_SUCCESS) {
@@ -425,8 +426,8 @@ buf_dblwr_init_or_load_pages(
/* Read the pages from the doublewrite buffer to memory */
err = os_file_read(
read_request,
- file, buf, block1 * srv_page_size,
- TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * srv_page_size);
+ file, buf, block1 << srv_page_size_shift,
+ TRX_SYS_DOUBLEWRITE_BLOCK_SIZE << srv_page_size_shift);
if (err != DB_SUCCESS) {
@@ -442,9 +443,9 @@ buf_dblwr_init_or_load_pages(
err = os_file_read(
read_request,
file,
- buf + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * srv_page_size,
- block2 * srv_page_size,
- TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * srv_page_size);
+ buf + (TRX_SYS_DOUBLEWRITE_BLOCK_SIZE << srv_page_size_shift),
+ block2 << srv_page_size_shift,
+ TRX_SYS_DOUBLEWRITE_BLOCK_SIZE << srv_page_size_shift);
if (err != DB_SUCCESS) {
@@ -484,7 +485,7 @@ buf_dblwr_init_or_load_pages(
err = os_file_write(
write_request, path, file, page,
- source_page_no * srv_page_size,
+ source_page_no << srv_page_size_shift,
srv_page_size);
if (err != DB_SUCCESS) {
@@ -529,7 +530,7 @@ buf_dblwr_process()
}
unaligned_read_buf = static_cast<byte*>(
- ut_malloc_nokey(2 * srv_page_size));
+ ut_malloc_nokey(2U << srv_page_size_shift));
read_buf = static_cast<byte*>(
ut_align(unaligned_read_buf, srv_page_size));
@@ -1024,8 +1025,8 @@ try_again:
}
/* Write out the first block of the doublewrite buffer */
- len = ut_min(TRX_SYS_DOUBLEWRITE_BLOCK_SIZE,
- buf_dblwr->first_free) * srv_page_size;
+ len = std::min<ulint>(TRX_SYS_DOUBLEWRITE_BLOCK_SIZE,
+ buf_dblwr->first_free) << srv_page_size_shift;
fil_io(IORequestWrite, true,
page_id_t(TRX_SYS_SPACE, buf_dblwr->block1), univ_page_size,
@@ -1038,10 +1039,10 @@ try_again:
/* Write out the second block of the doublewrite buffer. */
len = (buf_dblwr->first_free - TRX_SYS_DOUBLEWRITE_BLOCK_SIZE)
- * srv_page_size;
+ << srv_page_size_shift;
write_buf = buf_dblwr->write_buf
- + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * srv_page_size;
+ + (TRX_SYS_DOUBLEWRITE_BLOCK_SIZE << srv_page_size_shift);
fil_io(IORequestWrite, true,
page_id_t(TRX_SYS_SPACE, buf_dblwr->block2), univ_page_size,
diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc
index 2695792466d..aadaac7c1d9 100644
--- a/storage/innobase/buf/buf0lru.cc
+++ b/storage/innobase/buf/buf0lru.cc
@@ -998,7 +998,7 @@ buf_LRU_check_size_of_non_data_objects(
" Check that your transactions do not set too many"
" row locks, or review if"
" innodb_buffer_pool_size="
- << (buf_pool->curr_size >> (20 - srv_page_size_shift))
+ << (buf_pool->curr_size >> (20U - srv_page_size_shift))
<< "M could be bigger.";
} else if (!recv_recovery_is_on()
&& buf_pool->curr_size == buf_pool->old_size
@@ -1021,7 +1021,7 @@ buf_LRU_check_size_of_non_data_objects(
" set too many row locks."
" innodb_buffer_pool_size="
<< (buf_pool->curr_size >>
- (20 - srv_page_size_shift)) << "M."
+ (20U - srv_page_size_shift)) << "M."
" Starting the InnoDB Monitor to print"
" diagnostics.";
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 6ab062bc8ae..b76a54d3886 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -1040,7 +1040,7 @@ fil_space_extend_must_retry(
fil_node_open_file() expects at least 4 * srv_page_size bytes.*/
os_offset_t new_size = std::max(
os_offset_t(size - file_start_page_no) * page_size,
- os_offset_t(FIL_IBD_FILE_INITIAL_SIZE * srv_page_size));
+ os_offset_t(FIL_IBD_FILE_INITIAL_SIZE << srv_page_size_shift));
*success = os_file_set_size(node->name, node->handle, new_size,
FSP_FLAGS_HAS_PAGE_COMPRESSION(space->flags));
@@ -2043,7 +2043,7 @@ fil_write_flushed_lsn(
byte* buf;
dberr_t err = DB_TABLESPACE_NOT_FOUND;
- buf1 = static_cast<byte*>(ut_malloc_nokey(2 * srv_page_size));
+ buf1 = static_cast<byte*>(ut_malloc_nokey(2U << srv_page_size_shift));
buf = static_cast<byte*>(ut_align(buf1, srv_page_size));
const page_id_t page_id(TRX_SYS_SPACE, 0);
@@ -2805,7 +2805,8 @@ bool fil_truncate_tablespace(fil_space_t* space, ulint size_in_pages)
bool success = os_file_truncate(node->name, node->handle, 0);
if (success) {
- os_offset_t size = os_offset_t(size_in_pages) * srv_page_size;
+ os_offset_t size = os_offset_t(size_in_pages)
+ << srv_page_size_shift;
success = os_file_set_size(
node->name, node->handle, size,
@@ -3273,7 +3274,7 @@ err_exit:
with zeros from the call of os_file_set_size(), until a buffer pool
flush would write to it. */
- buf2 = static_cast<byte*>(ut_malloc_nokey(3 * srv_page_size));
+ buf2 = static_cast<byte*>(ut_malloc_nokey(3U << srv_page_size_shift));
/* Align the memory for file i/o if we might have O_DIRECT set */
page = static_cast<byte*>(ut_align(buf2, srv_page_size));
@@ -4027,7 +4028,8 @@ fil_ibd_load(
/* Every .ibd file is created >= 4 pages in size.
Smaller files cannot be OK. */
- minimum_size = FIL_IBD_FILE_INITIAL_SIZE * srv_page_size;
+ minimum_size = os_offset_t(FIL_IBD_FILE_INITIAL_SIZE)
+ << srv_page_size_shift;
if (size == static_cast<os_offset_t>(-1)) {
/* The following call prints an error message */
@@ -4381,7 +4383,7 @@ fil_io(
ut_ad(len > 0);
ut_ad(byte_offset < srv_page_size);
ut_ad(!page_size.is_compressed() || byte_offset == 0);
- ut_ad(srv_page_size == ulong(1) << srv_page_size_shift);
+ ut_ad(srv_page_size == 1UL << srv_page_size_shift);
#if (1 << UNIV_PAGE_SIZE_SHIFT_MAX) != UNIV_PAGE_SIZE_MAX
# error "(1 << UNIV_PAGE_SIZE_SHIFT_MAX) != UNIV_PAGE_SIZE_MAX"
#endif
@@ -4574,7 +4576,7 @@ fil_io(
ut_a(node->size - cur_page_no
>= ((byte_offset + len + (srv_page_size - 1))
- / srv_page_size));
+ >> srv_page_size_shift));
} else {
ulint size_shift;
@@ -5308,7 +5310,7 @@ truncate_t::truncate(
: space->size;
const bool success = os_file_truncate(
- path, node->handle, trunc_size * srv_page_size);
+ path, node->handle, trunc_size << srv_page_size_shift);
if (!success) {
ib::error() << "Cannot truncate file " << path
diff --git a/storage/innobase/fsp/fsp0sysspace.cc b/storage/innobase/fsp/fsp0sysspace.cc
index e3a90f63bc0..1c1c9417f1f 100644
--- a/storage/innobase/fsp/fsp0sysspace.cc
+++ b/storage/innobase/fsp/fsp0sysspace.cc
@@ -397,7 +397,7 @@ SysTablespace::set_size(
/* We created the data file and now write it full of zeros */
ib::info() << "Setting file '" << file.filepath() << "' size to "
- << (file.m_size >> (20 - srv_page_size_shift)) << " MB."
+ << (file.m_size >> (20U - srv_page_size_shift)) << " MB."
" Physically writing the file full; Please wait ...";
bool success = os_file_set_size(
@@ -406,7 +406,7 @@ SysTablespace::set_size(
if (success) {
ib::info() << "File '" << file.filepath() << "' size is now "
- << (file.m_size >> (20 - srv_page_size_shift))
+ << (file.m_size >> (20U - srv_page_size_shift))
<< " MB.";
} else {
ib::error() << "Could not set the file size of '"
@@ -766,11 +766,10 @@ SysTablespace::check_file_spec(
}
if (!m_auto_extend_last_file
- && get_sum_of_sizes() < min_expected_size / srv_page_size) {
-
+ && get_sum_of_sizes()
+ < (min_expected_size >> srv_page_size_shift)) {
ib::error() << "Tablespace size must be at least "
- << min_expected_size / (1024 * 1024) << " MB";
-
+ << (min_expected_size >> 20) << " MB";
return(DB_ERROR);
}
@@ -949,10 +948,10 @@ SysTablespace::normalize()
for (files_t::iterator it = m_files.begin(); it != end; ++it) {
- it->m_size *= (1024 * 1024) / srv_page_size;
+ it->m_size <<= (20U - srv_page_size_shift);
}
- m_last_file_size_max *= (1024 * 1024) / srv_page_size;
+ m_last_file_size_max <<= (20U - srv_page_size_shift);
}
diff --git a/storage/innobase/ha/ha0ha.cc b/storage/innobase/ha/ha0ha.cc
index f5d1a9db831..fa1a9bc5db9 100644
--- a/storage/innobase/ha/ha0ha.cc
+++ b/storage/innobase/ha/ha0ha.cc
@@ -60,7 +60,8 @@ ib_create(
if (n_sync_obj == 0) {
table->heap = mem_heap_create_typed(
- ut_min(static_cast<ulint>(4096),
+ std::min<ulong>(
+ 4096,
MEM_MAX_ALLOC_IN_BUF / 2
- MEM_BLOCK_HEADER_SIZE - MEM_SPACE_NEEDED(0)),
type);
@@ -84,7 +85,8 @@ ib_create(
for (ulint i = 0; i < n_sync_obj; i++) {
table->heaps[i] = mem_heap_create_typed(
- ut_min(static_cast<ulint>(4096),
+ std::min<ulong>(
+ 4096,
MEM_MAX_ALLOC_IN_BUF / 2
- MEM_BLOCK_HEADER_SIZE - MEM_SPACE_NEEDED(0)),
type);
@@ -126,7 +128,8 @@ ib_recreate(
for (ulint i = 0; i < new_table->n_sync_obj; i++) {
new_table->heaps[i] = mem_heap_create_typed(
- ut_min(static_cast<ulint>(4096),
+ std::min<ulong>(
+ 4096,
MEM_MAX_ALLOC_IN_BUF / 2
- MEM_BLOCK_HEADER_SIZE - MEM_SPACE_NEEDED(0)),
MEM_HEAP_FOR_PAGE_HASH);
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 8c66a67acda..00a20a72cec 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -3956,7 +3956,7 @@ innobase_change_buffering_inited_ok:
srv_max_undo_log_size = std::max(
srv_max_undo_log_size,
ulonglong(SRV_UNDO_TABLESPACE_SIZE_IN_PAGES)
- * srv_page_size);
+ << srv_page_size_shift);
}
if (srv_log_write_ahead_size > srv_page_size) {
@@ -13435,8 +13435,8 @@ ha_innobase::estimate_rows_upper_bound()
ut_a(stat_n_leaf_pages > 0);
- local_data_file_length =
- ((ulonglong) stat_n_leaf_pages) * srv_page_size;
+ local_data_file_length = ulonglong(stat_n_leaf_pages)
+ << srv_page_size_shift;
/* Calculate a minimum length for a clustered index record and from
that an upper bound for the number of rows. Since we only calculate
@@ -20684,13 +20684,13 @@ innodb_params_adjust()
= MYSQL_SYSVAR_NAME(undo_logs).def_val
= srv_available_undo_logs;
MYSQL_SYSVAR_NAME(max_undo_log_size).max_val
- = 1ULL << (32 + srv_page_size_shift);
+ = 1ULL << (32U + srv_page_size_shift);
MYSQL_SYSVAR_NAME(max_undo_log_size).min_val
= MYSQL_SYSVAR_NAME(max_undo_log_size).def_val
= ulonglong(SRV_UNDO_TABLESPACE_SIZE_IN_PAGES)
- * srv_page_size;
+ << srv_page_size_shift;
MYSQL_SYSVAR_NAME(max_undo_log_size).max_val
- = 1ULL << (32 + srv_page_size_shift);
+ = 1ULL << (32U + srv_page_size_shift);
}
/****************************************************************************
diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc
index ad19084a995..5551aba853b 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.cc
+++ b/storage/innobase/ibuf/ibuf0ibuf.cc
@@ -510,7 +510,7 @@ ibuf_init_at_db_start(void)
buffer pool size. Once ibuf struct is initialized this
value is updated with the user supplied size by calling
ibuf_max_size_update(). */
- ibuf->max_size = ((buf_pool_get_curr_size() / srv_page_size)
+ ibuf->max_size = ((buf_pool_get_curr_size() >> srv_page_size_shift)
* CHANGE_BUFFER_DEFAULT_SIZE) / 100;
mutex_create(LATCH_ID_IBUF, &ibuf_mutex);
@@ -584,7 +584,7 @@ ibuf_max_size_update(
ulint new_val) /*!< in: new value in terms of
percentage of the buffer pool size */
{
- ulint new_size = ((buf_pool_get_curr_size() / srv_page_size)
+ ulint new_size = ((buf_pool_get_curr_size() >> srv_page_size_shift)
* new_val) / 100;
mutex_enter(&ibuf_mutex);
ibuf->max_size = new_size;
@@ -2381,7 +2381,7 @@ ibuf_get_merge_page_nos_func(
&& prev_space_id == first_space_id)
|| (volume_for_page
> ((IBUF_MERGE_THRESHOLD - 1)
- * 4 * srv_page_size
+ * 4U << srv_page_size_shift
/ IBUF_PAGE_SIZE_PER_FREE_SPACE)
/ IBUF_MERGE_THRESHOLD)) {
@@ -4653,8 +4653,8 @@ loop:
volume += page_dir_calc_reserved_space(1);
- ut_a(volume <= 4 * srv_page_size
- / IBUF_PAGE_SIZE_PER_FREE_SPACE);
+ ut_a(volume <= (4U << srv_page_size_shift)
+ / IBUF_PAGE_SIZE_PER_FREE_SPACE);
#endif
ibuf_insert_to_index_page(
entry, block, dummy_index, &mtr);
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index 8271a3e06cf..9136c25acfd 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -1874,7 +1874,7 @@ struct buf_block_t{
/**********************************************************************//**
Compute the hash fold value for blocks in buf_pool->zip_hash. */
/* @{ */
-#define BUF_POOL_ZIP_FOLD_PTR(ptr) ((ulint) (ptr) / srv_page_size)
+#define BUF_POOL_ZIP_FOLD_PTR(ptr) (ulint(ptr) >> srv_page_size_shift)
#define BUF_POOL_ZIP_FOLD(b) BUF_POOL_ZIP_FOLD_PTR((b)->frame)
#define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b))
/* @} */
diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic
index d62149b31c7..8314797e78d 100644
--- a/storage/innobase/include/buf0buf.ic
+++ b/storage/innobase/include/buf0buf.ic
@@ -115,7 +115,7 @@ ulint
buf_pool_get_n_pages(void)
/*======================*/
{
- return(buf_pool_get_curr_size() / srv_page_size);
+ return buf_pool_get_curr_size() >> srv_page_size_shift;
}
/********************************************************************//**
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index 84061fdd7db..e08c7684061 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -365,15 +365,15 @@ typedef byte fil_faddr_t; /*!< 'type' definition in C: an address
#endif /* !UNIV_INNOCHECKSUM */
/** Initial size of a single-table tablespace in pages */
-#define FIL_IBD_FILE_INITIAL_SIZE 4
+#define FIL_IBD_FILE_INITIAL_SIZE 4U
/** 'null' (undefined) page offset in the context of file spaces */
#define FIL_NULL ULINT32_UNDEFINED
-#define FIL_ADDR_PAGE 0 /* first in address is the page offset */
-#define FIL_ADDR_BYTE 4 /* then comes 2-byte byte offset within page*/
-#define FIL_ADDR_SIZE 6 /* address size is 6 bytes */
+#define FIL_ADDR_PAGE 0U /* first in address is the page offset */
+#define FIL_ADDR_BYTE 4U /* then comes 2-byte byte offset within page*/
+#define FIL_ADDR_SIZE 6U /* address size is 6 bytes */
#ifndef UNIV_INNOCHECKSUM
@@ -393,15 +393,15 @@ extern const fil_addr_t fil_addr_null;
page belongs to (== 0) but in later
versions the 'new' checksum of the
page */
-#define FIL_PAGE_OFFSET 4 /*!< page offset inside space */
-#define FIL_PAGE_PREV 8 /*!< if there is a 'natural'
+#define FIL_PAGE_OFFSET 4U /*!< page offset inside space */
+#define FIL_PAGE_PREV 8U /*!< if there is a 'natural'
predecessor of the page, its
offset. Otherwise FIL_NULL.
This field is not set on BLOB
pages, which are stored as a
singly-linked list. See also
FIL_PAGE_NEXT. */
-#define FIL_PAGE_NEXT 12 /*!< if there is a 'natural' successor
+#define FIL_PAGE_NEXT 12U /*!< if there is a 'natural' successor
of the page, its offset.
Otherwise FIL_NULL.
B-tree index pages
@@ -411,9 +411,9 @@ extern const fil_addr_t fil_addr_null;
FIL_PAGE_PREV and FIL_PAGE_NEXT
in the collation order of the
smallest user record on each page. */
-#define FIL_PAGE_LSN 16 /*!< lsn of the end of the newest
+#define FIL_PAGE_LSN 16U /*!< lsn of the end of the newest
modification log record to the page */
-#define FIL_PAGE_TYPE 24 /*!< file page type: FIL_PAGE_INDEX,...,
+#define FIL_PAGE_TYPE 24U /*!< file page type: FIL_PAGE_INDEX,...,
2 bytes.
The contents of this field can only
@@ -428,7 +428,7 @@ extern const fil_addr_t fil_addr_null;
MySQL/InnoDB 5.1.7 or later, the
contents of this field is valid
for all uncompressed pages. */
-#define FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION 26 /*!< for the first page
+#define FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION 26U /*!< for the first page
in a system tablespace data file
(ibdata*, not *.ibd): the file has
been flushed to disk at least up
@@ -442,7 +442,7 @@ extern const fil_addr_t fil_addr_null;
#define FIL_RTREE_SPLIT_SEQ_NUM FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION
/** starting from 4.1.x this contains the space id of the page */
-#define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID 34
+#define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID 34U
#define FIL_PAGE_SPACE_ID FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID
diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h
index a0aea66f352..161d7a30ea4 100644
--- a/storage/innobase/include/fsp0fsp.h
+++ b/storage/innobase/include/fsp0fsp.h
@@ -46,7 +46,7 @@ Created 12/18/1995 Heikki Tuuri
/** @return the PAGE_SSIZE flags for the current innodb_page_size */
#define FSP_FLAGS_PAGE_SSIZE() \
((srv_page_size == UNIV_PAGE_SIZE_ORIG) ? \
- 0 : (srv_page_size_shift - UNIV_ZIP_SIZE_SHIFT_MIN + 1) \
+ 0U : (srv_page_size_shift - UNIV_ZIP_SIZE_SHIFT_MIN + 1) \
<< FSP_FLAGS_POS_PAGE_SSIZE)
/* @defgroup Compatibility macros for MariaDB 10.1.0 through 10.1.20;
@@ -318,7 +318,7 @@ UNIV_INLINE
ulint
fsp_get_extent_size_in_pages(const page_size_t& page_size)
{
- return(FSP_EXTENT_SIZE * srv_page_size / page_size.physical());
+ return (FSP_EXTENT_SIZE << srv_page_size_shift) / page_size.physical();
}
/**********************************************************************//**
diff --git a/storage/innobase/include/fsp0sysspace.h b/storage/innobase/include/fsp0sysspace.h
index b5cbe6160a4..4a36c9dcbd8 100644
--- a/storage/innobase/include/fsp0sysspace.h
+++ b/storage/innobase/include/fsp0sysspace.h
@@ -139,8 +139,8 @@ public:
@return the autoextend increment in pages. */
ulint get_autoextend_increment() const
{
- return(sys_tablespace_auto_extend_increment
- * ((1024 * 1024) / srv_page_size));
+ return sys_tablespace_auto_extend_increment
+ << (20 - srv_page_size_shift);
}
/**
diff --git a/storage/innobase/include/fsp0types.h b/storage/innobase/include/fsp0types.h
index 9b15d79066e..f7a5befa6ae 100644
--- a/storage/innobase/include/fsp0types.h
+++ b/storage/innobase/include/fsp0types.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2014, 2017, MariaDB Corporation.
+Copyright (c) 2014, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -59,11 +59,8 @@ page size | file space extent size
32 KiB | 64 pages = 2 MiB
64 KiB | 64 pages = 4 MiB
*/
-#define FSP_EXTENT_SIZE ((srv_page_size <= (16384) ? \
- (1048576 / srv_page_size) : \
- ((srv_page_size <= (32768)) ? \
- (2097152 / srv_page_size) : \
- (4194304 / srv_page_size))))
+#define FSP_EXTENT_SIZE (srv_page_size_shift < 14 ? \
+ (1048576U >> srv_page_size_shift) : 64U)
/** File space extent size (four megabyte) in pages for MAX page size */
#define FSP_EXTENT_SIZE_MAX (4194304 / UNIV_PAGE_SIZE_MAX)
@@ -159,30 +156,30 @@ The pages at FSP_XDES_OFFSET and FSP_IBUF_BITMAP_OFFSET are repeated
every XDES_DESCRIBED_PER_PAGE pages in every tablespace. */
/* @{ */
/*--------------------------------------*/
-#define FSP_XDES_OFFSET 0 /* !< extent descriptor */
-#define FSP_IBUF_BITMAP_OFFSET 1 /* !< insert buffer bitmap */
+#define FSP_XDES_OFFSET 0U /* !< extent descriptor */
+#define FSP_IBUF_BITMAP_OFFSET 1U /* !< insert buffer bitmap */
/* The ibuf bitmap pages are the ones whose
page number is the number above plus a
multiple of XDES_DESCRIBED_PER_PAGE */
-#define FSP_FIRST_INODE_PAGE_NO 2 /*!< in every tablespace */
+#define FSP_FIRST_INODE_PAGE_NO 2U /*!< in every tablespace */
/* The following pages exist
in the system tablespace (space 0). */
-#define FSP_IBUF_HEADER_PAGE_NO 3 /*!< insert buffer
+#define FSP_IBUF_HEADER_PAGE_NO 3U /*!< insert buffer
header page, in
tablespace 0 */
-#define FSP_IBUF_TREE_ROOT_PAGE_NO 4 /*!< insert buffer
+#define FSP_IBUF_TREE_ROOT_PAGE_NO 4U /*!< insert buffer
B-tree root page in
tablespace 0 */
/* The ibuf tree root page number in
tablespace 0; its fseg inode is on the page
number FSP_FIRST_INODE_PAGE_NO */
-#define FSP_TRX_SYS_PAGE_NO 5 /*!< transaction
+#define FSP_TRX_SYS_PAGE_NO 5U /*!< transaction
system header, in
tablespace 0 */
-#define FSP_FIRST_RSEG_PAGE_NO 6 /*!< first rollback segment
+#define FSP_FIRST_RSEG_PAGE_NO 6U /*!< first rollback segment
page, in tablespace 0 */
-#define FSP_DICT_HDR_PAGE_NO 7 /*!< data dictionary header
+#define FSP_DICT_HDR_PAGE_NO 7U /*!< data dictionary header
page, in tablespace 0 */
/*--------------------------------------*/
/* @} */
diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h
index 7da14030da2..31cc0f2afd0 100644
--- a/storage/innobase/include/log0log.h
+++ b/storage/innobase/include/log0log.h
@@ -50,8 +50,8 @@ struct log_group_t;
/* Margin for the free space in the smallest log group, before a new query
step which modifies the database, is started */
-#define LOG_CHECKPOINT_FREE_PER_THREAD (4 * srv_page_size)
-#define LOG_CHECKPOINT_EXTRA_FREE (8 * srv_page_size)
+#define LOG_CHECKPOINT_FREE_PER_THREAD (4U << srv_page_size_shift)
+#define LOG_CHECKPOINT_EXTRA_FREE (8U << srv_page_size_shift)
typedef ulint (*log_checksum_func_t)(const byte* log_block);
@@ -422,7 +422,7 @@ extern my_bool innodb_log_checksums;
/* The counting of lsn's starts from this value: this must be non-zero */
#define LOG_START_LSN ((lsn_t) (16 * OS_FILE_LOG_BLOCK_SIZE))
-#define LOG_BUFFER_SIZE (srv_log_buffer_size * srv_page_size)
+#define LOG_BUFFER_SIZE (srv_log_buffer_size << srv_page_size_shift)
/* Offsets of a log block header */
#define LOG_BLOCK_HDR_NO 0 /* block number which must be > 0 and
diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h
index 090f963321a..19e13fcdcc6 100644
--- a/storage/innobase/include/log0recv.h
+++ b/storage/innobase/include/log0recv.h
@@ -342,11 +342,11 @@ extern bool recv_lsn_checks_on;
/** Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many
times! */
-#define RECV_PARSING_BUF_SIZE (2 * 1024 * 1024)
+#define RECV_PARSING_BUF_SIZE (2U << 20)
/** Size of block reads when the log groups are scanned forward to do a
roll-forward */
-#define RECV_SCAN_SIZE (4 * srv_page_size)
+#define RECV_SCAN_SIZE (4U << srv_page_size_shift)
/** This many frames must be left free in the buffer pool when we scan
the log and store the scanned log records in the buffer pool: we will
diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h
index 1f2c99f1d23..aefd9db6287 100644
--- a/storage/innobase/include/trx0undo.h
+++ b/storage/innobase/include/trx0undo.h
@@ -421,7 +421,7 @@ struct trx_undo_t {
at most this many bytes used; we must leave space at least for one new undo
log header on the page */
-#define TRX_UNDO_PAGE_REUSE_LIMIT (3 * srv_page_size / 4)
+#define TRX_UNDO_PAGE_REUSE_LIMIT (3 << (srv_page_size_shift - 2))
/* An update undo log segment may contain several undo logs on its first page
if the undo logs took so little space that the segment could be cached and
diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i
index de5d67c5091..c78f6f81ef3 100644
--- a/storage/innobase/include/univ.i
+++ b/storage/innobase/include/univ.i
@@ -313,27 +313,27 @@ management to ensure correct alignment for doubles etc. */
/** log2 of smallest compressed page size (1<<10 == 1024 bytes)
Note: This must never change! */
-#define UNIV_ZIP_SIZE_SHIFT_MIN 10
+#define UNIV_ZIP_SIZE_SHIFT_MIN 10U
/** log2 of largest compressed page size (1<<14 == 16384 bytes).
A compressed page directory entry reserves 14 bits for the start offset
and 2 bits for flags. This limits the uncompressed page size to 16k.
*/
-#define UNIV_ZIP_SIZE_SHIFT_MAX 14
+#define UNIV_ZIP_SIZE_SHIFT_MAX 14U
/* Define the Min, Max, Default page sizes. */
/** Minimum Page Size Shift (power of 2) */
-#define UNIV_PAGE_SIZE_SHIFT_MIN 12
+#define UNIV_PAGE_SIZE_SHIFT_MIN 12U
/** log2 of largest page size (1<<16 == 64436 bytes). */
/** Maximum Page Size Shift (power of 2) */
-#define UNIV_PAGE_SIZE_SHIFT_MAX 16
+#define UNIV_PAGE_SIZE_SHIFT_MAX 16U
/** log2 of default page size (1<<14 == 16384 bytes). */
/** Default Page Size Shift (power of 2) */
-#define UNIV_PAGE_SIZE_SHIFT_DEF 14
+#define UNIV_PAGE_SIZE_SHIFT_DEF 14U
/** Original 16k InnoDB Page Size Shift, in case the default changes */
-#define UNIV_PAGE_SIZE_SHIFT_ORIG 14
+#define UNIV_PAGE_SIZE_SHIFT_ORIG 14U
/** Original 16k InnoDB Page Size as an ssize (log2 - 9) */
-#define UNIV_PAGE_SSIZE_ORIG (UNIV_PAGE_SIZE_SHIFT_ORIG - 9)
+#define UNIV_PAGE_SSIZE_ORIG (UNIV_PAGE_SIZE_SHIFT_ORIG - 9U)
/** Minimum page size InnoDB currently supports. */
#define UNIV_PAGE_SIZE_MIN (1U << UNIV_PAGE_SIZE_SHIFT_MIN)
@@ -355,11 +355,11 @@ and 2 bits for flags. This limits the uncompressed page size to 16k.
shifts starting with 512.)
This max number varies depending on srv_page_size. */
#define UNIV_PAGE_SSIZE_MAX \
- ulint(srv_page_size_shift - UNIV_ZIP_SIZE_SHIFT_MIN + 1)
+ ulint(srv_page_size_shift - UNIV_ZIP_SIZE_SHIFT_MIN + 1U)
/** Smallest possible ssize for an uncompressed page. */
#define UNIV_PAGE_SSIZE_MIN \
- ulint(UNIV_PAGE_SIZE_SHIFT_MIN - UNIV_ZIP_SIZE_SHIFT_MIN + 1)
+ ulint(UNIV_PAGE_SIZE_SHIFT_MIN - UNIV_ZIP_SIZE_SHIFT_MIN + 1U)
/** Maximum number of parallel threads in a parallelized operation */
#define UNIV_MAX_PARALLELISM 32
diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc
index a30b450636d..13e1c0e01d4 100644
--- a/storage/innobase/log/log0log.cc
+++ b/storage/innobase/log/log0log.cc
@@ -106,7 +106,8 @@ static time_t log_last_margine_warning_time;
/* Margins for free space in the log buffer after a log entry is catenated */
#define LOG_BUF_FLUSH_RATIO 2
-#define LOG_BUF_FLUSH_MARGIN (LOG_BUF_WRITE_MARGIN + 4 * srv_page_size)
+#define LOG_BUF_FLUSH_MARGIN (LOG_BUF_WRITE_MARGIN \
+ + (4U << srv_page_size_shift))
/* This parameter controls asynchronous making of a new checkpoint; the value
should be bigger than LOG_POOL_PREFLUSH_RATIO_SYNC */
@@ -184,7 +185,7 @@ log_buffer_extend(
log_mutex_enter_all();
- if (srv_log_buffer_size > len / srv_page_size) {
+ if (srv_log_buffer_size > (len >> srv_page_size_shift)) {
/* Already extended enough by the others */
log_mutex_exit_all();
return;
@@ -234,7 +235,7 @@ log_buffer_extend(
ut_free_dodump(log_sys->buf, log_sys->buf_size * 2);
/* reallocate log buffer */
- srv_log_buffer_size = len / srv_page_size + 1;
+ srv_log_buffer_size = (len >> srv_page_size_shift) + 1;
log_sys->buf_size = LOG_BUFFER_SIZE;
log_sys->buf = static_cast<byte*>(
@@ -722,7 +723,7 @@ log_sys_init()
log_sys->lsn = LOG_START_LSN;
ut_a(LOG_BUFFER_SIZE >= 16 * OS_FILE_LOG_BLOCK_SIZE);
- ut_a(LOG_BUFFER_SIZE >= 4 * srv_page_size);
+ ut_a(LOG_BUFFER_SIZE >= 4U << srv_page_size_shift);
log_sys->buf_size = LOG_BUFFER_SIZE;
@@ -895,12 +896,12 @@ log_group_file_header_flush(
srv_stats.os_log_pending_writes.inc();
- const ulint page_no = ulint(dest_offset / srv_page_size);
+ const ulint page_no = ulint(dest_offset >> srv_page_size_shift);
fil_io(IORequestLogWrite, true,
page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no),
univ_page_size,
- ulint(dest_offset % srv_page_size),
+ ulint(dest_offset & (srv_page_size - 1)),
OS_FILE_LOG_BLOCK_SIZE, buf, group);
srv_stats.os_log_pending_writes.dec();
@@ -1015,14 +1016,14 @@ loop:
srv_stats.os_log_pending_writes.inc();
- ut_a(next_offset / srv_page_size <= ULINT_MAX);
+ ut_a((next_offset >> srv_page_size_shift) <= ULINT_MAX);
- const ulint page_no = ulint(next_offset / srv_page_size);
+ const ulint page_no = ulint(next_offset >> srv_page_size_shift);
fil_io(IORequestLogWrite, true,
page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no),
univ_page_size,
- ulint(next_offset % srv_page_size), write_len, buf,
+ ulint(next_offset & (srv_page_size - 1)), write_len, buf,
group);
srv_stats.os_log_pending_writes.dec();
@@ -1564,8 +1565,8 @@ log_group_header_read(
fil_io(IORequestLogRead, true,
page_id_t(SRV_LOG_SPACE_FIRST_ID,
- header / srv_page_size),
- univ_page_size, header % srv_page_size,
+ header >> srv_page_size_shift),
+ univ_page_size, header & (srv_page_size - 1),
OS_FILE_LOG_BLOCK_SIZE, log_sys->checkpoint_buf, NULL);
}
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index 51e6bcabda1..fb04db253ef 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -673,14 +673,14 @@ loop:
MONITOR_INC(MONITOR_LOG_IO);
- ut_a(source_offset / srv_page_size <= ULINT_MAX);
+ ut_a((source_offset >> srv_page_size_shift) <= ULINT_MAX);
- const ulint page_no = ulint(source_offset / srv_page_size);
+ const ulint page_no = ulint(source_offset >> srv_page_size_shift);
fil_io(IORequestLogRead, true,
page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no),
univ_page_size,
- ulint(source_offset % srv_page_size),
+ ulint(source_offset & (srv_page_size - 1)),
len, buf, NULL);
for (ulint l = 0; l < len; l += OS_FILE_LOG_BLOCK_SIZE,
@@ -886,7 +886,7 @@ recv_log_format_0_recover(lsn_t lsn)
const lsn_t source_offset
= log_group_calc_lsn_offset(lsn, group);
log_mutex_exit();
- const ulint page_no = ulint(source_offset / srv_page_size);
+ const ulint page_no = ulint(source_offset >> srv_page_size_shift);
byte* buf = log_sys->buf;
static const char* NO_UPGRADE_RECOVERY_MSG =
@@ -897,7 +897,7 @@ recv_log_format_0_recover(lsn_t lsn)
page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no),
univ_page_size,
ulint((source_offset & ~(OS_FILE_LOG_BLOCK_SIZE - 1))
- % srv_page_size),
+ & (srv_page_size - 1)),
OS_FILE_LOG_BLOCK_SIZE, buf, NULL);
if (log_block_calc_checksum_format_0(buf)
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index 4142ce43ca5..5e5f05d6071 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -5327,11 +5327,9 @@ fallback:
#endif /* _WIN32*/
/* Write up to 1 megabyte at a time. */
- ulint buf_size = ut_min(
- static_cast<ulint>(64),
- static_cast<ulint>(size / srv_page_size));
-
- buf_size *= srv_page_size;
+ ulint buf_size = ut_min(ulint(64),
+ ulint(size >> srv_page_size_shift))
+ << srv_page_size_shift;
/* Align the buffer for possible raw i/o */
byte* buf2;
diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc
index 0b03939a4a2..2a21317c9da 100644
--- a/storage/innobase/page/page0cur.cc
+++ b/storage/innobase/page/page0cur.cc
@@ -2171,7 +2171,7 @@ page_copy_rec_list_end_to_created_page(
log_data_len = mtr->get_log()->size() - log_data_len;
- ut_a(log_data_len < 100 * srv_page_size);
+ ut_a(log_data_len < 100U << srv_page_size_shift);
if (log_ptr != NULL) {
mach_write_to_4(log_ptr, log_data_len);
diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc
index 84aa0f27f4f..9b0f6dd9737 100644
--- a/storage/innobase/page/page0zip.cc
+++ b/storage/innobase/page/page0zip.cc
@@ -3357,7 +3357,8 @@ page_zip_validate_low(
/* page_zip_decompress() expects the uncompressed page to be
srv_page_size aligned. */
- temp_page_buf = static_cast<byte*>(ut_malloc_nokey(2 * srv_page_size));
+ temp_page_buf = static_cast<byte*>(
+ ut_malloc_nokey(2 << srv_page_size_shift));
temp_page = static_cast<byte*>(ut_align(temp_page_buf, srv_page_size));
UNIV_MEM_ASSERT_RW(page, srv_page_size);
diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc
index ab82f43f074..59101c84600 100644
--- a/storage/innobase/row/row0import.cc
+++ b/storage/innobase/row/row0import.cc
@@ -3598,7 +3598,7 @@ fil_tablespace_iterate(
We allocate an extra page in case it is a compressed table. One
page is to ensure alignement. */
- void* page_ptr = ut_malloc_nokey(3 * srv_page_size);
+ void* page_ptr = ut_malloc_nokey(3U << srv_page_size_shift);
byte* page = static_cast<byte*>(ut_align(page_ptr, srv_page_size));
buf_block_t* block = reinterpret_cast<buf_block_t*>
@@ -3655,7 +3655,7 @@ fil_tablespace_iterate(
/* Add an extra page for compressed page scratch area. */
void* io_buffer = ut_malloc_nokey(
- (2 + iter.n_io_buffers) * srv_page_size);
+ (2 + iter.n_io_buffers) << srv_page_size_shift);
iter.io_buffer = static_cast<byte*>(
ut_align(io_buffer, srv_page_size));
@@ -3663,7 +3663,8 @@ fil_tablespace_iterate(
void* crypt_io_buffer = NULL;
if (iter.crypt_data) {
crypt_io_buffer = ut_malloc_nokey(
- (2 + iter.n_io_buffers) * srv_page_size);
+ (2 + iter.n_io_buffers)
+ << srv_page_size_shift);
iter.crypt_io_buffer = static_cast<byte*>(
ut_align(crypt_io_buffer, srv_page_size));
}
diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc
index b8d5e12b282..bc964d99405 100644
--- a/storage/innobase/row/row0log.cc
+++ b/storage/innobase/row/row0log.cc
@@ -2704,10 +2704,8 @@ row_log_progress_inc_per_block()
/* We must increment the progress once per page (as in
univ_page_size, usually 16KiB). One block here is srv_sort_buf_size
(usually 1MiB). */
- const ulint pages_per_block = std::max(
- static_cast<unsigned long>(
- srv_sort_buf_size / srv_page_size),
- 1UL);
+ const ulint pages_per_block = std::max<ulint>(
+ ulint(srv_sort_buf_size >> srv_page_size_shift), 1);
/* Multiply by an artificial factor of 6 to even the pace with
the rest of the ALTER TABLE phases, they process page_size amount
diff --git a/storage/innobase/row/row0trunc.cc b/storage/innobase/row/row0trunc.cc
index c678ea9aa68..f25b23cf5e4 100644
--- a/storage/innobase/row/row0trunc.cc
+++ b/storage/innobase/row/row0trunc.cc
@@ -2199,7 +2199,8 @@ fil_recreate_tablespace(
byte* buf;
page_t* page;
- buf = static_cast<byte*>(ut_zalloc_nokey(3 * srv_page_size));
+ buf = static_cast<byte*>(
+ ut_zalloc_nokey(3U << srv_page_size_shift));
/* Align the memory for file i/o */
page = static_cast<byte*>(ut_align(buf, srv_page_size));
diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc
index 457ab759ff5..341ec688b3a 100644
--- a/storage/innobase/srv/srv0srv.cc
+++ b/storage/innobase/srv/srv0srv.cc
@@ -1123,9 +1123,9 @@ srv_normalize_init_values(void)
srv_tmp_space.normalize();
- srv_log_buffer_size /= srv_page_size;
+ srv_log_buffer_size >>= srv_page_size_shift;
- srv_lock_table_size = 5 * (srv_buf_pool_size / srv_page_size);
+ srv_lock_table_size = 5 * (srv_buf_pool_size >> srv_page_size_shift);
}
/*********************************************************************//**
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index e1d3bbe0722..af42f288089 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -726,7 +726,7 @@ srv_undo_tablespace_open(
ut_a(fil_validate());
ut_a(space);
- os_offset_t n_pages = size / srv_page_size;
+ os_offset_t n_pages = size >> srv_page_size_shift;
/* On 32-bit platforms, ulint is 32 bits and os_offset_t
is 64 bits. It is OK to cast the n_pages to ulint because
diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc
index 02e1f948e20..56dbe61e715 100644
--- a/storage/innobase/trx/trx0purge.cc
+++ b/storage/innobase/trx/trx0purge.cc
@@ -800,7 +800,7 @@ trx_purge_mark_undo_for_truncate(
for (ulint i = 1; i <= srv_undo_tablespaces_active; i++) {
if (fil_space_get_size(space_id)
- > (srv_max_undo_log_size / srv_page_size)) {
+ > (srv_max_undo_log_size >> srv_page_size_shift)) {
/* Tablespace qualifies for truncate. */
undo_trunc->mark(space_id);
undo::Truncate::add_space_to_trunc_list(space_id);