Commit d4aef382 authored by Jan Lindström's avatar Jan Lindström

Fix compiler failure on fallocate function and used flags.

parent 01590005
...@@ -216,6 +216,8 @@ ...@@ -216,6 +216,8 @@
#cmakedefine HAVE_POLL 1 #cmakedefine HAVE_POLL 1
#cmakedefine HAVE_PORT_CREATE 1 #cmakedefine HAVE_PORT_CREATE 1
#cmakedefine HAVE_POSIX_FALLOCATE 1 #cmakedefine HAVE_POSIX_FALLOCATE 1
#cmakedefine HAVE_LINUX_FALLOC_H 1
#cmakedefine HAVE_FALLOCATE 1
#cmakedefine HAVE_PREAD 1 #cmakedefine HAVE_PREAD 1
#cmakedefine HAVE_PAUSE_INSTRUCTION 1 #cmakedefine HAVE_PAUSE_INSTRUCTION 1
#cmakedefine HAVE_FAKE_PAUSE_INSTRUCTION 1 #cmakedefine HAVE_FAKE_PAUSE_INSTRUCTION 1
......
...@@ -199,6 +199,7 @@ CHECK_INCLUDE_FILES (ieeefp.h HAVE_IEEEFP_H) ...@@ -199,6 +199,7 @@ CHECK_INCLUDE_FILES (ieeefp.h HAVE_IEEEFP_H)
CHECK_INCLUDE_FILES (inttypes.h HAVE_INTTYPES_H) CHECK_INCLUDE_FILES (inttypes.h HAVE_INTTYPES_H)
CHECK_INCLUDE_FILES (langinfo.h HAVE_LANGINFO_H) CHECK_INCLUDE_FILES (langinfo.h HAVE_LANGINFO_H)
CHECK_INCLUDE_FILES (linux/unistd.h HAVE_LINUX_UNISTD_H) CHECK_INCLUDE_FILES (linux/unistd.h HAVE_LINUX_UNISTD_H)
CHECK_INCLUDE_FILES (linux/falloc.h HAVE_LINUX_FALLOC_H)
CHECK_INCLUDE_FILES (limits.h HAVE_LIMITS_H) CHECK_INCLUDE_FILES (limits.h HAVE_LIMITS_H)
CHECK_INCLUDE_FILES (locale.h HAVE_LOCALE_H) CHECK_INCLUDE_FILES (locale.h HAVE_LOCALE_H)
CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H) CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
...@@ -399,6 +400,7 @@ CHECK_FUNCTION_EXISTS (perror HAVE_PERROR) ...@@ -399,6 +400,7 @@ CHECK_FUNCTION_EXISTS (perror HAVE_PERROR)
CHECK_FUNCTION_EXISTS (poll HAVE_POLL) CHECK_FUNCTION_EXISTS (poll HAVE_POLL)
CHECK_FUNCTION_EXISTS (port_create HAVE_PORT_CREATE) CHECK_FUNCTION_EXISTS (port_create HAVE_PORT_CREATE)
CHECK_FUNCTION_EXISTS (posix_fallocate HAVE_POSIX_FALLOCATE) CHECK_FUNCTION_EXISTS (posix_fallocate HAVE_POSIX_FALLOCATE)
CHECK_FUNCTION_EXISTS (fallocate HAVE_FALLOCATE)
CHECK_FUNCTION_EXISTS (pread HAVE_PREAD) CHECK_FUNCTION_EXISTS (pread HAVE_PREAD)
CHECK_FUNCTION_EXISTS (pthread_attr_create HAVE_PTHREAD_ATTR_CREATE) CHECK_FUNCTION_EXISTS (pthread_attr_create HAVE_PTHREAD_ATTR_CREATE)
CHECK_FUNCTION_EXISTS (pthread_attr_getstacksize HAVE_PTHREAD_ATTR_GETSTACKSIZE) CHECK_FUNCTION_EXISTS (pthread_attr_getstacksize HAVE_PTHREAD_ATTR_GETSTACKSIZE)
......
...@@ -135,4 +135,11 @@ fil_page_is_compressed( ...@@ -135,4 +135,11 @@ fil_page_is_compressed(
/*===================*/ /*===================*/
byte *buf); /*!< in: page */ byte *buf); /*!< in: page */
/*******************************************************************//**
Find out wheather the page is page compressed with lzo method
@return true if page is page compressed with lzo method*/
ibool
fil_page_is_lzo_compressed(
/*=======================*/
byte *buf); /*!< in: page */
#endif #endif
...@@ -182,3 +182,16 @@ fil_space_get_atomic_writes( ...@@ -182,3 +182,16 @@ fil_space_get_atomic_writes(
return((atomic_writes_t)0); return((atomic_writes_t)0);
} }
/*******************************************************************//**
Find out wheather the page is page compressed with lzo method
@return true if page is page compressed with lzo method, false if not */
UNIV_INLINE
ibool
fil_page_is_lzo_compressed(
/*=======================*/
byte *buf) /*!< in: page */
{
return(mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED &&
mach_read_from_8(buf+FIL_PAGE_FILE_FLUSH_LSN) == PAGE_LZO_ALGORITHM);
}
...@@ -48,6 +48,7 @@ Created 10/21/1995 Heikki Tuuri ...@@ -48,6 +48,7 @@ Created 10/21/1995 Heikki Tuuri
#include "srv0mon.h" #include "srv0mon.h"
#include "srv0srv.h" #include "srv0srv.h"
#ifdef HAVE_POSIX_FALLOCATE #ifdef HAVE_POSIX_FALLOCATE
#include "unistd.h"
#include "fcntl.h" #include "fcntl.h"
#endif #endif
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
...@@ -77,6 +78,19 @@ Created 10/21/1995 Heikki Tuuri ...@@ -77,6 +78,19 @@ Created 10/21/1995 Heikki Tuuri
#include <sys/statvfs.h> #include <sys/statvfs.h>
#endif #endif
#if defined(UNIV_LINUX) && defined(HAVE_LINUX_FALLOC_H)
#include <linux/falloc.h>
#endif
#if defined(HAVE_FALLOCATE)
#ifndef FALLOC_FL_KEEP_SIZE
#define FALLOC_FL_KEEP_SIZE 0x01
#endif
#ifndef FALLOC_FL_PUNCH_HOLE
#define FALLOC_FL_PUNCH_HOLE 0x02
#endif
#endif
#ifdef HAVE_LZO #ifdef HAVE_LZO
#include "lzo/lzo1x.h" #include "lzo/lzo1x.h"
#endif #endif
...@@ -2916,7 +2930,7 @@ try_again: ...@@ -2916,7 +2930,7 @@ try_again:
as file spaces and they do not have FIL_PAGE_TYPE as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual field, thus we must use here information is the actual
file space compressed. */ file space compressed. */
if (compressed && fil_page_is_compressed((byte *)buf)) { if (fil_page_is_compressed((byte *)buf)) {
fil_decompress_page(NULL, (byte *)buf, len, NULL); fil_decompress_page(NULL, (byte *)buf, len, NULL);
} }
...@@ -2936,7 +2950,7 @@ try_again: ...@@ -2936,7 +2950,7 @@ try_again:
as file spaces and they do not have FIL_PAGE_TYPE as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual field, thus we must use here information is the actual
file space compressed. */ file space compressed. */
if (compressed && fil_page_is_compressed((byte *)buf)) { if (fil_page_is_compressed((byte *)buf)) {
fil_decompress_page(NULL, (byte *)buf, n, NULL); fil_decompress_page(NULL, (byte *)buf, n, NULL);
} }
...@@ -3061,7 +3075,7 @@ try_again: ...@@ -3061,7 +3075,7 @@ try_again:
as file spaces and they do not have FIL_PAGE_TYPE as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual field, thus we must use here information is the actual
file space compressed. */ file space compressed. */
if (compressed && fil_page_is_compressed((byte *)buf)) { if (fil_page_is_compressed((byte *)buf)) {
fil_decompress_page(NULL, (byte *)buf, n, NULL); fil_decompress_page(NULL, (byte *)buf, n, NULL);
} }
...@@ -3081,7 +3095,7 @@ try_again: ...@@ -3081,7 +3095,7 @@ try_again:
as file spaces and they do not have FIL_PAGE_TYPE as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual field, thus we must use here information is the actual
file space compressed. */ file space compressed. */
if (compressed && fil_page_is_compressed((byte *)buf)) { if (fil_page_is_compressed((byte *)buf)) {
fil_decompress_page(NULL, (byte *)buf, n, NULL); fil_decompress_page(NULL, (byte *)buf, n, NULL);
} }
...@@ -4634,12 +4648,10 @@ found: ...@@ -4634,12 +4648,10 @@ found:
// We allocate memory for page compressed buffer if and only // We allocate memory for page compressed buffer if and only
// if it is not yet allocated. // if it is not yet allocated.
if (slot->page_buf == NULL) {
os_slot_alloc_page_buf(slot); os_slot_alloc_page_buf(slot);
}
#ifdef HAVE_LZO #ifdef HAVE_LZO
if (innodb_compression_algorithm == 3 && slot->lzo_mem == NULL) { if (innodb_compression_algorithm == 3) {
os_slot_alloc_lzo_mem(slot); os_slot_alloc_lzo_mem(slot);
} }
#endif #endif
...@@ -5305,6 +5317,7 @@ os_aio_windows_handle( ...@@ -5305,6 +5317,7 @@ os_aio_windows_handle(
case OS_FILE_WRITE: case OS_FILE_WRITE:
if (slot->message1 && if (slot->message1 &&
slot->page_compression && slot->page_compression &&
slot->page_compress_success &&
slot->page_buf) { slot->page_buf) {
ret = WriteFile(slot->file, slot->page_buf, ret = WriteFile(slot->file, slot->page_buf,
(DWORD) slot->len, &len, (DWORD) slot->len, &len,
...@@ -5345,21 +5358,20 @@ os_aio_windows_handle( ...@@ -5345,21 +5358,20 @@ os_aio_windows_handle(
ret_val = ret && len == slot->len; ret_val = ret && len == slot->len;
} }
if (slot->message1 && slot->page_compression) { if (slot->type == OS_FILE_READ) {
// We allocate memory for page compressed buffer if and only if(fil_page_is_compressed(slot->buf)) {
// if it is not yet allocated.
if (slot->page_buf == NULL) {
os_slot_alloc_page_buf(slot); os_slot_alloc_page_buf(slot);
}
#ifdef HAVE_LZO #ifdef HAVE_LZO
if (innodb_compression_algorithm == 3 && slot->lzo_mem == NULL) { if (fil_page_is_lzo_compressed(slot->buf)) {
os_slot_alloc_lzo_mem(slot); os_slot_alloc_lzo_mem(slot);
} }
#endif #endif
if (slot->type == OS_FILE_READ) {
fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size); fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size);
}
} else { } else {
/* OS_FILE_WRITE */
if (slot->page_compress_success && fil_page_is_compressed(slot->page_buf)) { if (slot->page_compress_success && fil_page_is_compressed(slot->page_buf)) {
if (srv_use_trim && os_fallocate_failed == FALSE) { if (srv_use_trim && os_fallocate_failed == FALSE) {
// Deallocate unused blocks from file system // Deallocate unused blocks from file system
...@@ -5367,7 +5379,6 @@ os_aio_windows_handle( ...@@ -5367,7 +5379,6 @@ os_aio_windows_handle(
} }
} }
} }
}
os_aio_array_free_slot(array, slot); os_aio_array_free_slot(array, slot);
...@@ -5458,25 +5469,24 @@ retry: ...@@ -5458,25 +5469,24 @@ retry:
/* We have not overstepped to next segment. */ /* We have not overstepped to next segment. */
ut_a(slot->pos < end_pos); ut_a(slot->pos < end_pos);
if (slot->type == OS_FILE_READ) {
/* If the table is page compressed and this is read, /* If the table is page compressed and this is read,
we decompress before we annouce the read is we decompress before we annouce the read is
complete. For writes, we free the compressed page. */ complete. For writes, we free the compressed page. */
if (slot->message1 && slot->page_compression) { if (fil_page_is_compressed(slot->buf)) {
// We allocate memory for page compressed buffer if and only // We allocate memory for page compressed buffer if and only
// if it is not yet allocated. // if it is not yet allocated.
if (slot->page_buf == NULL) {
os_slot_alloc_page_buf(slot); os_slot_alloc_page_buf(slot);
}
#ifdef HAVE_LZO #ifdef HAVE_LZO
if (innodb_compression_algorithm == 3 && slot->lzo_mem == NULL) { if (fil_page_is_lzo_compressed(slot->buf)) {
os_slot_alloc_lzo_mem(slot); os_slot_alloc_lzo_mem(slot);
} }
#endif #endif
if (slot->type == OS_FILE_READ) {
fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size); fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size);
}
} else { } else {
/* OS_FILE_WRITE */
if (slot->page_compress_success && if (slot->page_compress_success &&
fil_page_is_compressed(slot->page_buf)) { fil_page_is_compressed(slot->page_buf)) {
ut_ad(slot->page_compression_page); ut_ad(slot->page_compression_page);
...@@ -5486,7 +5496,6 @@ retry: ...@@ -5486,7 +5496,6 @@ retry:
} }
} }
} }
}
/* Mark this request as completed. The error handling /* Mark this request as completed. The error handling
will be done in the calling function. */ will be done in the calling function. */
...@@ -6397,7 +6406,7 @@ os_file_trim( ...@@ -6397,7 +6406,7 @@ os_file_trim(
} }
#ifdef __linux__ #ifdef __linux__
#if defined(HAVE_POSIX_FALLOCATE) #if defined(HAVE_FALLOCATE)
int ret = fallocate(slot->file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, off, trim_len); int ret = fallocate(slot->file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, off, trim_len);
if (ret) { if (ret) {
...@@ -6435,7 +6444,7 @@ os_file_trim( ...@@ -6435,7 +6444,7 @@ os_file_trim(
*slot->write_size = 0; *slot->write_size = 0;
} }
#endif /* HAVE_POSIX_FALLOCATE ... */ #endif /* HAVE_FALLOCATE ... */
#elif defined(_WIN32) #elif defined(_WIN32)
FILE_LEVEL_TRIM flt; FILE_LEVEL_TRIM flt;
...@@ -6518,13 +6527,15 @@ os_slot_alloc_page_buf( ...@@ -6518,13 +6527,15 @@ os_slot_alloc_page_buf(
byte* cbuf; byte* cbuf;
ut_a(slot != NULL); ut_a(slot != NULL);
if (slot->page_compression_page == NULL) {
/* We allocate extra to avoid memory overwrite on compression */ /* We allocate extra to avoid memory overwrite on compression */
cbuf2 = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE*2)); cbuf2 = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE*2));
cbuf = static_cast<byte *>(ut_align(cbuf2, UNIV_PAGE_SIZE)); cbuf = static_cast<byte *>(ut_align(cbuf2, UNIV_PAGE_SIZE));
slot->page_compression_page = static_cast<byte *>(cbuf2); slot->page_compression_page = static_cast<byte *>(cbuf2);
slot->page_buf = static_cast<byte *>(cbuf); slot->page_buf = static_cast<byte *>(cbuf);
memset(slot->page_buf, 0, UNIV_PAGE_SIZE); memset(slot->page_compression_page, 0, UNIV_PAGE_SIZE*2);
ut_a(slot->page_buf != NULL); ut_a(slot->page_buf != NULL);
}
} }
#ifdef HAVE_LZO #ifdef HAVE_LZO
...@@ -6538,9 +6549,11 @@ os_slot_alloc_lzo_mem( ...@@ -6538,9 +6549,11 @@ os_slot_alloc_lzo_mem(
os_aio_slot_t* slot) /*!< in: slot structure */ os_aio_slot_t* slot) /*!< in: slot structure */
{ {
ut_a(slot != NULL); ut_a(slot != NULL);
if(slot->lzo_mem == NULL) {
slot->lzo_mem = static_cast<byte *>(ut_malloc(LZO1X_1_15_MEM_COMPRESS)); slot->lzo_mem = static_cast<byte *>(ut_malloc(LZO1X_1_15_MEM_COMPRESS));
memset(slot->lzo_mem, 0, LZO1X_1_15_MEM_COMPRESS); memset(slot->lzo_mem, 0, LZO1X_1_15_MEM_COMPRESS);
ut_a(slot->lzo_mem != NULL); ut_a(slot->lzo_mem != NULL);
}
} }
#endif #endif
......
...@@ -135,4 +135,11 @@ fil_page_is_compressed( ...@@ -135,4 +135,11 @@ fil_page_is_compressed(
/*===================*/ /*===================*/
byte *buf); /*!< in: page */ byte *buf); /*!< in: page */
/*******************************************************************//**
Find out wheather the page is page compressed with lzo method
@return true if page is page compressed with lzo method*/
ibool
fil_page_is_lzo_compressed(
/*=======================*/
byte *buf); /*!< in: page */
#endif #endif
...@@ -182,3 +182,16 @@ fil_space_get_atomic_writes( ...@@ -182,3 +182,16 @@ fil_space_get_atomic_writes(
return((atomic_writes_t)0); return((atomic_writes_t)0);
} }
/*******************************************************************//**
Find out wheather the page is page compressed with lzo method
@return true if page is page compressed with lzo method, false if not */
UNIV_INLINE
ibool
fil_page_is_lzo_compressed(
/*=======================*/
byte *buf) /*!< in: page */
{
return(mach_read_from_2(buf+FIL_PAGE_TYPE) == FIL_PAGE_PAGE_COMPRESSED &&
mach_read_from_8(buf+FIL_PAGE_FILE_FLUSH_LSN) == PAGE_LZO_ALGORITHM);
}
...@@ -50,6 +50,7 @@ Created 10/21/1995 Heikki Tuuri ...@@ -50,6 +50,7 @@ Created 10/21/1995 Heikki Tuuri
#include "srv0mon.h" #include "srv0mon.h"
#include "srv0srv.h" #include "srv0srv.h"
#ifdef HAVE_POSIX_FALLOCATE #ifdef HAVE_POSIX_FALLOCATE
#include "unistd.h"
#include "fcntl.h" #include "fcntl.h"
#endif #endif
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
...@@ -83,6 +84,19 @@ Created 10/21/1995 Heikki Tuuri ...@@ -83,6 +84,19 @@ Created 10/21/1995 Heikki Tuuri
#include <sys/statvfs.h> #include <sys/statvfs.h>
#endif #endif
#if defined(UNIV_LINUX) && defined(HAVE_LINUX_FALLOC_H)
#include <linux/falloc.h>
#endif
#if defined(HAVE_FALLOCATE)
#ifndef FALLOC_FL_KEEP_SIZE
#define FALLOC_FL_KEEP_SIZE 0x01
#endif
#ifndef FALLOC_FL_PUNCH_HOLE
#define FALLOC_FL_PUNCH_HOLE 0x02
#endif
#endif
#ifdef HAVE_LZO #ifdef HAVE_LZO
#include "lzo/lzo1x.h" #include "lzo/lzo1x.h"
#endif #endif
...@@ -3112,7 +3126,7 @@ try_again: ...@@ -3112,7 +3126,7 @@ try_again:
as file spaces and they do not have FIL_PAGE_TYPE as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual field, thus we must use here information is the actual
file space compressed. */ file space compressed. */
if (compressed && fil_page_is_compressed((byte *)buf)) { if (fil_page_is_compressed((byte *)buf)) {
fil_decompress_page(NULL, (byte *)buf, len, NULL); fil_decompress_page(NULL, (byte *)buf, len, NULL);
} }
...@@ -3133,7 +3147,7 @@ try_again: ...@@ -3133,7 +3147,7 @@ try_again:
as file spaces and they do not have FIL_PAGE_TYPE as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual field, thus we must use here information is the actual
file space compressed. */ file space compressed. */
if (compressed && fil_page_is_compressed((byte *)buf)) { if (fil_page_is_compressed((byte *)buf)) {
fil_decompress_page(NULL, (byte *)buf, n, NULL); fil_decompress_page(NULL, (byte *)buf, n, NULL);
} }
...@@ -3231,7 +3245,7 @@ try_again: ...@@ -3231,7 +3245,7 @@ try_again:
as file spaces and they do not have FIL_PAGE_TYPE as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual field, thus we must use here information is the actual
file space compressed. */ file space compressed. */
if (compressed && fil_page_is_compressed((byte *)buf)) { if (fil_page_is_compressed((byte *)buf)) {
fil_decompress_page(NULL, (byte *)buf, n, NULL); fil_decompress_page(NULL, (byte *)buf, n, NULL);
} }
...@@ -3252,7 +3266,7 @@ try_again: ...@@ -3252,7 +3266,7 @@ try_again:
as file spaces and they do not have FIL_PAGE_TYPE as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual field, thus we must use here information is the actual
file space compressed. */ file space compressed. */
if (compressed && fil_page_is_compressed((byte *)buf)) { if (fil_page_is_compressed((byte *)buf)) {
fil_decompress_page(NULL, (byte *)buf, n, NULL); fil_decompress_page(NULL, (byte *)buf, n, NULL);
} }
...@@ -4753,12 +4767,10 @@ found: ...@@ -4753,12 +4767,10 @@ found:
// We allocate memory for page compressed buffer if and only // We allocate memory for page compressed buffer if and only
// if it is not yet allocated. // if it is not yet allocated.
if (slot->page_buf == NULL) {
os_slot_alloc_page_buf(slot); os_slot_alloc_page_buf(slot);
}
#ifdef HAVE_LZO #ifdef HAVE_LZO
if (innodb_compression_algorithm == 3 && slot->lzo_mem == NULL) { if (innodb_compression_algorithm == 3) {
os_slot_alloc_lzo_mem(slot); os_slot_alloc_lzo_mem(slot);
} }
#endif #endif
...@@ -4786,7 +4798,6 @@ found: ...@@ -4786,7 +4798,6 @@ found:
/* Take array mutex back */ /* Take array mutex back */
os_mutex_enter(array->mutex); os_mutex_enter(array->mutex);
} }
#ifdef WIN_ASYNC_IO #ifdef WIN_ASYNC_IO
...@@ -5176,9 +5187,11 @@ try_again: ...@@ -5176,9 +5187,11 @@ try_again:
trx->io_reads++; trx->io_reads++;
trx->io_read += n; trx->io_read += n;
} }
slot = os_aio_array_reserve_slot(type, array, message1, message2, file, slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
name, buf, offset, n, space_id, name, buf, offset, n, space_id,
page_compression, page_compression_level, write_size); page_compression, page_compression_level, write_size);
if (type == OS_FILE_READ) { if (type == OS_FILE_READ) {
if (srv_use_native_aio) { if (srv_use_native_aio) {
os_n_file_reads++; os_n_file_reads++;
...@@ -5364,7 +5377,7 @@ os_aio_windows_handle( ...@@ -5364,7 +5377,7 @@ os_aio_windows_handle(
switch (slot->type) { switch (slot->type) {
case OS_FILE_WRITE: case OS_FILE_WRITE:
if (slot->message1 && slot->page_compression && slot->page_buf) { if (slot->message1 && slot->page_compression slot->page_compress_success && slot->page_buf) {
ret_val = os_file_write(slot->name, slot->file, slot->page_buf, ret_val = os_file_write(slot->name, slot->file, slot->page_buf,
slot->offset, slot->len); slot->offset, slot->len);
} else { } else {
...@@ -5400,21 +5413,19 @@ os_aio_windows_handle( ...@@ -5400,21 +5413,19 @@ os_aio_windows_handle(
ret_val = ret && len == slot->len; ret_val = ret && len == slot->len;
} }
if (slot->message1 && slot->page_compression) { if (slot->type == OS_FILE_READ) {
// We allocate memory for page compressed buffer if and only if (fil_page_is_compressed(slot->buf)) {
// if it is not yet allocated.
if (slot->page_buf == NULL) {
os_slot_alloc_page_buf(slot); os_slot_alloc_page_buf(slot);
}
#ifdef HAVE_LZO #ifdef HAVE_LZO
if (innodb_compression_algorithm == 3 && slot->lzo_mem == NULL) { if (fil_page_is_lzo_compressed(slot->buf)) {
os_slot_alloc_lzo_mem(slot); os_slot_alloc_lzo_mem(slot);
} }
#endif #endif
if (slot->type == OS_FILE_READ) {
fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size); fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size);
}
} else { } else {
/* OS_FILE_WRITE */
if (slot->page_compress_success && fil_page_is_compressed(slot->page_buf)) { if (slot->page_compress_success && fil_page_is_compressed(slot->page_buf)) {
if (srv_use_trim && os_fallocate_failed == FALSE) { if (srv_use_trim && os_fallocate_failed == FALSE) {
// Deallocate unused blocks from file system // Deallocate unused blocks from file system
...@@ -5422,7 +5433,6 @@ os_aio_windows_handle( ...@@ -5422,7 +5433,6 @@ os_aio_windows_handle(
} }
} }
} }
}
os_aio_array_free_slot((os_aio_array_t *)slot->arr, slot); os_aio_array_free_slot((os_aio_array_t *)slot->arr, slot);
...@@ -5513,24 +5523,23 @@ retry: ...@@ -5513,24 +5523,23 @@ retry:
/* We have not overstepped to next segment. */ /* We have not overstepped to next segment. */
ut_a(slot->pos < end_pos); ut_a(slot->pos < end_pos);
if (slot->type == OS_FILE_READ) {
/* If the table is page compressed and this is read, /* If the table is page compressed and this is read,
we decompress before we annouce the read is we decompress before we annouce the read is
complete. For writes, we free the compressed page. */ complete. For writes, we free the compressed page. */
if (slot->message1 && slot->page_compression) { if (fil_page_is_compressed(slot->buf)) {
// We allocate memory for page compressed buffer if and only // We allocate memory for page compressed buffer if and only
// if it is not yet allocated. // if it is not yet allocated.
if (slot->page_buf == NULL) {
os_slot_alloc_page_buf(slot); os_slot_alloc_page_buf(slot);
}
#ifdef HAVE_LZO #ifdef HAVE_LZO
if (innodb_compression_algorithm == 3 && slot->lzo_mem == NULL) { if (fil_page_is_lzo_compressed(slot->buf)) {
os_slot_alloc_lzo_mem(slot); os_slot_alloc_lzo_mem(slot);
} }
#endif #endif
if (slot->type == OS_FILE_READ) {
fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size); fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size);
}
} else { } else {
/* OS_FILE_WRITE */
if (slot->page_compress_success && if (slot->page_compress_success &&
fil_page_is_compressed(slot->page_buf)) { fil_page_is_compressed(slot->page_buf)) {
ut_ad(slot->page_compression_page); ut_ad(slot->page_compression_page);
...@@ -5540,7 +5549,6 @@ retry: ...@@ -5540,7 +5549,6 @@ retry:
} }
} }
} }
}
/* Mark this request as completed. The error handling /* Mark this request as completed. The error handling
will be done in the calling function. */ will be done in the calling function. */
...@@ -6490,7 +6498,7 @@ os_file_trim( ...@@ -6490,7 +6498,7 @@ os_file_trim(
} }
#ifdef __linux__ #ifdef __linux__
#if defined(POSIX_FALLOCATE) #if defined(HAVE_FALLOCATE)
int ret = fallocate(slot->file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, off, trim_len); int ret = fallocate(slot->file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, off, trim_len);
if (ret) { if (ret) {
...@@ -6528,7 +6536,7 @@ os_file_trim( ...@@ -6528,7 +6536,7 @@ os_file_trim(
*slot->write_size = 0; *slot->write_size = 0;
} }
#endif /* HAVE_POSIX_FALLOCATE ... */ #endif /* HAVE_FALLOCATE ... */
#elif defined(_WIN32) #elif defined(_WIN32)
FILE_LEVEL_TRIM flt; FILE_LEVEL_TRIM flt;
...@@ -6610,13 +6618,15 @@ os_slot_alloc_page_buf( ...@@ -6610,13 +6618,15 @@ os_slot_alloc_page_buf(
byte* cbuf; byte* cbuf;
ut_a(slot != NULL); ut_a(slot != NULL);
if (slot->page_compression_page == NULL) {
/* We allocate extra to avoid memory overwrite on compression */ /* We allocate extra to avoid memory overwrite on compression */
cbuf2 = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE*2)); cbuf2 = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE*2));
cbuf = static_cast<byte *>(ut_align(cbuf2, UNIV_PAGE_SIZE)); cbuf = static_cast<byte *>(ut_align(cbuf2, UNIV_PAGE_SIZE));
slot->page_compression_page = static_cast<byte *>(cbuf2); slot->page_compression_page = static_cast<byte *>(cbuf2);
slot->page_buf = static_cast<byte *>(cbuf); slot->page_buf = static_cast<byte *>(cbuf);
memset(slot->page_buf, 0, UNIV_PAGE_SIZE); memset(slot->page_compression_page, 0, UNIV_PAGE_SIZE*2);
ut_a(slot->page_buf != NULL); ut_a(slot->page_buf != NULL);
}
} }
#ifdef HAVE_LZO #ifdef HAVE_LZO
...@@ -6630,9 +6640,11 @@ os_slot_alloc_lzo_mem( ...@@ -6630,9 +6640,11 @@ os_slot_alloc_lzo_mem(
os_aio_slot_t* slot) /*!< in: slot structure */ os_aio_slot_t* slot) /*!< in: slot structure */
{ {
ut_a(slot != NULL); ut_a(slot != NULL);
if(slot->lzo_mem == NULL) {
slot->lzo_mem = static_cast<byte *>(ut_malloc(LZO1X_1_15_MEM_COMPRESS)); slot->lzo_mem = static_cast<byte *>(ut_malloc(LZO1X_1_15_MEM_COMPRESS));
memset(slot->lzo_mem, 0, LZO1X_1_15_MEM_COMPRESS); memset(slot->lzo_mem, 0, LZO1X_1_15_MEM_COMPRESS);
ut_a(slot->lzo_mem != NULL); ut_a(slot->lzo_mem != NULL);
}
} }
#endif #endif
......
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