mirror of
https://github.com/MariaDB/server.git
synced 2025-08-09 22:24:09 +03:00
Removed some unnecessary assertions to debug build and enhanced the page_compression and page_compression_level fetch.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
@@ -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) /*!<in: compression algorithm number */
|
||||
{
|
||||
switch(comp_alg) {
|
||||
case FIL_PAGE_COMPRESSION_ZLIB:
|
||||
return ("ZLIB");
|
||||
break;
|
||||
default:
|
||||
return("UNKNOWN");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************//**
|
||||
Returns the atomic writes flag of the space, or false if the space
|
||||
is not using atomic writes. The tablespace must be cached in the memory cache.
|
||||
@return atomic writes table option value */
|
||||
atomic_writes_t
|
||||
fil_space_get_atomic_writes(
|
||||
/*========================*/
|
||||
ulint id) /*!< in: space id */
|
||||
{
|
||||
ulint flags;
|
||||
|
||||
flags = fil_space_get_flags(id);
|
||||
|
||||
if (flags && flags != ULINT_UNDEFINED) {
|
||||
|
||||
return((atomic_writes_t)fsp_flags_get_atomic_writes(flags));
|
||||
}
|
||||
|
||||
return((atomic_writes_t)0);
|
||||
}
|
||||
|
@@ -84,6 +84,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 */
|
||||
|
||||
/****************************************************************//**
|
||||
|
@@ -24,6 +24,8 @@ compression and atomic writes information to file space.
|
||||
Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com
|
||||
***********************************************************************/
|
||||
|
||||
#include "fsp0fsp.h"
|
||||
|
||||
/********************************************************************//**
|
||||
Determine if the tablespace is page compressed from dict_table_t::flags.
|
||||
@return TRUE if page compressed, FALSE if not page compressed */
|
||||
@@ -59,3 +61,113 @@ fsp_flags_get_atomic_writes(
|
||||
{
|
||||
return((atomic_writes_t)FSP_FLAGS_GET_ATOMIC_WRITES(flags));
|
||||
}
|
||||
|
||||
/*******************************************************************//**
|
||||
Find out wheather the page is index page or not
|
||||
@return true if page type index page, false if not */
|
||||
UNIV_INLINE
|
||||
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 */
|
||||
UNIV_INLINE
|
||||
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 */
|
||||
UNIV_INLINE
|
||||
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. */
|
||||
UNIV_INLINE
|
||||
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*/
|
||||
UNIV_INLINE
|
||||
const char*
|
||||
fil_get_compression_alg_name(
|
||||
/*=========================*/
|
||||
ulint comp_alg) /*!<in: compression algorithm number */
|
||||
{
|
||||
switch(comp_alg) {
|
||||
case FIL_PAGE_COMPRESSION_ZLIB:
|
||||
return ("ZLIB");
|
||||
break;
|
||||
default:
|
||||
return("UNKNOWN");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************//**
|
||||
Returns the atomic writes flag of the space, or false if the space
|
||||
is not using atomic writes. The tablespace must be cached in the memory cache.
|
||||
@return atomic writes table option value */
|
||||
UNIV_INLINE
|
||||
atomic_writes_t
|
||||
fil_space_get_atomic_writes(
|
||||
/*========================*/
|
||||
ulint id) /*!< in: space id */
|
||||
{
|
||||
ulint flags;
|
||||
|
||||
flags = fil_space_get_flags(id);
|
||||
|
||||
if (flags && flags != ULINT_UNDEFINED) {
|
||||
|
||||
return((atomic_writes_t)fsp_flags_get_atomic_writes(flags));
|
||||
}
|
||||
|
||||
return((atomic_writes_t)0);
|
||||
}
|
||||
|
@@ -288,9 +288,11 @@ The wrapper functions have the prefix of "innodb_". */
|
||||
pfs_os_file_close_func(file, __FILE__, __LINE__)
|
||||
|
||||
# define os_aio(type, mode, name, file, buf, offset, \
|
||||
n, message1, message2, write_size) \
|
||||
n, message1, message2, write_size, \
|
||||
page_compression, page_compression_level) \
|
||||
pfs_os_aio_func(type, mode, name, file, buf, offset, \
|
||||
n, message1, message2, write_size, __FILE__, __LINE__)
|
||||
n, message1, message2, write_size, \
|
||||
page_compression, page_compression_level, __FILE__, __LINE__)
|
||||
|
||||
# define os_file_read(file, buf, offset, n) \
|
||||
pfs_os_file_read_func(file, buf, offset, n, __FILE__, __LINE__)
|
||||
@@ -327,7 +329,7 @@ to original un-instrumented file I/O APIs */
|
||||
|
||||
# define os_aio(type, mode, name, file, buf, offset, n, message1, message2, write_size) \
|
||||
os_aio_func(type, mode, name, file, buf, offset, n, \
|
||||
message1, message2, write_size)
|
||||
message1, message2, write_size, page_compression, page_compression_level)
|
||||
|
||||
# define os_file_read(file, buf, offset, n) \
|
||||
os_file_read_func(file, buf, offset, n)
|
||||
@@ -733,6 +735,10 @@ pfs_os_aio_func(
|
||||
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 */
|
||||
const char* src_file,/*!< in: file name where func invoked */
|
||||
ulint src_line);/*!< in: line where the func invoked */
|
||||
/*******************************************************************//**
|
||||
@@ -1065,11 +1071,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 */
|
||||
|
||||
/************************************************************************//**
|
||||
Wakes up all async i/o threads so that they know to exit themselves in
|
||||
|
@@ -220,6 +220,10 @@ pfs_os_aio_func(
|
||||
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 */
|
||||
const char* src_file,/*!< in: file name where func invoked */
|
||||
ulint src_line)/*!< in: line where the func invoked */
|
||||
{
|
||||
@@ -235,7 +239,8 @@ pfs_os_aio_func(
|
||||
src_file, src_line);
|
||||
|
||||
result = os_aio_func(type, mode, name, file, buf, offset,
|
||||
n, message1, message2, write_size);
|
||||
n, message1, message2, write_size,
|
||||
page_compression, page_compression_level);
|
||||
|
||||
register_pfs_file_io_end(locker, n);
|
||||
|
||||
|
@@ -196,6 +196,9 @@ struct os_aio_slot_t{
|
||||
freed after the write
|
||||
has been completed */
|
||||
|
||||
ibool page_compression;
|
||||
ulint page_compression_level;
|
||||
|
||||
ulint* write_size; /*!< Actual write size initialized
|
||||
after fist successfull trim
|
||||
operation for this page and if
|
||||
@@ -4353,11 +4356,15 @@ os_aio_array_reserve_slot(
|
||||
to write */
|
||||
os_offset_t offset, /*!< in: file offset */
|
||||
ulint len, /*!< in: length of the block to read or write */
|
||||
ulint* write_size) /*!< in: 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_slot_t* slot = NULL;
|
||||
#ifdef WIN_ASYNC_IO
|
||||
@@ -4449,6 +4456,8 @@ found:
|
||||
slot->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) {
|
||||
|
Reference in New Issue
Block a user