Commit 752ba087 authored by Jan Lindström's avatar Jan Lindström

MDEV-5746: Slow file extend when innodb_use_fallocate=1 and SSD

file storage.

Analysis: posix_fallocate was called using 0 as offset and len as
desired size. This is not optimal for SSDs.

Fix: Call posix_fallocate with correct offset i.e. current file size
and extend the file from there len bytes.
parent e479829a
......@@ -4110,12 +4110,22 @@ fil_extend_space_to_desired_size(
#ifdef HAVE_POSIX_FALLOCATE
if (srv_use_posix_fallocate) {
offset_high = size_after_extend * page_size / (4ULL*1024*1024*1024);
offset_low = size_after_extend * page_size % (4ULL*1024*1024*1024);
ib_int64_t start_offset = start_page_no * page_size;
ib_int64_t end_offset = (size_after_extend - start_page_no) * page_size;
ib_int64_t desired_size = size_after_extend*page_size;
mutex_exit(&fil_system->mutex);
success = os_file_set_size(node->name, node->handle,
offset_low, offset_high);
if (posix_fallocate(node->handle, start_offset, end_offset) == -1) {
fprintf(stderr, "InnoDB: Error: preallocating file "
"space for file \'%s\' failed. Current size "
" %lld, len %lld, desired size %lld\n",
node->name, start_offset, end_offset, desired_size);
success = FALSE;
} else {
success = TRUE;
}
mutex_enter(&fil_system->mutex);
if (success) {
......
......@@ -4953,12 +4953,22 @@ fil_extend_space_to_desired_size(
#ifdef HAVE_POSIX_FALLOCATE
if (srv_use_posix_fallocate) {
offset_high = size_after_extend * page_size / (4ULL*1024*1024*1024);
offset_low = size_after_extend * page_size % (4ULL*1024*1024*1024);
ib_int64_t start_offset = start_page_no * page_size;
ib_int64_t end_offset = (size_after_extend - start_page_no) * page_size;
ib_int64_t desired_size = size_after_extend*page_size;
mutex_exit(&fil_system->mutex);
success = os_file_set_size(node->name, node->handle,
offset_low, offset_high);
if (posix_fallocate(node->handle, start_offset, end_offset) == -1) {
fprintf(stderr, "InnoDB: Error: preallocating file "
"space for file \'%s\' failed. Current size "
" %lld, len %lld, desired size %lld\n",
node->name, start_offset, end_offset, desired_size);
success = FALSE;
} else {
success = TRUE;
}
mutex_enter(&fil_system->mutex);
if (success) {
......
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