summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff2
-rw-r--r--storage/innobase/fil/fil0fil.cc12
-rw-r--r--storage/innobase/os/os0file.cc7
3 files changed, 13 insertions, 8 deletions
diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff
index 52cd6832755..e7760461abb 100644
--- a/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff
+++ b/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff
@@ -21,5 +21,5 @@
+# bytes: 16384
INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20;
-# bytes: 65536
-+# bytes: 25600
++# bytes: 24576
DROP TABLE t1;
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index a0542825891..cfd16f5996e 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -980,11 +980,15 @@ fil_space_extend_must_retry(
const page_size_t pageSize(space->flags);
const ulint page_size = pageSize.physical();
- /* fil_read_first_page() expects UNIV_PAGE_SIZE bytes.
- fil_node_open_file() expects at least 4 * UNIV_PAGE_SIZE bytes.*/
+ /* fil_read_first_page() expects innodb_page_size bytes.
+ fil_node_open_file() expects at least 4 * innodb_page_size bytes.
+ os_file_set_size() expects multiples of 4096 bytes.
+ For ROW_FORMAT=COMPRESSED tables using 1024-byte or 2048-byte
+ pages, we will preallocate up to an integer multiple of 4096 bytes,
+ and let normal writes append 1024, 2048, or 3072 bytes to the file. */
os_offset_t new_size = std::max(
- os_offset_t(size - file_start_page_no) * page_size,
- os_offset_t(FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE));
+ (os_offset_t(size - file_start_page_no) * page_size) & ~4095,
+ os_offset_t(FIL_IBD_FILE_INITIAL_SIZE << srv_page_size_shift));
*success = os_file_set_size(node->name, node->handle, new_size,
FSP_FLAGS_HAS_PAGE_COMPRESSION(space->flags));
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index a793f9b30cb..48be5256ab1 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -5405,6 +5405,8 @@ os_file_set_size(
os_offset_t size,
bool is_sparse)
{
+ ut_ad(!(size & 4095));
+
#ifdef _WIN32
/* On Windows, changing file size works well and as expected for both
sparse and normal files.
@@ -5446,7 +5448,7 @@ fallback:
if (current_size >= size) {
return true;
}
- current_size &= ~os_offset_t(statbuf.st_blksize - 1);
+ current_size &= ~4095ULL;
err = posix_fallocate(file, current_size,
size - current_size);
}
@@ -5486,8 +5488,7 @@ fallback:
if (fstat(file, &statbuf)) {
return false;
}
- os_offset_t current_size = statbuf.st_size
- & ~os_offset_t(statbuf.st_blksize - 1);
+ os_offset_t current_size = statbuf.st_size & ~4095ULL;
#endif
if (current_size >= size) {
return true;