summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-02-22 12:32:17 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2017-02-22 12:32:17 +0200
commita0ce92ddc7d3f147c5103b9470d10bad194b41e4 (patch)
tree13c3dbf6d08b0470b02965c24c5a5e1944abf4bc
parent81695ab8b53013c302b50e015836d38146436cba (diff)
downloadmariadb-git-a0ce92ddc7d3f147c5103b9470d10bad194b41e4.tar.gz
MDEV-11520 post-fix
fil_extend_space_to_desired_size(): Use a proper type cast when computing start_offset for the posix_fallocate() call on 32-bit systems (where sizeof(ulint) < sizeof(os_offset_t)). This could affect 32-bit systems when extending files that are at least 4 MiB long. This bug existed in MariaDB 10.0 before MDEV-11520. In MariaDB 10.1 it had been fixed in MDEV-11556.
-rw-r--r--storage/innobase/fil/fil0fil.cc10
-rw-r--r--storage/xtradb/fil/fil0fil.cc10
2 files changed, 12 insertions, 8 deletions
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 874997cb005..b0d489cf701 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -5016,10 +5016,12 @@ retry:
const ulint file_start_page_no = space->size - node->size;
#ifdef HAVE_POSIX_FALLOCATE
if (srv_use_posix_fallocate) {
- os_offset_t start_offset
- = (start_page_no - file_start_page_no) * page_size;
- ulint n_pages = size_after_extend - start_page_no;
- os_offset_t len = os_offset_t(n_pages) * page_size;
+ const os_offset_t start_offset
+ = os_offset_t(start_page_no - file_start_page_no)
+ * page_size;
+ const ulint n_pages
+ = size_after_extend - start_page_no;
+ const os_offset_t len = os_offset_t(n_pages) * page_size;
int err = posix_fallocate(node->handle, start_offset, len);
success = !err;
diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc
index de6eef8f1d0..3b0b1da57e9 100644
--- a/storage/xtradb/fil/fil0fil.cc
+++ b/storage/xtradb/fil/fil0fil.cc
@@ -5056,10 +5056,12 @@ retry:
const ulint file_start_page_no = space->size - node->size;
#ifdef HAVE_POSIX_FALLOCATE
if (srv_use_posix_fallocate) {
- os_offset_t start_offset
- = (start_page_no - file_start_page_no) * page_size;
- ulint n_pages = size_after_extend - start_page_no;
- os_offset_t len = os_offset_t(n_pages) * page_size;
+ const os_offset_t start_offset
+ = os_offset_t(start_page_no - file_start_page_no)
+ * page_size;
+ const ulint n_pages
+ = size_after_extend - start_page_no;
+ const os_offset_t len = os_offset_t(n_pages) * page_size;
int err = posix_fallocate(node->handle, start_offset, len);
success = !err;