summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-04-08 15:36:03 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-04-08 21:33:49 +0300
commitf120a15b93dcb88adc31ad4fc7caf63b813ca63e (patch)
treec71890a6285fd503530471deee099d50005ab604
parentcaa8c20abee29416c82031a8ae2f7dd23d821b10 (diff)
downloadmariadb-git-f120a15b93dcb88adc31ad4fc7caf63b813ca63e.tar.gz
MDEV-19212 4GB Limit on large_pages - integer overflow
os_mem_alloc_large(): Invoke the macro ut_2pow_round() with the correct argument type. innobase_large_page_size, innobase_use_large_pages, os_use_large_pages, os_large_page_size: Remove. Simply refer to opt_large_page_size, my_use_large_pages.
-rw-r--r--extra/mariabackup/xtrabackup.cc5
-rw-r--r--storage/innobase/buf/buf0buf.cc2
-rw-r--r--storage/innobase/handler/ha_innodb.cc6
-rw-r--r--storage/innobase/include/os0proc.h8
-rw-r--r--storage/innobase/os/os0proc.cc30
5 files changed, 16 insertions, 35 deletions
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 3eca4687bbd..2b8abc04446 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -221,8 +221,6 @@ const char *defaults_group = "mysqld";
#define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */
#define HA_INNOBASE_RANGE_COUNT 100
-ulong innobase_large_page_size = 0;
-
/* The default values for the following, type long or longlong, start-up
parameters are declared in mysqld.cc: */
@@ -247,7 +245,6 @@ affects Windows: */
char* innobase_unix_file_flush_method;
my_bool innobase_use_doublewrite;
-my_bool innobase_use_large_pages;
my_bool innobase_file_per_table;
my_bool innobase_locks_unsafe_for_binlog;
my_bool innobase_rollback_on_timeout;
@@ -1919,8 +1916,6 @@ innodb_init_param(void)
srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite;
- os_use_large_pages = (ibool) innobase_use_large_pages;
- os_large_page_size = (ulint) innobase_large_page_size;
row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout;
srv_file_per_table = (my_bool) innobase_file_per_table;
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index cd0ef0e1610..4703df3d33c 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -1566,7 +1566,7 @@ buf_chunk_init(
chunk->blocks = (buf_block_t*) chunk->mem;
/* Align a pointer to the first frame. Note that when
- os_large_page_size is smaller than UNIV_PAGE_SIZE,
+ opt_large_page_size is smaller than UNIV_PAGE_SIZE,
we may allocate one fewer block than requested. When
it is bigger, we may allocate more blocks than requested. */
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index adcb845c031..8a97aeed0ba 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -4265,12 +4265,6 @@ innobase_change_buffering_inited_ok:
innodb_log_checksums = innodb_log_checksums_func_update(
NULL, innodb_log_checksums);
-#ifdef HAVE_LINUX_LARGE_PAGES
- if ((os_use_large_pages = my_use_large_pages)) {
- os_large_page_size = opt_large_page_size;
- }
-#endif
-
row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout;
srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog;
diff --git a/storage/innobase/include/os0proc.h b/storage/innobase/include/os0proc.h
index a73ba5a9e84..69d48c4d2f6 100644
--- a/storage/innobase/include/os0proc.h
+++ b/storage/innobase/include/os0proc.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation.
+Copyright (c) 2017, 2019, 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
@@ -42,12 +42,6 @@ typedef unsigned long int os_process_id_t;
system with os_mem_alloc_large(). */
extern ulint os_total_large_mem_allocated;
-/** Whether to use large pages in the buffer pool */
-extern my_bool os_use_large_pages;
-
-/** Large page size. This may be a boot-time option on some platforms */
-extern uint os_large_page_size;
-
/** Converts the current process id to a number.
@return process id as a number */
ulint
diff --git a/storage/innobase/os/os0proc.cc b/storage/innobase/os/os0proc.cc
index 0c8f8795be8..685bcef25db 100644
--- a/storage/innobase/os/os0proc.cc
+++ b/storage/innobase/os/os0proc.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2019, 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
@@ -25,6 +26,9 @@ Created 9/30/1995 Heikki Tuuri
*******************************************************/
#include "univ.i"
+#ifdef HAVE_LINUX_LARGE_PAGES
+# include "mysqld.h"
+#endif
/* FreeBSD for example has only MAP_ANON, Linux has MAP_ANONYMOUS and
MAP_ANON but MAP_ANON is marked as deprecated */
@@ -38,12 +42,6 @@ MAP_ANON but MAP_ANON is marked as deprecated */
system with os_mem_alloc_large(). */
ulint os_total_large_mem_allocated = 0;
-/** Whether to use large pages in the buffer pool */
-my_bool os_use_large_pages;
-
-/** Large page size. This may be a boot-time option on some platforms */
-uint os_large_page_size;
-
/** Converts the current process id to a number.
@return process id as a number */
ulint
@@ -66,18 +64,18 @@ os_mem_alloc_large(
{
void* ptr;
ulint size;
-#if defined HAVE_LINUX_LARGE_PAGES && defined UNIV_LINUX
+#ifdef HAVE_LINUX_LARGE_PAGES
int shmid;
struct shmid_ds buf;
- if (!os_use_large_pages || !os_large_page_size) {
+ if (!my_use_large_pages || !opt_large_page_size) {
goto skip;
}
- /* Align block size to os_large_page_size */
- ut_ad(ut_is_2pow(os_large_page_size));
- size = ut_2pow_round(*n + (os_large_page_size - 1),
- os_large_page_size);
+ /* Align block size to opt_large_page_size */
+ ut_ad(ut_is_2pow(opt_large_page_size));
+ size = ut_2pow_round(*n + opt_large_page_size - 1,
+ ulint(opt_large_page_size));
shmid = shmget(IPC_PRIVATE, (size_t) size, SHM_HUGETLB | SHM_R | SHM_W);
if (shmid < 0) {
@@ -109,7 +107,7 @@ os_mem_alloc_large(
ib::warn() << "Using conventional memory pool";
skip:
-#endif /* HAVE_LINUX_LARGE_PAGES && UNIV_LINUX */
+#endif /* HAVE_LINUX_LARGE_PAGES */
#ifdef _WIN32
SYSTEM_INFO system_info;
@@ -161,13 +159,13 @@ os_mem_free_large(
{
ut_a(os_total_large_mem_allocated >= size);
-#if defined HAVE_LINUX_LARGE_PAGES && defined UNIV_LINUX
- if (os_use_large_pages && os_large_page_size && !shmdt(ptr)) {
+#ifdef HAVE_LINUX_LARGE_PAGES
+ if (my_use_large_pages && opt_large_page_size && !shmdt(ptr)) {
my_atomic_addlint(
&os_total_large_mem_allocated, -size);
return;
}
-#endif /* HAVE_LINUX_LARGE_PAGES && UNIV_LINUX */
+#endif /* HAVE_LINUX_LARGE_PAGES */
#ifdef _WIN32
/* When RELEASE memory, the size parameter must be 0.
Do not use MEM_RELEASE with MEM_DECOMMIT. */