mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 11:57:38 +02:00
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:
parent
e479829a15
commit
752ba087c8
2 changed files with 28 additions and 8 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue