From a0ce92ddc7d3f147c5103b9470d10bad194b41e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 22 Feb 2017 12:32:17 +0200 Subject: [PATCH] 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. --- storage/innobase/fil/fil0fil.cc | 10 ++++++---- storage/xtradb/fil/fil0fil.cc | 10 ++++++---- 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;