Commit a0ce92dd authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent 81695ab8
...@@ -5016,10 +5016,12 @@ fil_extend_space_to_desired_size( ...@@ -5016,10 +5016,12 @@ fil_extend_space_to_desired_size(
const ulint file_start_page_no = space->size - node->size; const ulint file_start_page_no = space->size - node->size;
#ifdef HAVE_POSIX_FALLOCATE #ifdef HAVE_POSIX_FALLOCATE
if (srv_use_posix_fallocate) { if (srv_use_posix_fallocate) {
os_offset_t start_offset const os_offset_t start_offset
= (start_page_no - file_start_page_no) * page_size; = os_offset_t(start_page_no - file_start_page_no)
ulint n_pages = size_after_extend - start_page_no; * page_size;
os_offset_t len = os_offset_t(n_pages) * 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); int err = posix_fallocate(node->handle, start_offset, len);
success = !err; success = !err;
......
...@@ -5056,10 +5056,12 @@ fil_extend_space_to_desired_size( ...@@ -5056,10 +5056,12 @@ fil_extend_space_to_desired_size(
const ulint file_start_page_no = space->size - node->size; const ulint file_start_page_no = space->size - node->size;
#ifdef HAVE_POSIX_FALLOCATE #ifdef HAVE_POSIX_FALLOCATE
if (srv_use_posix_fallocate) { if (srv_use_posix_fallocate) {
os_offset_t start_offset const os_offset_t start_offset
= (start_page_no - file_start_page_no) * page_size; = os_offset_t(start_page_no - file_start_page_no)
ulint n_pages = size_after_extend - start_page_no; * page_size;
os_offset_t len = os_offset_t(n_pages) * 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); int err = posix_fallocate(node->handle, start_offset, len);
success = !err; success = !err;
......
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