Commit 137cf961 authored by marko's avatar marko

branches/zip: Fix some bugs in the crash recovery of compressed tablespaces.

fil_node_open_file(): Set node->size correctly for compressed tablespaces.

fsp_header_write_space_id(): Rename to fsp_header_write_fields(),
add parameter zip_size.

fil_io(): Add UNIV_UNLIKELY hints to assertion-like tests.
parent 7f8cb7aa
......@@ -615,11 +615,15 @@ fil_node_open_file(
ut_error;
}
if (size_bytes >= FSP_EXTENT_SIZE * UNIV_PAGE_SIZE) {
node->size = (ulint) ((size_bytes / (1024 * 1024))
* ((1024 * 1024) / UNIV_PAGE_SIZE));
} else {
if (size_bytes >= 1024 * 1024) {
/* Truncate the size to whole megabytes. */
size_bytes = ut_2pow_round(size_bytes, 1024 * 1024);
}
if (!zip_size) {
node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
} else {
node->size = (ulint) (size_bytes / zip_size);
}
#endif
space->size += node->size;
......@@ -2522,10 +2526,19 @@ fil_create_new_single_table_tablespace(
memset(page, '\0', UNIV_PAGE_SIZE);
fsp_header_write_space_id(page, *space_id);
fsp_header_init_fields(page, *space_id, zip_size);
buf_flush_init_for_writing(page, NULL/* TODO: page_zip */,
if (!zip_size) {
buf_flush_init_for_writing(page, NULL,
ut_dulint_zero, *space_id, 0);
} else {
page_zip_des_t page_zip;
page_zip.size = zip_size;
page_zip.data = page;
page_zip.n_blobs = page_zip.m_start = page_zip.m_end = 0;
buf_flush_init_for_writing(page, &page_zip,
ut_dulint_zero, *space_id, 0);
}
ret = os_file_write(path, file, page, 0, 0, UNIV_PAGE_SIZE);
......@@ -4066,7 +4079,7 @@ fil_io(
node = UT_LIST_GET_FIRST(space->chain);
for (;;) {
if (node == NULL) {
if (UNIV_UNLIKELY(node == NULL)) {
fil_report_invalid_page_access(block_offset, space_id,
space->name, byte_offset, len, type);
......@@ -4094,8 +4107,8 @@ fil_io(
/* Check that at least the start offset is within the bounds of a
single-table tablespace */
if (space->purpose == FIL_TABLESPACE && space->id != 0
&& node->size <= block_offset) {
if (UNIV_UNLIKELY(node->size <= block_offset)
&& space->id != 0 && space->purpose == FIL_TABLESPACE) {
fil_report_invalid_page_access(block_offset, space_id,
space->name, byte_offset, len, type);
......
......@@ -884,16 +884,22 @@ fsp_init(void)
}
/**************************************************************************
Writes the space id to a tablespace header. This function is used past the
buffer pool when we in fil0fil.c create a new single-table tablespace. */
Writes the space id and compressed page size to a tablespace header.
This function is used past the buffer pool when we in fil0fil.c create
a new single-table tablespace. */
void
fsp_header_write_space_id(
/*======================*/
page_t* page, /* in: first page in the space */
ulint space_id) /* in: space id */
fsp_header_init_fields(
/*===================*/
page_t* page, /* in/out: first page in the space */
ulint space_id, /* in: space id */
ulint zip_size) /* in: compressed page size in bytes;
0 for uncompressed pages */
{
mach_write_to_4(page + FSP_HEADER_OFFSET + FSP_SPACE_ID, space_id);
mach_write_to_4(FSP_HEADER_OFFSET + FSP_SPACE_ID + page,
space_id);
mach_write_to_4(FSP_HEADER_OFFSET + FSP_PAGE_ZIP_SIZE + page,
zip_size);
}
/**************************************************************************
......
......@@ -91,14 +91,17 @@ fsp_header_get_zip_size(
/* out: compressed page size, or 0 if uncompressed */
page_t* page); /* in: first page of a tablespace */
/**************************************************************************
Writes the space id to a tablespace header. This function is used past the
buffer pool when we in fil0fil.c create a new single-table tablespace. */
Writes the space id and compressed page size to a tablespace header.
This function is used past the buffer pool when we in fil0fil.c create
a new single-table tablespace. */
void
fsp_header_write_space_id(
/*======================*/
page_t* page, /* in: first page in the space */
ulint space_id); /* in: space id */
fsp_header_init_fields(
/*===================*/
page_t* page, /* in/out: first page in the space */
ulint space_id, /* in: space id */
ulint zip_size); /* in: compressed page size in bytes;
0 for uncompressed pages */
/**************************************************************************
Initializes the space header of a new created space and creates also the
insert buffer tree root if space == 0. */
......
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