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

current offset to desired size if posix_fallocate is used.
This commit is contained in:
Jan Lindström 2014-02-06 17:49:55 +02:00
parent 7f3950a2ae
commit 18353c6a4d
2 changed files with 26 additions and 35 deletions
storage
innobase/fil
xtradb/fil

View file

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

View file

@ -4988,27 +4988,24 @@ retry:
#ifdef HAVE_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);
/* Temporal solution: In directFS using atomic writes
we must use posix_fallocate to extend the file because
pwrite past end of file fails but when compression is
used the file pages must be physically initialized with
zeroes, thus after file extend with posix_fallocate
we still write empty pages to file. */
if (success &&
srv_use_atomic_writes &&
srv_compress_pages) {
goto extend_file;
if (posix_fallocate(node->handle, start_offset, end_offset) == -1) {
ib_logf(IB_LOG_LEVEL_ERROR, "preallocating file "
"space for file \'%s\' failed. Current size "
INT64PF ", desired size " INT64PF "\n",
node->name, start_offset, end_offset);
success = FALSE;
} else {
success = TRUE;
}
mutex_enter(&fil_system->mutex);
if (success) {
node->size += n_pages;
space->size += n_pages;
node->size += (size_after_extend - start_page_no);
space->size += (size_after_extend - start_page_no);
os_has_said_disk_full = FALSE;
}
@ -5022,8 +5019,6 @@ retry:
}
#endif
extend_file:
/* Extend at most 64 pages at a time */
buf_size = ut_min(64, size_after_extend - start_page_no) * page_size;
buf2 = static_cast<byte*>(mem_alloc(buf_size + page_size));