Skip to content

Commit a0ce92d

Browse files
committed
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.
1 parent 81695ab commit a0ce92d

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

storage/innobase/fil/fil0fil.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5016,10 +5016,12 @@ fil_extend_space_to_desired_size(
50165016
const ulint file_start_page_no = space->size - node->size;
50175017
#ifdef HAVE_POSIX_FALLOCATE
50185018
if (srv_use_posix_fallocate) {
5019-
os_offset_t start_offset
5020-
= (start_page_no - file_start_page_no) * page_size;
5021-
ulint n_pages = size_after_extend - start_page_no;
5022-
os_offset_t len = os_offset_t(n_pages) * page_size;
5019+
const os_offset_t start_offset
5020+
= os_offset_t(start_page_no - file_start_page_no)
5021+
* page_size;
5022+
const ulint n_pages
5023+
= size_after_extend - start_page_no;
5024+
const os_offset_t len = os_offset_t(n_pages) * page_size;
50235025

50245026
int err = posix_fallocate(node->handle, start_offset, len);
50255027
success = !err;

storage/xtradb/fil/fil0fil.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5056,10 +5056,12 @@ fil_extend_space_to_desired_size(
50565056
const ulint file_start_page_no = space->size - node->size;
50575057
#ifdef HAVE_POSIX_FALLOCATE
50585058
if (srv_use_posix_fallocate) {
5059-
os_offset_t start_offset
5060-
= (start_page_no - file_start_page_no) * page_size;
5061-
ulint n_pages = size_after_extend - start_page_no;
5062-
os_offset_t len = os_offset_t(n_pages) * page_size;
5059+
const os_offset_t start_offset
5060+
= os_offset_t(start_page_no - file_start_page_no)
5061+
* page_size;
5062+
const ulint n_pages
5063+
= size_after_extend - start_page_no;
5064+
const os_offset_t len = os_offset_t(n_pages) * page_size;
50635065

50645066
int err = posix_fallocate(node->handle, start_offset, len);
50655067
success = !err;

0 commit comments

Comments
 (0)