diff options
-rw-r--r-- | storage/innobase/fil/fil0fil.cc | 35 | ||||
-rw-r--r-- | storage/innobase/log/log0recv.cc | 12 |
2 files changed, 31 insertions, 16 deletions
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 3ebf0cc04dc..91e4df7ca26 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -577,7 +577,7 @@ fil_space_extend_must_retry( os_offset_t(FIL_IBD_FILE_INITIAL_SIZE << srv_page_size_shift)); *success = os_file_set_size(node->name, node->handle, new_size, - space->is_compressed()); + node->punch_hole == 1); os_has_said_disk_full = *success; if (*success) { @@ -2024,24 +2024,17 @@ fil_ibd_create( } const bool is_compressed = fil_space_t::is_compressed(flags); - fil_space_crypt_t* crypt_data = nullptr; #ifdef _WIN32 + const bool is_sparse = is_compressed; if (is_compressed) { os_file_set_sparse_win32(file); } +#else + const bool is_sparse = is_compressed + && DB_SUCCESS == os_file_punch_hole(file, 0, 4096) + && !my_test_if_thinly_provisioned(file); #endif - if (!os_file_set_size( - path, file, - os_offset_t(size) << srv_page_size_shift, is_compressed)) { - *err = DB_OUT_OF_FILE_SPACE; -err_exit: - os_file_close(file); - os_file_delete(innodb_data_file_key, path); - free(crypt_data); - return NULL; - } - if (fil_space_t::full_crc32(flags)) { flags |= FSP_FLAGS_FCRC32_PAGE_SSIZE(); } else { @@ -2050,9 +2043,21 @@ err_exit: /* Create crypt data if the tablespace is either encrypted or user has requested it to remain unencrypted. */ - crypt_data = (mode != FIL_ENCRYPTION_DEFAULT || srv_encrypt_tables) + fil_space_crypt_t* crypt_data = (mode != FIL_ENCRYPTION_DEFAULT + || srv_encrypt_tables) ? fil_space_create_crypt_data(mode, key_id) - : NULL; + : nullptr; + + if (!os_file_set_size(path, file, + os_offset_t(size) << srv_page_size_shift, + is_sparse)) { + *err = DB_OUT_OF_FILE_SPACE; +err_exit: + os_file_close(file); + os_file_delete(innodb_data_file_key, path); + free(crypt_data); + return nullptr; + } fil_space_t::name_type space_name; diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 16250928845..f1e1c350135 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -839,9 +839,19 @@ bool recv_sys_t::recover_deferred(recv_sys_t::map::iterator &p, node->deferred= true; if (!space->acquire()) goto fail; + const bool is_compressed= fil_space_t::is_compressed(flags); +#ifdef _WIN32 + const bool is_sparse= is_compressed; + if (is_compressed) + os_file_set_sparse_win32(node->handle); +#else + const bool is_sparse= is_compressed && + DB_SUCCESS == os_file_punch_hole(node->handle, 0, 4096) && + !my_test_if_thinly_provisioned(node->handle); +#endif if (!os_file_set_size(node->name, node->handle, size * fil_space_t::physical_size(flags), - space->is_compressed())) + is_sparse)) { space->release(); goto fail; |