@@ -3355,26 +3355,30 @@ struct fil_iterator_t {
3355
3355
/* * InnoDB writes page by page when there is page compressed
3356
3356
tablespace involved. It does help to save the disk space when
3357
3357
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
3359
3360
@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
3365
3366
@return DB_SUCCESS */
3366
3367
static
3367
3368
dberr_t fil_import_compress_fwrite (const fil_iterator_t &iter,
3369
+ bool full_crc32,
3368
3370
const IORequest &write_request,
3369
3371
os_offset_t offset,
3370
3372
const byte *writeptr,
3371
3373
ulint n_bytes,
3372
3374
bool try_punch_only= false )
3373
3375
{
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))
3376
3377
return err;
3377
3378
3379
+ if (try_punch_only)
3380
+ return DB_SUCCESS;
3381
+
3378
3382
for (ulint j= 0 ; j < n_bytes; j+= srv_page_size)
3379
3383
{
3380
3384
/* Read the original data length from block and
@@ -3384,20 +3388,27 @@ dberr_t fil_import_compress_fwrite(const fil_iterator_t &iter,
3384
3388
if (j || offset)
3385
3389
{
3386
3390
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);
3388
3392
/* Ignore the empty page */
3389
3393
if (ptype == 0 && n_write_bytes == 0 )
3390
3394
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
+ }
3392
3404
}
3393
3405
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;
3398
3409
}
3399
3410
3400
- return err ;
3411
+ return DB_SUCCESS ;
3401
3412
}
3402
3413
3403
3414
/* *******************************************************************/ /* *
@@ -3721,8 +3732,8 @@ fil_iterate(
3721
3732
3722
3733
if (page_compressed && punch_hole) {
3723
3734
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);
3726
3737
3727
3738
if (err != DB_SUCCESS) {
3728
3739
punch_hole = false ;
0 commit comments