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.
This commit is contained in:
Jan Lindström 2014-02-26 13:49:50 +02:00
commit 752ba087c8
2 changed files with 28 additions and 8 deletions

View file

@ -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) {