Skip to content

Commit 8341f58

Browse files
committed
MDEV-15527 fixup for innodb_checksum_algorithm=full_crc32
1 parent 50de71b commit 8341f58

File tree

3 files changed

+38
-17
lines changed

3 files changed

+38
-17
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[strict_crc32]
2+
--innodb-checksum-algorithm=strict_crc32
3+
4+
[strict_full_crc32]
5+
--innodb-checksum-algorithm=strict_full_crc32
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[strict_crc32]
2+
--innodb-checksum-algorithm=strict_crc32
3+
4+
[strict_full_crc32]
5+
--innodb-checksum-algorithm=strict_full_crc32

storage/innobase/row/row0import.cc

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3355,26 +3355,30 @@ struct fil_iterator_t {
33553355
/** InnoDB writes page by page when there is page compressed
33563356
tablespace involved. It does help to save the disk space when
33573357
punch hole is enabled
3358-
@param iter Tablespace iterator
3358+
@param iter Tablespace iterator
3359+
@param full_crc32 whether the file is in the full_crc32 format
33593360
@param write_request Request to write into the file
3360-
@param offset offset of the file to be written
3361-
@param writeptr buffer to be written
3362-
@param n_bytes number of bytes to be written
3363-
@param try_punch_only Try the range punch only because the
3364-
current range is full of empty pages
3361+
@param offset offset of the file to be written
3362+
@param writeptr buffer to be written
3363+
@param n_bytes number of bytes to be written
3364+
@param try_punch_only Try the range punch only because the
3365+
current range is full of empty pages
33653366
@return DB_SUCCESS */
33663367
static
33673368
dberr_t fil_import_compress_fwrite(const fil_iterator_t &iter,
3369+
bool full_crc32,
33683370
const IORequest &write_request,
33693371
os_offset_t offset,
33703372
const byte *writeptr,
33713373
ulint n_bytes,
33723374
bool try_punch_only= false)
33733375
{
3374-
dberr_t err= os_file_punch_hole(iter.file, offset, n_bytes);
3375-
if (err != DB_SUCCESS || try_punch_only)
3376+
if (dberr_t err= os_file_punch_hole(iter.file, offset, n_bytes))
33763377
return err;
33773378

3379+
if (try_punch_only)
3380+
return DB_SUCCESS;
3381+
33783382
for (ulint j= 0; j < n_bytes; j+= srv_page_size)
33793383
{
33803384
/* Read the original data length from block and
@@ -3384,20 +3388,27 @@ dberr_t fil_import_compress_fwrite(const fil_iterator_t &iter,
33843388
if (j || offset)
33853389
{
33863390
n_write_bytes= mach_read_from_2(writeptr + j + FIL_PAGE_DATA);
3387-
const unsigned ptype= mach_read_from_2(writeptr + j + FIL_PAGE_TYPE);
3391+
const unsigned ptype= mach_read_from_2(writeptr + j + FIL_PAGE_TYPE);
33883392
/* Ignore the empty page */
33893393
if (ptype == 0 && n_write_bytes == 0)
33903394
continue;
3391-
n_write_bytes+= FIL_PAGE_DATA + FIL_PAGE_ENCRYPT_COMP_METADATA_LEN;
3395+
if (full_crc32)
3396+
n_write_bytes= buf_page_full_crc32_size(writeptr + j,
3397+
nullptr, nullptr);
3398+
else
3399+
{
3400+
n_write_bytes+= ptype == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED
3401+
? FIL_PAGE_DATA + FIL_PAGE_ENCRYPT_COMP_METADATA_LEN
3402+
: FIL_PAGE_DATA + FIL_PAGE_COMP_METADATA_LEN;
3403+
}
33923404
}
33933405

3394-
err= os_file_write(write_request, iter.filepath, iter.file,
3395-
writeptr + j, offset + j, n_write_bytes);
3396-
if (err != DB_SUCCESS)
3397-
break;
3406+
if (dberr_t err= os_file_write(write_request, iter.filepath, iter.file,
3407+
writeptr + j, offset + j, n_write_bytes))
3408+
return err;
33983409
}
33993410

3400-
return err;
3411+
return DB_SUCCESS;
34013412
}
34023413

34033414
/********************************************************************//**
@@ -3721,8 +3732,8 @@ fil_iterate(
37213732

37223733
if (page_compressed && punch_hole) {
37233734
err = fil_import_compress_fwrite(
3724-
iter, write_request, offset, writeptr, n_bytes,
3725-
!updated);
3735+
iter, full_crc32, write_request, offset,
3736+
writeptr, n_bytes, !updated);
37263737

37273738
if (err != DB_SUCCESS) {
37283739
punch_hole = false;

0 commit comments

Comments
 (0)