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 @@
#cmakedefine HAVE_POLL 1
#cmakedefine HAVE_PORT_CREATE 1
#cmakedefine HAVE_POSIX_FALLOCATE 1
#cmakedefine HAVE_LINUX_FALLOC_H 1
#cmakedefine HAVE_FALLOCATE 1
#cmakedefine HAVE_PREAD 1
#cmakedefine HAVE_PAUSE_INSTRUCTION 1
#cmakedefine HAVE_FAKE_PAUSE_INSTRUCTION 1
......
......@@ -199,6 +199,7 @@ CHECK_INCLUDE_FILES (ieeefp.h HAVE_IEEEFP_H)
CHECK_INCLUDE_FILES (inttypes.h HAVE_INTTYPES_H)
CHECK_INCLUDE_FILES (langinfo.h HAVE_LANGINFO_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 (locale.h HAVE_LOCALE_H)
CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
......@@ -399,6 +400,7 @@ CHECK_FUNCTION_EXISTS (perror HAVE_PERROR)
CHECK_FUNCTION_EXISTS (poll HAVE_POLL)
CHECK_FUNCTION_EXISTS (port_create HAVE_PORT_CREATE)
CHECK_FUNCTION_EXISTS (posix_fallocate HAVE_POSIX_FALLOCATE)
CHECK_FUNCTION_EXISTS (fallocate HAVE_FALLOCATE)
CHECK_FUNCTION_EXISTS (pread HAVE_PREAD)
CHECK_FUNCTION_EXISTS (pthread_attr_create HAVE_PTHREAD_ATTR_CREATE)
CHECK_FUNCTION_EXISTS (pthread_attr_getstacksize HAVE_PTHREAD_ATTR_GETSTACKSIZE)
......
......@@ -135,4 +135,11 @@ fil_page_is_compressed(
/*===================*/
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
......@@ -182,3 +182,16 @@ fil_space_get_atomic_writes(
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
#include "srv0mon.h"
#include "srv0srv.h"
#ifdef HAVE_POSIX_FALLOCATE
#include "unistd.h"
#include "fcntl.h"
#endif
#ifndef UNIV_HOTBACKUP
......@@ -77,6 +78,19 @@ Created 10/21/1995 Heikki Tuuri
#include <sys/statvfs.h>
#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
#include "lzo/lzo1x.h"
#endif
......@@ -2916,7 +2930,7 @@ os_file_read_func(
as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual
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);
}
......@@ -2936,7 +2950,7 @@ os_file_read_func(
as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual
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);
}
......@@ -3061,7 +3075,7 @@ os_file_read_no_error_handling_func(
as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual
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);
}
......@@ -3081,7 +3095,7 @@ os_file_read_no_error_handling_func(
as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual
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);
}
......@@ -4634,12 +4648,10 @@ os_aio_array_reserve_slot(
// We allocate memory for page compressed buffer if and only
// 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
if (innodb_compression_algorithm == 3 && slot->lzo_mem == NULL) {
if (innodb_compression_algorithm == 3) {
os_slot_alloc_lzo_mem(slot);
}
#endif
......@@ -5305,6 +5317,7 @@ os_aio_windows_handle(
case OS_FILE_WRITE:
if (slot->message1 &&
slot->page_compression &&
slot->page_compress_success &&
slot->page_buf) {
ret = WriteFile(slot->file, slot->page_buf,
(DWORD) slot->len, &len,
......@@ -5345,26 +5358,24 @@ os_aio_windows_handle(
ret_val = ret && len == slot->len;
}
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) {
if (slot->type == OS_FILE_READ) {
if(fil_page_is_compressed(slot->buf)) {
os_slot_alloc_page_buf(slot);
}
#ifdef HAVE_LZO
if (innodb_compression_algorithm == 3 && slot->lzo_mem == NULL) {
os_slot_alloc_lzo_mem(slot);
}
if (fil_page_is_lzo_compressed(slot->buf)) {
os_slot_alloc_lzo_mem(slot);
}
#endif
if (slot->type == OS_FILE_READ) {
fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size);
} else {
if (slot->page_compress_success && fil_page_is_compressed(slot->page_buf)) {
if (srv_use_trim && os_fallocate_failed == FALSE) {
// Deallocate unused blocks from file system
os_file_trim(slot);
}
}
} else {
/* OS_FILE_WRITE */
if (slot->page_compress_success && fil_page_is_compressed(slot->page_buf)) {
if (srv_use_trim && os_fallocate_failed == FALSE) {
// Deallocate unused blocks from file system
os_file_trim(slot);
}
}
}
......@@ -5458,32 +5469,30 @@ os_aio_linux_collect(
/* We have not overstepped to next segment. */
ut_a(slot->pos < end_pos);
/* 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 && slot->page_compression) {
// We allocate memory for page compressed buffer if and only
// if it is not yet allocated.
if (slot->page_buf == NULL) {
if (slot->type == OS_FILE_READ) {
/* 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 (fil_page_is_compressed(slot->buf)) {
// We allocate memory for page compressed buffer if and only
// if it is not yet allocated.
os_slot_alloc_page_buf(slot);
}
#ifdef HAVE_LZO
if (innodb_compression_algorithm == 3 && slot->lzo_mem == NULL) {
os_slot_alloc_lzo_mem(slot);
}
if (fil_page_is_lzo_compressed(slot->buf)) {
os_slot_alloc_lzo_mem(slot);
}
#endif
if (slot->type == OS_FILE_READ) {
fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size);
} else {
if (slot->page_compress_success &&
fil_page_is_compressed(slot->page_buf)) {
ut_ad(slot->page_compression_page);
if (srv_use_trim && os_fallocate_failed == FALSE) {
// Deallocate unused blocks from file system
os_file_trim(slot);
}
}
} else {
/* OS_FILE_WRITE */
if (slot->page_compress_success &&
fil_page_is_compressed(slot->page_buf)) {
ut_ad(slot->page_compression_page);
if (srv_use_trim && os_fallocate_failed == FALSE) {
// Deallocate unused blocks from file system
os_file_trim(slot);
}
}
}
......@@ -6397,7 +6406,7 @@ os_file_trim(
}
#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);
if (ret) {
......@@ -6435,7 +6444,7 @@ os_file_trim(
*slot->write_size = 0;
}
#endif /* HAVE_POSIX_FALLOCATE ... */
#endif /* HAVE_FALLOCATE ... */
#elif defined(_WIN32)
FILE_LEVEL_TRIM flt;
......@@ -6518,13 +6527,15 @@ os_slot_alloc_page_buf(
byte* cbuf;
ut_a(slot != NULL);
/* We allocate extra to avoid memory overwrite on compression */
cbuf2 = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE*2));
cbuf = static_cast<byte *>(ut_align(cbuf2, UNIV_PAGE_SIZE));
slot->page_compression_page = static_cast<byte *>(cbuf2);
slot->page_buf = static_cast<byte *>(cbuf);
memset(slot->page_buf, 0, UNIV_PAGE_SIZE);
ut_a(slot->page_buf != NULL);
if (slot->page_compression_page == NULL) {
/* We allocate extra to avoid memory overwrite on compression */
cbuf2 = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE*2));
cbuf = static_cast<byte *>(ut_align(cbuf2, UNIV_PAGE_SIZE));
slot->page_compression_page = static_cast<byte *>(cbuf2);
slot->page_buf = static_cast<byte *>(cbuf);
memset(slot->page_compression_page, 0, UNIV_PAGE_SIZE*2);
ut_a(slot->page_buf != NULL);
}
}
#ifdef HAVE_LZO
......@@ -6538,9 +6549,11 @@ os_slot_alloc_lzo_mem(
os_aio_slot_t* slot) /*!< in: slot structure */
{
ut_a(slot != NULL);
slot->lzo_mem = static_cast<byte *>(ut_malloc(LZO1X_1_15_MEM_COMPRESS));
memset(slot->lzo_mem, 0, LZO1X_1_15_MEM_COMPRESS);
ut_a(slot->lzo_mem != NULL);
if(slot->lzo_mem == NULL) {
slot->lzo_mem = static_cast<byte *>(ut_malloc(LZO1X_1_15_MEM_COMPRESS));
memset(slot->lzo_mem, 0, LZO1X_1_15_MEM_COMPRESS);
ut_a(slot->lzo_mem != NULL);
}
}
#endif
......
......@@ -135,4 +135,11 @@ fil_page_is_compressed(
/*===================*/
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
......@@ -182,3 +182,16 @@ fil_space_get_atomic_writes(
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
#include "srv0mon.h"
#include "srv0srv.h"
#ifdef HAVE_POSIX_FALLOCATE
#include "unistd.h"
#include "fcntl.h"
#endif
#ifndef UNIV_HOTBACKUP
......@@ -83,6 +84,19 @@ Created 10/21/1995 Heikki Tuuri
#include <sys/statvfs.h>
#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
#include "lzo/lzo1x.h"
#endif
......@@ -3112,7 +3126,7 @@ os_file_read_func(
as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual
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);
}
......@@ -3133,7 +3147,7 @@ os_file_read_func(
as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual
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);
}
......@@ -3231,7 +3245,7 @@ os_file_read_no_error_handling_func(
as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual
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);
}
......@@ -3252,7 +3266,7 @@ os_file_read_no_error_handling_func(
as file spaces and they do not have FIL_PAGE_TYPE
field, thus we must use here information is the actual
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);
}
......@@ -4753,12 +4767,10 @@ os_aio_array_reserve_slot(
// We allocate memory for page compressed buffer if and only
// 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
if (innodb_compression_algorithm == 3 && slot->lzo_mem == NULL) {
if (innodb_compression_algorithm == 3) {
os_slot_alloc_lzo_mem(slot);
}
#endif
......@@ -4786,7 +4798,6 @@ os_aio_array_reserve_slot(
/* Take array mutex back */
os_mutex_enter(array->mutex);
}
#ifdef WIN_ASYNC_IO
......@@ -5176,9 +5187,11 @@ os_aio_func(
trx->io_reads++;
trx->io_read += n;
}
slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
name, buf, offset, n, space_id,
page_compression, page_compression_level, write_size);
if (type == OS_FILE_READ) {
if (srv_use_native_aio) {
os_n_file_reads++;
......@@ -5364,7 +5377,7 @@ os_aio_windows_handle(
switch (slot->type) {
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,
slot->offset, slot->len);
} else {
......@@ -5400,26 +5413,23 @@ os_aio_windows_handle(
ret_val = ret && len == slot->len;
}
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) {
if (slot->type == OS_FILE_READ) {
if (fil_page_is_compressed(slot->buf)) {
os_slot_alloc_page_buf(slot);
}
#ifdef HAVE_LZO
if (innodb_compression_algorithm == 3 && slot->lzo_mem == NULL) {
os_slot_alloc_lzo_mem(slot);
}
if (fil_page_is_lzo_compressed(slot->buf)) {
os_slot_alloc_lzo_mem(slot);
}
#endif
if (slot->type == OS_FILE_READ) {
fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size);
} else {
if (slot->page_compress_success && fil_page_is_compressed(slot->page_buf)) {
if (srv_use_trim && os_fallocate_failed == FALSE) {
// Deallocate unused blocks from file system
os_file_trim(slot);
}
}
} else {
/* OS_FILE_WRITE */
if (slot->page_compress_success && fil_page_is_compressed(slot->page_buf)) {
if (srv_use_trim && os_fallocate_failed == FALSE) {
// Deallocate unused blocks from file system
os_file_trim(slot);
}
}
}
......@@ -5513,31 +5523,29 @@ os_aio_linux_collect(
/* We have not overstepped to next segment. */
ut_a(slot->pos < end_pos);
/* 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 && slot->page_compression) {
// We allocate memory for page compressed buffer if and only
// if it is not yet allocated.
if (slot->page_buf == NULL) {
if (slot->type == OS_FILE_READ) {
/* 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 (fil_page_is_compressed(slot->buf)) {
// We allocate memory for page compressed buffer if and only
// if it is not yet allocated.
os_slot_alloc_page_buf(slot);
}
#ifdef HAVE_LZO
if (innodb_compression_algorithm == 3 && slot->lzo_mem == NULL) {
os_slot_alloc_lzo_mem(slot);
}
if (fil_page_is_lzo_compressed(slot->buf)) {
os_slot_alloc_lzo_mem(slot);
}
#endif
if (slot->type == OS_FILE_READ) {
fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size);
} else {
if (slot->page_compress_success &&
fil_page_is_compressed(slot->page_buf)) {
ut_ad(slot->page_compression_page);
if (srv_use_trim && os_fallocate_failed == FALSE) {
// Deallocate unused blocks from file system
os_file_trim(slot);
}
}
} else {
/* OS_FILE_WRITE */
if (slot->page_compress_success &&
fil_page_is_compressed(slot->page_buf)) {
ut_ad(slot->page_compression_page);
if (srv_use_trim && os_fallocate_failed == FALSE) {
// Deallocate unused blocks from file system
os_file_trim(slot);
}
}
}
......@@ -6490,7 +6498,7 @@ os_file_trim(
}
#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);
if (ret) {
......@@ -6528,7 +6536,7 @@ os_file_trim(
*slot->write_size = 0;
}
#endif /* HAVE_POSIX_FALLOCATE ... */
#endif /* HAVE_FALLOCATE ... */
#elif defined(_WIN32)
FILE_LEVEL_TRIM flt;
......@@ -6610,13 +6618,15 @@ os_slot_alloc_page_buf(
byte* cbuf;
ut_a(slot != NULL);
/* We allocate extra to avoid memory overwrite on compression */
cbuf2 = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE*2));
cbuf = static_cast<byte *>(ut_align(cbuf2, UNIV_PAGE_SIZE));
slot->page_compression_page = static_cast<byte *>(cbuf2);
slot->page_buf = static_cast<byte *>(cbuf);
memset(slot->page_buf, 0, UNIV_PAGE_SIZE);
ut_a(slot->page_buf != NULL);
if (slot->page_compression_page == NULL) {
/* We allocate extra to avoid memory overwrite on compression */
cbuf2 = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE*2));
cbuf = static_cast<byte *>(ut_align(cbuf2, UNIV_PAGE_SIZE));
slot->page_compression_page = static_cast<byte *>(cbuf2);
slot->page_buf = static_cast<byte *>(cbuf);
memset(slot->page_compression_page, 0, UNIV_PAGE_SIZE*2);
ut_a(slot->page_buf != NULL);
}
}
#ifdef HAVE_LZO
......@@ -6630,9 +6640,11 @@ os_slot_alloc_lzo_mem(
os_aio_slot_t* slot) /*!< in: slot structure */
{
ut_a(slot != NULL);
slot->lzo_mem = static_cast<byte *>(ut_malloc(LZO1X_1_15_MEM_COMPRESS));
memset(slot->lzo_mem, 0, LZO1X_1_15_MEM_COMPRESS);
ut_a(slot->lzo_mem != NULL);
if(slot->lzo_mem == NULL) {
slot->lzo_mem = static_cast<byte *>(ut_malloc(LZO1X_1_15_MEM_COMPRESS));
memset(slot->lzo_mem, 0, LZO1X_1_15_MEM_COMPRESS);
ut_a(slot->lzo_mem != NULL);
}
}
#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