summaryrefslogtreecommitdiff
path: root/storage/innobase
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@skysql.com>2014-12-03 10:41:52 +0200
committerJan Lindström <jan.lindstrom@skysql.com>2014-12-03 10:41:52 +0200
commitd4aef382fd9e3cc10ed687cc981b43aac1f29281 (patch)
tree6cf63e29aaebe4f60d1150fc73c46e7e9471d7b4 /storage/innobase
parent01590005ba44f350f63b70a7ceb9f69095b293d5 (diff)
downloadmariadb-git-d4aef382fd9e3cc10ed687cc981b43aac1f29281.tar.gz
Fix compiler failure on fallocate function and used flags.
Diffstat (limited to 'storage/innobase')
-rw-r--r--storage/innobase/include/fil0pagecompress.h7
-rw-r--r--storage/innobase/include/fsp0pagecompress.ic13
-rw-r--r--storage/innobase/os/os0file.cc125
3 files changed, 89 insertions, 56 deletions
diff --git a/storage/innobase/include/fil0pagecompress.h b/storage/innobase/include/fil0pagecompress.h
index fb97af87460..c797c221efc 100644
--- a/storage/innobase/include/fil0pagecompress.h
+++ b/storage/innobase/include/fil0pagecompress.h
@@ -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
diff --git a/storage/innobase/include/fsp0pagecompress.ic b/storage/innobase/include/fsp0pagecompress.ic
index 1ba3b7835c9..3e59106b05d 100644
--- a/storage/innobase/include/fsp0pagecompress.ic
+++ b/storage/innobase/include/fsp0pagecompress.ic
@@ -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);
+}
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index 11c1e75fb73..d7cbd37b3cd 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -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 @@ try_again:
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 @@ try_again:
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 @@ try_again:
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 @@ try_again:
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 @@ found:
// 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 @@ retry:
/* 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