summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-03-31 10:55:21 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-03-31 10:55:21 +0300
commit8341f582b2fe864027954282f96fb84e560cae72 (patch)
tree258c4f230fc9bf8afb696f26c799ef511aa7a40f
parent50de71b026ddb560db2be14a06897874a5732dac (diff)
downloadmariadb-git-8341f582b2fe864027954282f96fb84e560cae72.tar.gz
MDEV-15527 fixup for innodb_checksum_algorithm=full_crc32
-rw-r--r--mysql-test/suite/encryption/t/innodb-discard-import-change.combinations5
-rw-r--r--mysql-test/suite/encryption/t/innodb-discard-import.combinations5
-rw-r--r--storage/innobase/row/row0import.cc45
3 files changed, 38 insertions, 17 deletions
diff --git a/mysql-test/suite/encryption/t/innodb-discard-import-change.combinations b/mysql-test/suite/encryption/t/innodb-discard-import-change.combinations
new file mode 100644
index 00000000000..729380593f3
--- /dev/null
+++ b/mysql-test/suite/encryption/t/innodb-discard-import-change.combinations
@@ -0,0 +1,5 @@
+[strict_crc32]
+--innodb-checksum-algorithm=strict_crc32
+
+[strict_full_crc32]
+--innodb-checksum-algorithm=strict_full_crc32
diff --git a/mysql-test/suite/encryption/t/innodb-discard-import.combinations b/mysql-test/suite/encryption/t/innodb-discard-import.combinations
new file mode 100644
index 00000000000..729380593f3
--- /dev/null
+++ b/mysql-test/suite/encryption/t/innodb-discard-import.combinations
@@ -0,0 +1,5 @@
+[strict_crc32]
+--innodb-checksum-algorithm=strict_crc32
+
+[strict_full_crc32]
+--innodb-checksum-algorithm=strict_full_crc32
diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc
index 632406624e1..ed834a48af5 100644
--- a/storage/innobase/row/row0import.cc
+++ b/storage/innobase/row/row0import.cc
@@ -3355,26 +3355,30 @@ struct fil_iterator_t {
/** InnoDB writes page by page when there is page compressed
tablespace involved. It does help to save the disk space when
punch hole is enabled
-@param iter Tablespace iterator
+@param iter Tablespace iterator
+@param full_crc32 whether the file is in the full_crc32 format
@param write_request Request to write into the file
-@param offset offset of the file to be written
-@param writeptr buffer to be written
-@param n_bytes number of bytes to be written
-@param try_punch_only Try the range punch only because the
- current range is full of empty pages
+@param offset offset of the file to be written
+@param writeptr buffer to be written
+@param n_bytes number of bytes to be written
+@param try_punch_only Try the range punch only because the
+ current range is full of empty pages
@return DB_SUCCESS */
static
dberr_t fil_import_compress_fwrite(const fil_iterator_t &iter,
+ bool full_crc32,
const IORequest &write_request,
os_offset_t offset,
const byte *writeptr,
ulint n_bytes,
bool try_punch_only= false)
{
- dberr_t err= os_file_punch_hole(iter.file, offset, n_bytes);
- if (err != DB_SUCCESS || try_punch_only)
+ if (dberr_t err= os_file_punch_hole(iter.file, offset, n_bytes))
return err;
+ if (try_punch_only)
+ return DB_SUCCESS;
+
for (ulint j= 0; j < n_bytes; j+= srv_page_size)
{
/* Read the original data length from block and
@@ -3384,20 +3388,27 @@ dberr_t fil_import_compress_fwrite(const fil_iterator_t &iter,
if (j || offset)
{
n_write_bytes= mach_read_from_2(writeptr + j + FIL_PAGE_DATA);
- const unsigned ptype= mach_read_from_2(writeptr + j + FIL_PAGE_TYPE);
+ const unsigned ptype= mach_read_from_2(writeptr + j + FIL_PAGE_TYPE);
/* Ignore the empty page */
if (ptype == 0 && n_write_bytes == 0)
continue;
- n_write_bytes+= FIL_PAGE_DATA + FIL_PAGE_ENCRYPT_COMP_METADATA_LEN;
+ if (full_crc32)
+ n_write_bytes= buf_page_full_crc32_size(writeptr + j,
+ nullptr, nullptr);
+ else
+ {
+ n_write_bytes+= ptype == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED
+ ? FIL_PAGE_DATA + FIL_PAGE_ENCRYPT_COMP_METADATA_LEN
+ : FIL_PAGE_DATA + FIL_PAGE_COMP_METADATA_LEN;
+ }
}
- err= os_file_write(write_request, iter.filepath, iter.file,
- writeptr + j, offset + j, n_write_bytes);
- if (err != DB_SUCCESS)
- break;
+ if (dberr_t err= os_file_write(write_request, iter.filepath, iter.file,
+ writeptr + j, offset + j, n_write_bytes))
+ return err;
}
- return err;
+ return DB_SUCCESS;
}
/********************************************************************//**
@@ -3721,8 +3732,8 @@ not_encrypted:
if (page_compressed && punch_hole) {
err = fil_import_compress_fwrite(
- iter, write_request, offset, writeptr, n_bytes,
- !updated);
+ iter, full_crc32, write_request, offset,
+ writeptr, n_bytes, !updated);
if (err != DB_SUCCESS) {
punch_hole = false;