mirror of
https://github.com/MariaDB/server.git
synced 2025-12-12 08:01:43 +03: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:
@@ -601,12 +601,13 @@ Initializes a page for writing to the tablespace. */
|
|||||||
void
|
void
|
||||||
buf_flush_init_for_writing(
|
buf_flush_init_for_writing(
|
||||||
/*=======================*/
|
/*=======================*/
|
||||||
byte* page, /* in/out: page, may be NULL
|
byte* page, /* in/out: page */
|
||||||
if page_zip_ is non-NULL */
|
|
||||||
void* page_zip_, /* in/out: compressed page, or NULL */
|
void* page_zip_, /* in/out: compressed page, or NULL */
|
||||||
ib_uint64_t newest_lsn) /* in: newest modification lsn
|
ib_uint64_t newest_lsn) /* in: newest modification lsn
|
||||||
to the page */
|
to the page */
|
||||||
{
|
{
|
||||||
|
ut_ad(page);
|
||||||
|
|
||||||
if (page_zip_) {
|
if (page_zip_) {
|
||||||
page_zip_des_t* page_zip = page_zip_;
|
page_zip_des_t* page_zip = page_zip_;
|
||||||
ulint zip_size = page_zip_get_size(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(ut_is_2pow(zip_size));
|
||||||
ut_ad(zip_size <= UNIV_PAGE_SIZE);
|
ut_ad(zip_size <= UNIV_PAGE_SIZE);
|
||||||
|
|
||||||
switch (UNIV_EXPECT(fil_page_get_type(page
|
switch (UNIV_EXPECT(fil_page_get_type(page), FIL_PAGE_INDEX)) {
|
||||||
? page : page_zip->data),
|
|
||||||
FIL_PAGE_INDEX)) {
|
|
||||||
case FIL_PAGE_TYPE_ALLOCATED:
|
case FIL_PAGE_TYPE_ALLOCATED:
|
||||||
case FIL_PAGE_INODE:
|
case FIL_PAGE_INODE:
|
||||||
case FIL_PAGE_IBUF_BITMAP:
|
case FIL_PAGE_IBUF_BITMAP:
|
||||||
case FIL_PAGE_TYPE_FSP_HDR:
|
case FIL_PAGE_TYPE_FSP_HDR:
|
||||||
case FIL_PAGE_TYPE_XDES:
|
case FIL_PAGE_TYPE_XDES:
|
||||||
/* These are essentially uncompressed pages. */
|
/* These are essentially uncompressed pages. */
|
||||||
if (page) {
|
|
||||||
memcpy(page_zip->data, page, zip_size);
|
memcpy(page_zip->data, page, zip_size);
|
||||||
}
|
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case FIL_PAGE_TYPE_ZBLOB:
|
case FIL_PAGE_TYPE_ZBLOB:
|
||||||
case FIL_PAGE_INDEX:
|
case FIL_PAGE_INDEX:
|
||||||
@@ -644,8 +641,6 @@ buf_flush_init_for_writing(
|
|||||||
ut_error;
|
ut_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ut_ad(page);
|
|
||||||
|
|
||||||
/* Write the newest modification lsn to the page header and trailer */
|
/* Write the newest modification lsn to the page header and trailer */
|
||||||
mach_write_ull(page + FIL_PAGE_LSN, newest_lsn);
|
mach_write_ull(page + FIL_PAGE_LSN, newest_lsn);
|
||||||
|
|
||||||
@@ -715,22 +710,24 @@ buf_flush_write_block_low(
|
|||||||
ut_error;
|
ut_error;
|
||||||
break;
|
break;
|
||||||
case BUF_BLOCK_ZIP_DIRTY:
|
case BUF_BLOCK_ZIP_DIRTY:
|
||||||
|
frame = bpage->zip.data;
|
||||||
if (UNIV_LIKELY(srv_use_checksums)) {
|
if (UNIV_LIKELY(srv_use_checksums)) {
|
||||||
ut_a(mach_read_from_4(bpage->zip.data
|
ut_a(mach_read_from_4(frame + FIL_PAGE_SPACE_OR_CHKSUM)
|
||||||
+ FIL_PAGE_SPACE_OR_CHKSUM)
|
== page_zip_calc_checksum(frame, zip_size));
|
||||||
== page_zip_calc_checksum(bpage->zip.data,
|
|
||||||
zip_size));
|
|
||||||
}
|
}
|
||||||
|
mach_write_ull(frame + FIL_PAGE_LSN,
|
||||||
|
bpage->newest_modification);
|
||||||
|
memset(frame + FIL_PAGE_FILE_FLUSH_LSN, 0, 8);
|
||||||
break;
|
break;
|
||||||
case BUF_BLOCK_FILE_PAGE:
|
case BUF_BLOCK_FILE_PAGE:
|
||||||
frame = ((buf_block_t*) bpage)->frame;
|
frame = ((buf_block_t*) bpage)->frame;
|
||||||
|
buf_flush_init_for_writing(frame,
|
||||||
|
bpage->zip.data
|
||||||
|
? &bpage->zip : NULL,
|
||||||
|
bpage->newest_modification);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf_flush_init_for_writing(frame,
|
|
||||||
bpage->zip.data ? &bpage->zip : NULL,
|
|
||||||
bpage->newest_modification);
|
|
||||||
|
|
||||||
if (!srv_use_doublewrite_buf || !trx_doublewrite) {
|
if (!srv_use_doublewrite_buf || !trx_doublewrite) {
|
||||||
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
|
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
|
||||||
FALSE, buf_page_get_space(bpage), zip_size,
|
FALSE, buf_page_get_space(bpage), zip_size,
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ Initializes a page for writing to the tablespace. */
|
|||||||
void
|
void
|
||||||
buf_flush_init_for_writing(
|
buf_flush_init_for_writing(
|
||||||
/*=======================*/
|
/*=======================*/
|
||||||
byte* page, /* in/out: page, may be NULL
|
byte* page, /* in/out: page */
|
||||||
if page_zip_ is non-NULL */
|
|
||||||
void* page_zip_, /* in/out: compressed page, or NULL */
|
void* page_zip_, /* in/out: compressed page, or NULL */
|
||||||
ib_uint64_t newest_lsn); /* in: newest modification lsn
|
ib_uint64_t newest_lsn); /* in: newest modification lsn
|
||||||
to the page */
|
to the page */
|
||||||
|
|||||||
@@ -3729,8 +3729,19 @@ page_zip_calc_checksum(
|
|||||||
const void* data, /* in: compressed page */
|
const void* data, /* in: compressed page */
|
||||||
ulint size) /* in: size of compressed page */
|
ulint size) /* in: size of compressed page */
|
||||||
{
|
{
|
||||||
/* Exclude the 32-bit checksum field from the checksum. */
|
/* Exclude FIL_PAGE_SPACE_OR_CHKSUM, FIL_PAGE_LSN,
|
||||||
return((ulint) adler32(0,
|
and FIL_PAGE_FILE_FLUSH_LSN from the checksum. */
|
||||||
((const Bytef*) data) + FIL_PAGE_OFFSET,
|
|
||||||
size - FIL_PAGE_OFFSET));
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user