summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@skysql.com>2014-12-02 19:25:58 +0200
committerJan Lindström <jan.lindstrom@skysql.com>2014-12-02 19:25:58 +0200
commit01590005ba44f350f63b70a7ceb9f69095b293d5 (patch)
tree66daf7ccc7c98680197596cce28156dc3b206c7c
parent3502d7412148d543082aad3c72bbadf742f0a60d (diff)
downloadmariadb-git-01590005ba44f350f63b70a7ceb9f69095b293d5.tar.gz
Fix buildbot valgrind errors on test innodb.innodb-page_compression_tables
Problem was that temporal buffers allocated for page compression are not initialized and rest of the page that is actually writen was als not initialized after previous usage.
-rw-r--r--storage/innobase/fil/fil0pagecompress.cc18
-rw-r--r--storage/innobase/os/os0file.cc6
-rw-r--r--storage/xtradb/fil/fil0pagecompress.cc18
-rw-r--r--storage/xtradb/os/os0file.cc6
4 files changed, 20 insertions, 28 deletions
diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc
index 2b0196c9017..635e9c88fad 100644
--- a/storage/innobase/fil/fil0pagecompress.cc
+++ b/storage/innobase/fil/fil0pagecompress.cc
@@ -456,11 +456,14 @@ fil_compress_page(
/* Actual write needs to be alligned on block size */
if (write_size % block_size) {
-#ifdef UNIV_DEBUG
size_t tmp = write_size;
+#ifdef UNIV_DEBUG
ut_a(block_size > 0);
#endif
write_size = (size_t)ut_uint64_align_up((ib_uint64_t)write_size, block_size);
+ /* Initialize rest of the written data to avoid
+ uninitialized bytes */
+ memset(out_buf+tmp, 0, write_size-tmp);
#ifdef UNIV_DEBUG
ut_a(write_size > 0 && ((write_size % block_size) == 0));
ut_a(write_size >= tmp);
@@ -477,19 +480,10 @@ fil_compress_page(
srv_stats.page_compression_saved.add((len - write_size));
srv_stats.pages_page_compressed.inc();
-#if defined (__linux__) && (!defined(FALLOC_FL_PUNCH_HOLE) || !defined (FALLOC_FL_KEEP_SIZE))
- if (srv_use_trim) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: [Warning] System does not support FALLOC_FL_PUNCH_HOLE || FALLOC_FL_KEEP_SIZE.\n"
- " InnoDB: Disabling trim for now.\n");
- srv_use_trim = FALSE;
- }
-#endif
-
if (!srv_use_trim) {
/* If persistent trims are not used we always write full
- page */
+ page and end of the page needs to be initialized.*/
+ memset(out_buf+write_size, 0, len-write_size);
write_size = len;
}
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index 3ea3df0227c..11c1e75fb73 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -6397,7 +6397,7 @@ os_file_trim(
}
#ifdef __linux__
-#if defined(FALLOC_FL_PUNCH_HOLE) && defined (FALLOC_FL_KEEP_SIZE)
+#if defined(HAVE_POSIX_FALLOCATE)
int ret = fallocate(slot->file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, off, trim_len);
if (ret) {
@@ -6435,7 +6435,7 @@ os_file_trim(
*slot->write_size = 0;
}
-#endif /* HAVE_FALLOCATE ... */
+#endif /* HAVE_POSIX_FALLOCATE ... */
#elif defined(_WIN32)
FILE_LEVEL_TRIM flt;
@@ -6523,6 +6523,7 @@ os_slot_alloc_page_buf(
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);
}
@@ -6538,6 +6539,7 @@ os_slot_alloc_lzo_mem(
{
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);
}
#endif
diff --git a/storage/xtradb/fil/fil0pagecompress.cc b/storage/xtradb/fil/fil0pagecompress.cc
index 20b6b0b1b15..0b622bac8ba 100644
--- a/storage/xtradb/fil/fil0pagecompress.cc
+++ b/storage/xtradb/fil/fil0pagecompress.cc
@@ -453,11 +453,14 @@ fil_compress_page(
/* Actual write needs to be alligned on block size */
if (write_size % block_size) {
-#ifdef UNIV_DEBUG
size_t tmp = write_size;
+#ifdef UNIV_DEBUG
ut_a(block_size > 0);
#endif
write_size = (size_t)ut_uint64_align_up((ib_uint64_t)write_size, block_size);
+ /* Initialize rest of the written data to avoid
+ uninitialized bytes */
+ memset(out_buf+tmp, 0, write_size-tmp);
#ifdef UNIV_DEBUG
ut_a(write_size > 0 && ((write_size % block_size) == 0));
ut_a(write_size >= tmp);
@@ -474,19 +477,10 @@ fil_compress_page(
srv_stats.page_compression_saved.add((len - write_size));
srv_stats.pages_page_compressed.inc();
-#if defined (__linux__) && (!defined(FALLOC_FL_PUNCH_HOLE) || !defined (FALLOC_FL_KEEP_SIZE))
- if (srv_use_trim) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: [Warning] System does not support FALLOC_FL_PUNCH_HOLE || FALLOC_FL_KEEP_SIZE.\n"
- " InnoDB: Disabling trim for now.\n");
- srv_use_trim = FALSE;
- }
-#endif
-
if (!srv_use_trim) {
/* If persistent trims are not used we always write full
- page */
+ page and end of the page needs to be initialized.*/
+ memset(out_buf+write_size, 0, len-write_size);
write_size = len;
}
diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc
index 5fc1ab57c46..48d7cbf274a 100644
--- a/storage/xtradb/os/os0file.cc
+++ b/storage/xtradb/os/os0file.cc
@@ -6490,7 +6490,7 @@ os_file_trim(
}
#ifdef __linux__
-#if defined(FALLOC_FL_PUNCH_HOLE) && defined (FALLOC_FL_KEEP_SIZE)
+#if defined(POSIX_FALLOCATE)
int ret = fallocate(slot->file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, off, trim_len);
if (ret) {
@@ -6528,7 +6528,7 @@ os_file_trim(
*slot->write_size = 0;
}
-#endif /* HAVE_FALLOCATE ... */
+#endif /* HAVE_POSIX_FALLOCATE ... */
#elif defined(_WIN32)
FILE_LEVEL_TRIM flt;
@@ -6615,6 +6615,7 @@ os_slot_alloc_page_buf(
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);
}
@@ -6630,6 +6631,7 @@ os_slot_alloc_lzo_mem(
{
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);
}
#endif