Commit 365c4e97 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-11520/MDEV-5746 post-fix: Do not posix_fallocate() too much.

Before the MDEV-11520 fixes, fil_extend_space_to_desired_size()
in MariaDB Server 5.5 incorrectly passed the desired file size as the
third argument to posix_fallocate(), even though the length of the
extension should have been passed. This looks like a regression
that was introduced in the 5.5 version of MDEV-5746.
parent 6de50b2c
......@@ -4136,13 +4136,11 @@ fil_extend_space_to_desired_size(
#ifdef HAVE_POSIX_FALLOCATE
if (srv_use_posix_fallocate) {
ib_int64_t start_offset
= (start_page_no - file_start_page_no) * page_size;
ib_int64_t end_offset
= (size_after_extend - file_start_page_no) * page_size;
int err = posix_fallocate(
node->handle, start_offset, end_offset);
ib_int64_t len
= (size_after_extend - start_page_no) * page_size;
int err = posix_fallocate(node->handle, start_offset, len);
success = !err;
......@@ -4151,7 +4149,8 @@ fil_extend_space_to_desired_size(
"InnoDB: Error: extending file %s"
" from %lld to %lld bytes"
" failed with error %d\n",
node->name, start_offset, end_offset, err);
node->name,
start_offset, len + start_offset, err);
}
mutex_enter(&fil_system->mutex);
......
......@@ -4971,13 +4971,11 @@ fil_extend_space_to_desired_size(
#ifdef HAVE_POSIX_FALLOCATE
if (srv_use_posix_fallocate) {
ib_int64_t start_offset
= (start_page_no - file_start_page_no) * page_size;
ib_int64_t end_offset
= (size_after_extend - file_start_page_no) * page_size;
int err = posix_fallocate(
node->handle, start_offset, end_offset);
ib_int64_t len
= (size_after_extend - start_page_no) * page_size;
int err = posix_fallocate(node->handle, start_offset, len);
success = !err;
......@@ -4986,7 +4984,8 @@ fil_extend_space_to_desired_size(
"InnoDB: Error: extending file %s"
" from %lld to %lld bytes"
" failed with error %d\n",
node->name, start_offset, end_offset, err);
node->name,
start_offset, len + start_offset, err);
}
mutex_enter(&fil_system->mutex);
......
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