diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 2f56936ae04..1718e68d667 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -4920,7 +4920,7 @@ extend_file: success = os_aio(OS_FILE_WRITE, OS_AIO_SYNC, node->name, node->handle, buf, offset, page_size * n_pages, - NULL, NULL, 0); + NULL, NULL, 0, FALSE, 0); #endif /* UNIV_HOTBACKUP */ if (success) { os_has_said_disk_full = FALSE; @@ -5302,6 +5302,8 @@ fil_io( ulint wake_later; os_offset_t offset; ibool ignore_nonexistent_pages; + ibool page_compressed = FALSE; + ibool page_compression_level = 0; is_log = type & OS_FILE_LOG; type = type & ~OS_FILE_LOG; @@ -5462,6 +5464,9 @@ fil_io( ut_a(byte_offset % OS_FILE_LOG_BLOCK_SIZE == 0); ut_a((len % OS_FILE_LOG_BLOCK_SIZE) == 0); + page_compressed = fsp_flags_is_page_compressed(space->flags); + page_compression_level = fsp_flags_get_page_compression_level(space->flags); + #ifdef UNIV_HOTBACKUP /* In ibbackup do normal i/o, not aio */ if (type == OS_FILE_READ) { @@ -5474,7 +5479,8 @@ fil_io( #else /* Queue the aio request */ ret = os_aio(type, mode | wake_later, node->name, node->handle, buf, - offset, len, node, message, write_size); + offset, len, node, message, write_size, + page_compressed, page_compression_level); #endif /* UNIV_HOTBACKUP */ ut_a(ret); diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index b67f583b53b..2da9d70e197 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -77,6 +77,7 @@ fil_compress_page( this must be appropriately aligned */ byte* out_buf, /*!< out: compressed buffer */ ulint len, /*!< in: length of input buffer.*/ + ulint compression_level, /* in: compression level */ ulint* out_len) /*!< out: actual length of compressed page */ { int err = Z_OK; @@ -84,13 +85,13 @@ fil_compress_page( ulint header_len = FIL_PAGE_DATA + FIL_PAGE_COMPRESSED_SIZE; ulint write_size=0; - ut_a(buf); - ut_a(out_buf); - ut_a(len); - ut_a(out_len); + ut_ad(buf); + ut_ad(out_buf); + ut_ad(len); + ut_ad(out_len); - level = fil_space_get_page_compression_level(space_id); - ut_a(fil_space_is_page_compressed(space_id)); + level = compression_level; + ut_ad(fil_space_is_page_compressed(space_id)); fil_system_enter(); fil_space_t* space = fil_space_get_by_id(space_id); @@ -181,8 +182,8 @@ fil_decompress_page( ulint compression_alg = 0; byte *in_buf; - ut_a(buf); - ut_a(len); + ut_ad(buf); + ut_ad(len); /* Before actual decompress, make sure that page type is correct */ @@ -264,106 +265,4 @@ fil_decompress_page( } } -/*******************************************************************//** -Find out wheather the page is index page or not -@return true if page type index page, false if not */ -ibool -fil_page_is_index_page( -/*===================*/ - byte *buf) /*!< in: page */ -{ - return(mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_INDEX); -} -/*******************************************************************//** -Find out wheather the page is page compressed -@return true if page is page compressed, false if not */ -ibool -fil_page_is_compressed( -/*===================*/ - byte *buf) /*!< in: page */ -{ - return(mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED); -} - -/*******************************************************************//** -Returns the page compression level of the space, or 0 if the space -is not compressed. The tablespace must be cached in the memory cache. -@return page compression level, ULINT_UNDEFINED if space not found */ -ulint -fil_space_get_page_compression_level( -/*=================================*/ - ulint id) /*!< in: space id */ -{ - ulint flags; - - flags = fil_space_get_flags(id); - - if (flags && flags != ULINT_UNDEFINED) { - - return(fsp_flags_get_page_compression_level(flags)); - } - - return(flags); -} - -/*******************************************************************//** -Extract the page compression from space. -@return true if space is page compressed, false if space is not found -or space is not page compressed. */ -ibool -fil_space_is_page_compressed( -/*=========================*/ - ulint id) /*!< in: space id */ -{ - ulint flags; - - flags = fil_space_get_flags(id); - - if (flags && flags != ULINT_UNDEFINED) { - - return(fsp_flags_is_page_compressed(flags)); - } - - return(flags); -} - -/****************************************************************//** -Get the name of the compression algorithm used for page -compression. -@return compression algorithm name or "UNKNOWN" if not known*/ -const char* -fil_get_compression_alg_name( -/*=========================*/ - ulint comp_alg) /*!io_already_done = FALSE; slot->page_compress_success = FALSE; slot->write_size = write_size; + slot->page_compression_level = page_compression_level; + slot->page_compression = page_compression; /* If the space is page compressed and this is write operation and if either only index pages compression is disabled or @@ -4456,7 +4465,7 @@ found: we compress the page */ if (message1 && type == OS_FILE_WRITE && - fil_space_is_page_compressed(fil_node_get_space_id(slot->message1)) && + page_compression && (srv_page_compress_index_pages == false || (srv_page_compress_index_pages == true && fil_page_is_index_page(slot->buf)))) { ulint real_len = len; @@ -4477,7 +4486,7 @@ found: can't really avoid this now. */ memset(slot->page_buf, 0, len); - tmp = fil_compress_page(fil_node_get_space_id(slot->message1), (byte *)buf, slot->page_buf, len, &real_len); + tmp = fil_compress_page(fil_node_get_space_id(slot->message1), (byte *)buf, slot->page_buf, len, page_compression_level, &real_len); /* If compression succeeded, set up the length and buffer */ if (tmp != buf) { @@ -4773,11 +4782,15 @@ os_aio_func( (can be used to identify a completed aio operation); ignored if mode is OS_AIO_SYNC */ - ulint* write_size)/*!< in/out: Actual write size initialized + ulint* write_size,/*!< in/out: Actual write size initialized after fist successfull trim operation for this page and if initialized we do not trim again if actual page size does not decrease. */ + ibool page_compression, /*!< in: is page compression used + on this file space */ + ulint page_compression_level) /*!< page compression + level to be used */ { os_aio_array_t* array; os_aio_slot_t* slot; @@ -4875,7 +4888,7 @@ try_again: } slot = os_aio_array_reserve_slot(type, array, message1, message2, file, - name, buf, offset, n, write_size); + name, buf, offset, n, write_size, page_compression, page_compression_level); if (type == OS_FILE_READ) { if (srv_use_native_aio) { @@ -5100,7 +5113,7 @@ os_aio_windows_handle( switch (slot->type) { case OS_FILE_WRITE: if (slot->message1 && - fil_space_is_page_compressed(fil_node_get_space_id(slot->message1)) && + page_compression && slot->page_buf) { ret = WriteFile(slot->file, slot->page_buf, (DWORD) slot->len, &len, @@ -5141,8 +5154,7 @@ os_aio_windows_handle( ret_val = ret && len == slot->len; } - if (slot->message1 && - fil_space_is_page_compressed(fil_node_get_space_id(slot->message1))) { + if (slot->message1 && page_compression) { // We allocate memory for page compressed buffer if and only // if it is not yet allocated. if (slot->page_buf == NULL) { @@ -5256,8 +5268,7 @@ retry: /* If the table is page compressed and this is read, we decompress before we annouce the read is complete. For writes, we free the compressed page. */ - if (slot->message1 && - fil_space_is_page_compressed(fil_node_get_space_id(slot->message1))) { + if (slot->message1 && slot->page_compression) { // We allocate memory for page compressed buffer if and only // if it is not yet allocated. if (slot->page_buf == NULL) {