mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 19:11:46 +01:00
branches/zip: buf_flush_write_block_low(): Avoid recomputing the compressed
page checksum of compressed-only blocks. Pass the compressed page frame to fil_io() when needed. page_zip_calc_checksum(): Skip also FIL_PAGE_LSN and FIL_PAGE_FILE_FLUSH_LSN. buf_flush_init_for_writing(): Expect page to be non-NULL.
This commit is contained in:
parent
361fe1a5b9
commit
b76c8a5a8d
3 changed files with 31 additions and 24 deletions
|
@ -601,12 +601,13 @@ Initializes a page for writing to the tablespace. */
|
|||
void
|
||||
buf_flush_init_for_writing(
|
||||
/*=======================*/
|
||||
byte* page, /* in/out: page, may be NULL
|
||||
if page_zip_ is non-NULL */
|
||||
byte* page, /* in/out: page */
|
||||
void* page_zip_, /* in/out: compressed page, or NULL */
|
||||
ib_uint64_t newest_lsn) /* in: newest modification lsn
|
||||
to the page */
|
||||
{
|
||||
ut_ad(page);
|
||||
|
||||
if (page_zip_) {
|
||||
page_zip_des_t* page_zip = page_zip_;
|
||||
ulint zip_size = page_zip_get_size(page_zip);
|
||||
|
@ -614,18 +615,14 @@ buf_flush_init_for_writing(
|
|||
ut_ad(ut_is_2pow(zip_size));
|
||||
ut_ad(zip_size <= UNIV_PAGE_SIZE);
|
||||
|
||||
switch (UNIV_EXPECT(fil_page_get_type(page
|
||||
? page : page_zip->data),
|
||||
FIL_PAGE_INDEX)) {
|
||||
switch (UNIV_EXPECT(fil_page_get_type(page), FIL_PAGE_INDEX)) {
|
||||
case FIL_PAGE_TYPE_ALLOCATED:
|
||||
case FIL_PAGE_INODE:
|
||||
case FIL_PAGE_IBUF_BITMAP:
|
||||
case FIL_PAGE_TYPE_FSP_HDR:
|
||||
case FIL_PAGE_TYPE_XDES:
|
||||
/* These are essentially uncompressed pages. */
|
||||
if (page) {
|
||||
memcpy(page_zip->data, page, zip_size);
|
||||
}
|
||||
memcpy(page_zip->data, page, zip_size);
|
||||
/* fall through */
|
||||
case FIL_PAGE_TYPE_ZBLOB:
|
||||
case FIL_PAGE_INDEX:
|
||||
|
@ -644,8 +641,6 @@ buf_flush_init_for_writing(
|
|||
ut_error;
|
||||
}
|
||||
|
||||
ut_ad(page);
|
||||
|
||||
/* Write the newest modification lsn to the page header and trailer */
|
||||
mach_write_ull(page + FIL_PAGE_LSN, newest_lsn);
|
||||
|
||||
|
@ -715,22 +710,24 @@ buf_flush_write_block_low(
|
|||
ut_error;
|
||||
break;
|
||||
case BUF_BLOCK_ZIP_DIRTY:
|
||||
frame = bpage->zip.data;
|
||||
if (UNIV_LIKELY(srv_use_checksums)) {
|
||||
ut_a(mach_read_from_4(bpage->zip.data
|
||||
+ FIL_PAGE_SPACE_OR_CHKSUM)
|
||||
== page_zip_calc_checksum(bpage->zip.data,
|
||||
zip_size));
|
||||
ut_a(mach_read_from_4(frame + FIL_PAGE_SPACE_OR_CHKSUM)
|
||||
== page_zip_calc_checksum(frame, zip_size));
|
||||
}
|
||||
mach_write_ull(frame + FIL_PAGE_LSN,
|
||||
bpage->newest_modification);
|
||||
memset(frame + FIL_PAGE_FILE_FLUSH_LSN, 0, 8);
|
||||
break;
|
||||
case BUF_BLOCK_FILE_PAGE:
|
||||
frame = ((buf_block_t*) bpage)->frame;
|
||||
buf_flush_init_for_writing(frame,
|
||||
bpage->zip.data
|
||||
? &bpage->zip : NULL,
|
||||
bpage->newest_modification);
|
||||
break;
|
||||
}
|
||||
|
||||
buf_flush_init_for_writing(frame,
|
||||
bpage->zip.data ? &bpage->zip : NULL,
|
||||
bpage->newest_modification);
|
||||
|
||||
if (!srv_use_doublewrite_buf || !trx_doublewrite) {
|
||||
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
|
||||
FALSE, buf_page_get_space(bpage), zip_size,
|
||||
|
|
|
@ -48,8 +48,7 @@ Initializes a page for writing to the tablespace. */
|
|||
void
|
||||
buf_flush_init_for_writing(
|
||||
/*=======================*/
|
||||
byte* page, /* in/out: page, may be NULL
|
||||
if page_zip_ is non-NULL */
|
||||
byte* page, /* in/out: page */
|
||||
void* page_zip_, /* in/out: compressed page, or NULL */
|
||||
ib_uint64_t newest_lsn); /* in: newest modification lsn
|
||||
to the page */
|
||||
|
|
|
@ -3729,8 +3729,19 @@ page_zip_calc_checksum(
|
|||
const void* data, /* in: compressed page */
|
||||
ulint size) /* in: size of compressed page */
|
||||
{
|
||||
/* Exclude the 32-bit checksum field from the checksum. */
|
||||
return((ulint) adler32(0,
|
||||
((const Bytef*) data) + FIL_PAGE_OFFSET,
|
||||
size - FIL_PAGE_OFFSET));
|
||||
/* Exclude FIL_PAGE_SPACE_OR_CHKSUM, FIL_PAGE_LSN,
|
||||
and FIL_PAGE_FILE_FLUSH_LSN from the checksum. */
|
||||
|
||||
const Bytef* s = data;
|
||||
uLong adler;
|
||||
|
||||
ut_ad(size > FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
|
||||
|
||||
adler = adler32(0L, s + FIL_PAGE_OFFSET,
|
||||
FIL_PAGE_LSN - FIL_PAGE_OFFSET);
|
||||
adler = adler32(adler, s + FIL_PAGE_TYPE, 2);
|
||||
adler = adler32(adler, s + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
|
||||
size - FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
|
||||
|
||||
return((ulint) adler);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue