Commit 18353c6a authored by Jan Lindström's avatar Jan Lindström

Fixed issue on file space extension. File space should be extended from

current offset to desired size if posix_fallocate is used.
parent 7f3950a2
...@@ -48,6 +48,7 @@ Created 10/25/1995 Heikki Tuuri ...@@ -48,6 +48,7 @@ Created 10/25/1995 Heikki Tuuri
#include "page0zip.h" #include "page0zip.h"
#include "trx0sys.h" #include "trx0sys.h"
#include "row0mysql.h" #include "row0mysql.h"
#include "os0file.h"
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
# include "buf0lru.h" # include "buf0lru.h"
# include "ibuf0ibuf.h" # include "ibuf0ibuf.h"
...@@ -4860,28 +4861,25 @@ retry: ...@@ -4860,28 +4861,25 @@ retry:
#ifdef HAVE_POSIX_FALLOCATE #ifdef HAVE_POSIX_FALLOCATE
if (srv_use_posix_fallocate) { if (srv_use_posix_fallocate) {
ulint n_pages = size_after_extend; os_offset_t start_offset = start_page_no * page_size;
os_offset_t end_offset = (size_after_extend - start_page_no) * page_size;
success = os_file_set_size(node->name, node->handle,
n_pages * page_size); if (posix_fallocate(node->handle, start_offset, end_offset) == -1) {
ib_logf(IB_LOG_LEVEL_ERROR, "preallocating file "
/* Temporal solution: In directFS using atomic writes "space for file \'%s\' failed. Current size "
we must use posix_fallocate to extend the file because INT64PF ", desired size " INT64PF "\n",
pwrite past end of file fails but when compression is node->name, start_offset, end_offset);
used the file pages must be physically initialized with success = FALSE;
zeroes, thus after file extend with posix_fallocate } else {
we still write empty pages to file. */ success = TRUE;
if (success &&
srv_use_atomic_writes &&
srv_compress_pages) {
goto extend_file;
} }
mutex_enter(&fil_system->mutex); mutex_enter(&fil_system->mutex);
if (success) { if (success) {
node->size += n_pages; node->size += (size_after_extend - start_page_no);
space->size += n_pages; space->size += (size_after_extend - start_page_no);
os_has_said_disk_full = FALSE; os_has_said_disk_full = FALSE;
} }
...@@ -4895,8 +4893,6 @@ retry: ...@@ -4895,8 +4893,6 @@ retry:
} }
#endif #endif
extend_file:
/* Extend at most 64 pages at a time */ /* Extend at most 64 pages at a time */
buf_size = ut_min(64, size_after_extend - start_page_no) * page_size; buf_size = ut_min(64, size_after_extend - start_page_no) * page_size;
buf2 = static_cast<byte*>(mem_alloc(buf_size + page_size)); buf2 = static_cast<byte*>(mem_alloc(buf_size + page_size));
......
...@@ -4988,27 +4988,24 @@ retry: ...@@ -4988,27 +4988,24 @@ retry:
#ifdef HAVE_POSIX_FALLOCATE #ifdef HAVE_POSIX_FALLOCATE
if (srv_use_posix_fallocate) { if (srv_use_posix_fallocate) {
ulint n_pages = size_after_extend; os_offset_t start_offset = start_page_no * page_size;
os_offset_t end_offset = (size_after_extend - start_page_no) * page_size;
success = os_file_set_size(node->name, node->handle, n_pages * page_size);
if (posix_fallocate(node->handle, start_offset, end_offset) == -1) {
/* Temporal solution: In directFS using atomic writes ib_logf(IB_LOG_LEVEL_ERROR, "preallocating file "
we must use posix_fallocate to extend the file because "space for file \'%s\' failed. Current size "
pwrite past end of file fails but when compression is INT64PF ", desired size " INT64PF "\n",
used the file pages must be physically initialized with node->name, start_offset, end_offset);
zeroes, thus after file extend with posix_fallocate success = FALSE;
we still write empty pages to file. */ } else {
if (success && success = TRUE;
srv_use_atomic_writes &&
srv_compress_pages) {
goto extend_file;
} }
mutex_enter(&fil_system->mutex); mutex_enter(&fil_system->mutex);
if (success) { if (success) {
node->size += n_pages; node->size += (size_after_extend - start_page_no);
space->size += n_pages; space->size += (size_after_extend - start_page_no);
os_has_said_disk_full = FALSE; os_has_said_disk_full = FALSE;
} }
...@@ -5022,8 +5019,6 @@ retry: ...@@ -5022,8 +5019,6 @@ retry:
} }
#endif #endif
extend_file:
/* Extend at most 64 pages at a time */ /* Extend at most 64 pages at a time */
buf_size = ut_min(64, size_after_extend - start_page_no) * page_size; buf_size = ut_min(64, size_after_extend - start_page_no) * page_size;
buf2 = static_cast<byte*>(mem_alloc(buf_size + page_size)); buf2 = static_cast<byte*>(mem_alloc(buf_size + page_size));
......
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