Commit 0c19de98 authored by marko's avatar marko

branches/zip: buf_page_io_complete(): Change the parameter type from

buf_block_t* to buf_page_t*.  Handle compressed-only blocks.
parent fbae0bac
...@@ -2375,13 +2375,13 @@ the buffer pool. */ ...@@ -2375,13 +2375,13 @@ the buffer pool. */
void void
buf_page_io_complete( buf_page_io_complete(
/*=================*/ /*=================*/
buf_block_t* block) /* in: pointer to the block in question */ buf_page_t* bpage) /* in: pointer to the block in question */
{ {
enum buf_io_fix io_type; enum buf_io_fix io_type;
const ibool uncompressed = (buf_page_get_state(bpage)
== BUF_BLOCK_FILE_PAGE);
ut_ad(block); ut_a(buf_page_in_file(bpage));
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
/* We do not need protect io_fix here by mutex to read /* We do not need protect io_fix here by mutex to read
it because this is the only function where we can change the value it because this is the only function where we can change the value
...@@ -2389,22 +2389,25 @@ buf_page_io_complete( ...@@ -2389,22 +2389,25 @@ buf_page_io_complete(
ensures that this is the only thread that handles the i/o for this ensures that this is the only thread that handles the i/o for this
block. */ block. */
io_type = buf_block_get_io_fix(block); io_type = buf_page_get_io_fix(bpage);
ut_ad(io_type == BUF_IO_READ || io_type == BUF_IO_WRITE);
if (io_type == BUF_IO_READ) { if (io_type == BUF_IO_READ) {
ulint read_page_no; ulint read_page_no;
ulint read_space_id; ulint read_space_id;
byte* frame; byte* frame;
if (buf_block_get_zip_size(block)) { if (buf_page_get_zip_size(bpage)) {
frame = block->page.zip.data; frame = bpage->zip.data;
if (uncompressed
if (!buf_zip_decompress(block, FALSE)) { && !buf_zip_decompress((buf_block_t*) bpage,
FALSE)) {
goto corrupt; goto corrupt;
} }
} else { } else {
frame = block->frame; ut_a(uncompressed);
frame = ((buf_block_t*) bpage)->frame;
} }
/* If this page is not uninitialized and not in the /* If this page is not uninitialized and not in the
...@@ -2414,25 +2417,24 @@ buf_page_io_complete( ...@@ -2414,25 +2417,24 @@ buf_page_io_complete(
read_space_id = mach_read_from_4( read_space_id = mach_read_from_4(
frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
if (buf_block_get_space(block) == TRX_SYS_SPACE if (bpage->space == TRX_SYS_SPACE
&& trx_doublewrite_page_inside( && trx_doublewrite_page_inside(bpage->offset)) {
buf_block_get_page_no(block))) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Error: reading page %lu\n" " InnoDB: Error: reading page %lu\n"
"InnoDB: which is in the" "InnoDB: which is in the"
" doublewrite buffer!\n", " doublewrite buffer!\n",
(ulong) buf_block_get_page_no(block)); (ulong) bpage->offset);
} else if (!read_space_id && !read_page_no) { } else if (!read_space_id && !read_page_no) {
/* This is likely an uninitialized page. */ /* This is likely an uninitialized page. */
} else if ((block->page.space } else if ((bpage->space
&& block->page.space != read_space_id) && bpage->space != read_space_id)
|| block->page.offset != read_page_no) { || bpage->offset != read_page_no) {
/* We did not compare space_id to read_space_id /* We did not compare space_id to read_space_id
if block->page.space == 0, because the field on the if bpage->space == 0, because the field on the
page may contain garbage in MySQL < 4.1.1, page may contain garbage in MySQL < 4.1.1,
which only supported block->page.space == 0. */ which only supported bpage->space == 0. */
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
...@@ -2441,15 +2443,15 @@ buf_page_io_complete( ...@@ -2441,15 +2443,15 @@ buf_page_io_complete(
"InnoDB: read in are %lu:%lu," "InnoDB: read in are %lu:%lu,"
" should be %lu:%lu!\n", " should be %lu:%lu!\n",
(ulong) read_space_id, (ulong) read_page_no, (ulong) read_space_id, (ulong) read_page_no,
(ulong) block->page.space, (ulong) bpage->space,
(ulong) block->page.offset); (ulong) bpage->offset);
} }
/* From version 3.23.38 up we store the page checksum /* From version 3.23.38 up we store the page checksum
to the 4 first bytes of the page end lsn field */ to the 4 first bytes of the page end lsn field */
if (buf_page_is_corrupted(frame, if (buf_page_is_corrupted(frame,
buf_block_get_zip_size(block))) { buf_page_get_zip_size(bpage))) {
corrupt: corrupt:
fprintf(stderr, fprintf(stderr,
"InnoDB: Database page corruption on disk" "InnoDB: Database page corruption on disk"
...@@ -2457,15 +2459,15 @@ buf_page_io_complete( ...@@ -2457,15 +2459,15 @@ buf_page_io_complete(
"InnoDB: file read of page %lu.\n" "InnoDB: file read of page %lu.\n"
"InnoDB: You may have to recover" "InnoDB: You may have to recover"
" from a backup.\n", " from a backup.\n",
(ulong) block->page.offset); (ulong) bpage->offset);
buf_page_print(frame, buf_block_get_zip_size(block)); buf_page_print(frame, buf_page_get_zip_size(bpage));
fprintf(stderr, fprintf(stderr,
"InnoDB: Database page corruption on disk" "InnoDB: Database page corruption on disk"
" or a failed\n" " or a failed\n"
"InnoDB: file read of page %lu.\n" "InnoDB: file read of page %lu.\n"
"InnoDB: You may have to recover" "InnoDB: You may have to recover"
" from a backup.\n", " from a backup.\n",
(ulong) block->page.offset); (ulong) bpage->offset);
fputs("InnoDB: It is also possible that" fputs("InnoDB: It is also possible that"
" your operating\n" " your operating\n"
"InnoDB: system has corrupted its" "InnoDB: system has corrupted its"
...@@ -2496,31 +2498,34 @@ buf_page_io_complete( ...@@ -2496,31 +2498,34 @@ buf_page_io_complete(
} }
if (recv_recovery_is_on()) { if (recv_recovery_is_on()) {
recv_recover_page(FALSE, TRUE, block); /* Pages must be uncompressed for crash recovery. */
ut_a(uncompressed);
recv_recover_page(FALSE, TRUE, (buf_block_t*) bpage);
} }
if (!recv_no_ibuf_operations) { if (uncompressed && !recv_no_ibuf_operations) {
ibuf_merge_or_delete_for_page( ibuf_merge_or_delete_for_page(
block, block->page.space, block->page.offset, (buf_block_t*) bpage, bpage->space,
buf_block_get_zip_size(block), TRUE); bpage->offset, buf_page_get_zip_size(bpage),
TRUE);
} }
} }
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
mutex_enter(&block->mutex); mutex_enter(buf_page_get_mutex(bpage));
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
ut_a(ibuf_count_get(buf_block_get_space(block), ut_a(ibuf_count_get(bpage->space, bpage->offset) == 0);
buf_block_get_page_no(block)) == 0);
#endif #endif
/* Because this thread which does the unlocking is not the same that /* Because this thread which does the unlocking is not the same that
did the locking, we use a pass value != 0 in unlock, which simply did the locking, we use a pass value != 0 in unlock, which simply
removes the newest lock debug record, without checking the thread removes the newest lock debug record, without checking the thread
id. */ id. */
buf_page_set_io_fix(&block->page, BUF_IO_NONE); buf_page_set_io_fix(bpage, BUF_IO_NONE);
if (io_type == BUF_IO_READ) { switch (io_type) {
case BUF_IO_READ:
/* NOTE that the call to ibuf may have moved the ownership of /* NOTE that the call to ibuf may have moved the ownership of
the x-latch to this OS thread: do not let this confuse you in the x-latch to this OS thread: do not let this confuse you in
debugging! */ debugging! */
...@@ -2529,40 +2534,41 @@ buf_page_io_complete( ...@@ -2529,40 +2534,41 @@ buf_page_io_complete(
buf_pool->n_pend_reads--; buf_pool->n_pend_reads--;
buf_pool->n_pages_read++; buf_pool->n_pages_read++;
rw_lock_x_unlock_gen(&(block->lock), BUF_IO_READ); if (uncompressed) {
rw_lock_x_unlock_gen(&((buf_block_t*) bpage)->lock,
#ifdef UNIV_DEBUG BUF_IO_READ);
if (buf_debug_prints) {
fputs("Has read ", stderr);
} }
#endif /* UNIV_DEBUG */
} else {
ut_ad(io_type == BUF_IO_WRITE);
break;
case BUF_IO_WRITE:
/* Write means a flush operation: call the completion /* Write means a flush operation: call the completion
routine in the flush system */ routine in the flush system */
buf_flush_write_complete(&block->page); buf_flush_write_complete(bpage);
rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE); if (uncompressed) {
rw_lock_s_unlock_gen(&((buf_block_t*) bpage)->lock,
BUF_IO_WRITE);
}
buf_pool->n_pages_written++; buf_pool->n_pages_written++;
#ifdef UNIV_DEBUG break;
if (buf_debug_prints) {
fputs("Has written ", stderr); default:
} ut_error;
#endif /* UNIV_DEBUG */
} }
mutex_exit(&block->mutex); mutex_exit(buf_page_get_mutex(bpage));
mutex_exit(&(buf_pool->mutex)); mutex_exit(&(buf_pool->mutex));
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (buf_debug_prints) { if (buf_debug_prints) {
fprintf(stderr, "page space %lu page no %lu\n", fprintf(stderr, "Has %s page space %lu page no %lu\n",
(ulong) buf_block_get_space(block), io_type == BUF_IO_READ ? "read" : "written",
(ulong) buf_block_get_page_no(block)); (ulong) buf_page_get_space(bpage),
(ulong) buf_page_get_page_no(bpage));
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
} }
......
...@@ -145,7 +145,7 @@ buf_read_page_low( ...@@ -145,7 +145,7 @@ buf_read_page_low(
if (sync) { if (sync) {
/* The i/o is already completed when we arrive from /* The i/o is already completed when we arrive from
fil_read */ fil_read */
buf_page_io_complete(block); buf_page_io_complete(&block->page);
} }
return(1); return(1);
......
...@@ -867,7 +867,7 @@ the buffer pool. */ ...@@ -867,7 +867,7 @@ the buffer pool. */
void void
buf_page_io_complete( buf_page_io_complete(
/*=================*/ /*=================*/
buf_block_t* block); /* in: pointer to the block in question */ buf_page_t* bpage); /* in: pointer to the block in question */
/************************************************************************ /************************************************************************
Calculates a folded value of a file page address to use in the page hash Calculates a folded value of a file page address to use in the page hash
table. */ table. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment