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

Removed unnecessary files and set lz4 under HAVE_LZ4 compiler

option using cmake find_library. Fixed bunch of compiler
warnings.
parent a5cf3a80
# Copyright (C) 2014, SkySQL Ab. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
MACRO (MYSQL_CHECK_LZ4)
CHECK_INCLUDE_FILES(lz4.h HAVE_LZ4_H)
CHECK_LIBRARY_EXISTS(liblz4.a LZ4_compress_limitedOutput "" HAVE_LZ4_LIB)
IF(HAVE_LZ4_LIB AND HAVE_LZ4_H)
ADD_DEFINITIONS(-DHAVE_LZ4=1)
LINK_LIBRARIES(liblz4.a)
ENDIF()
ENDMACRO()
MACRO (MYSQL_CHECK_SHARED_LZ4)
CHECK_INCLUDE_FILES(lz4.h HAVE_LZ4_H)
CHECK_LIBRARY_EXISTS(lz4 LZ4_compress_limitedOutput "" HAVE_LZ4_SHARED_LIB)
IF (HAVE_LZ4_SHARED_LIB AND HAVE_LZ4_H)
ADD_DEFINITIONS(-DHAVE_LZ4=1)
LINK_LIBRARIES(lz4)
ENDIF()
ENDMACRO()
......@@ -18,6 +18,9 @@
INCLUDE(CheckFunctionExists)
INCLUDE(CheckCSourceCompiles)
INCLUDE(CheckCSourceRuns)
INCLUDE(lz4)
MYSQL_CHECK_LZ4()
# OS tests
IF(UNIX)
......@@ -293,7 +296,6 @@ SET(INNOBASE_SOURCES
eval/eval0proc.cc
fil/fil0fil.cc
fil/fil0pagecompress.cc
fil/lz4.c
fsp/fsp0fsp.cc
fut/fut0fut.cc
fut/fut0lst.cc
......
......@@ -2390,7 +2390,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
ulint next_loop_time = ut_time_ms() + 1000;
ulint n_flushed = 0;
ulint last_activity = srv_get_activity_count();
ulint n_lru=0, n_pgc_flush=0, n_pgc_batch=0;
ulint n_lru=0;
ut_ad(!srv_read_only_mode);
......@@ -2429,15 +2429,10 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
#endif
/* Flush pages from flush_list if required */
n_flushed += n_pgc_flush = page_cleaner_flush_pages_if_needed();
n_flushed += page_cleaner_flush_pages_if_needed();
#ifdef UNIV_DEBUG
if (n_pgc_flush) {
fprintf(stderr,"n_pgc_flush:%lu ",n_pgc_flush);
}
#endif
} else {
n_pgc_batch = n_flushed = page_cleaner_do_flush_batch(
n_flushed = page_cleaner_do_flush_batch(
PCT_IO(100),
LSN_MAX);
......@@ -2448,21 +2443,11 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
MONITOR_FLUSH_BACKGROUND_PAGES,
n_flushed);
}
#ifdef UNIV_DEBUG
if (n_pgc_batch) {
fprintf(stderr,"n_pgc_batch:%lu ",n_pgc_batch);
}
#endif
}
#ifdef UNIV_DEBUG
if (n_lru || n_pgc_flush || n_pgc_batch) {
fprintf(stderr,"\n");
n_lru = n_pgc_flush = n_pgc_batch = 0;
}
#endif
}
ut_ad(srv_shutdown_state > 0);
if (srv_fast_shutdown == 2) {
/* In very fast shutdown we simulate a crash of
buffer pool. We are not required to do any flushing */
......
......@@ -548,7 +548,7 @@ buf_mtflu_flush_work_items(
if((int)done_wi->id_usr == -1 &&
done_wi->wi_status == WRK_ITEM_SET ) {
fprintf(stderr,
"**Set/Unused work_item[%lu] flush_type=%lu\n",
"**Set/Unused work_item[%lu] flush_type=%d\n",
i,
done_wi->wr.flush_type);
ut_a(0);
......
......@@ -63,7 +63,9 @@ static ulint srv_data_read, srv_data_written;
#include <linux/falloc.h>
#endif
#include "row0mysql.h"
#ifdef HAVE_LZ4
#include "lz4.h"
#endif
/****************************************************************//**
For page compressed pages compress the page before actual write
......@@ -108,10 +110,11 @@ fil_compress_page(
fprintf(stderr,
"InnoDB: Note: Preparing for compress for space %lu name %s len %lu\n",
space_id, fil_space_name(space), len);
#endif
#endif /* UNIV_DEBUG */
write_size = UNIV_PAGE_SIZE - header_len;
#ifdef HAVE_LZ4
if (srv_use_lz4) {
err = LZ4_compress_limitedOutput((const char *)buf, (char *)out_buf+header_len, len, write_size);
write_size = err;
......@@ -127,6 +130,7 @@ fil_compress_page(
return (buf);
}
} else {
#endif /* HAVE_LZ4 */
err = compress2(out_buf+header_len, &write_size, buf, len, level);
if (err != Z_OK) {
......@@ -139,7 +143,9 @@ fil_compress_page(
*out_len = len;
return (buf);
}
#ifdef HAVE_LZ4
}
#endif /* HAVE_LZ4 */
/* Set up the page header */
memcpy(out_buf, buf, FIL_PAGE_DATA);
......@@ -148,11 +154,18 @@ fil_compress_page(
/* Set up the correct page type */
mach_write_to_2(out_buf+FIL_PAGE_TYPE, FIL_PAGE_PAGE_COMPRESSED);
/* Set up the flush lsn to be compression algorithm */
#ifdef HAVE_LZ4
if (srv_use_lz4) {
mach_write_to_8(out_buf+FIL_PAGE_FILE_FLUSH_LSN, FIL_PAGE_COMPRESSION_LZ4);
} else {
#endif /* HAVE_LZ4 */
mach_write_to_8(out_buf+FIL_PAGE_FILE_FLUSH_LSN, FIL_PAGE_COMPRESSION_ZLIB);
#ifdef HAVE_LZ4
}
#endif /* HAVE_LZ4 */
/* Set up the actual payload lenght */
mach_write_to_2(out_buf+FIL_PAGE_DATA, write_size);
......@@ -161,12 +174,18 @@ fil_compress_page(
ut_ad(fil_page_is_compressed(out_buf));
ut_ad(mach_read_from_4(out_buf+FIL_PAGE_SPACE_OR_CHKSUM) == BUF_NO_CHECKSUM_MAGIC);
ut_ad(mach_read_from_2(out_buf+FIL_PAGE_DATA) == write_size);
#ifdef HAVE_LZ4
if (srv_use_lz4) {
ut_ad(mach_read_from_8(out_buf+FIL_PAGE_FILE_FLUSH_LSN) == FIL_PAGE_COMPRESSION_LZ4);
} else {
#endif /* HAVE_LZ4 */
ut_ad(mach_read_from_8(out_buf+FIL_PAGE_FILE_FLUSH_LSN) == FIL_PAGE_COMPRESSION_ZLIB);
#ifdef HAVE_LZ4
}
#endif
#endif /* HAVE_LZ4 */
#endif /* UNIV_DEBUG */
write_size+=header_len;
/* Actual write needs to be alligned on block size */
......@@ -236,8 +255,8 @@ fil_decompress_page(
if (page_buf == NULL) {
#ifdef UNIV_DEBUG
fprintf(stderr,
"InnoDB: Note: Compression buffer not given, allocating...\n");
#endif
"InnoDB: Note: FIL: Compression buffer not given, allocating...\n");
#endif /* UNIV_DEBUG */
in_buf = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE));
} else {
in_buf = page_buf;
......@@ -261,7 +280,7 @@ fil_decompress_page(
fprintf(stderr,
"InnoDB: Note: Preparing for decompress for len %lu\n",
actual_size);
#endif
#endif /* UNIV_DEBUG */
err= uncompress(in_buf, &len, buf+FIL_PAGE_DATA+FIL_PAGE_COMPRESSED_SIZE, (unsigned long)actual_size);
......@@ -284,11 +303,12 @@ fil_decompress_page(
fprintf(stderr,
"InnoDB: Note: Decompression succeeded for len %lu \n",
len);
#endif
#endif /* UNIV_DEBUG */
#ifdef HAVE_LZ4
} else if (compression_alg == FIL_PAGE_COMPRESSION_LZ4) {
err = LZ4_decompress_fast((const char *)buf+FIL_PAGE_DATA+FIL_PAGE_COMPRESSED_SIZE, (char *)in_buf, UNIV_PAGE_SIZE);
if (err != actual_size) {
if (err != (int)actual_size) {
fprintf(stderr,
"InnoDB: Corruption: Page is marked as compressed\n"
"InnoDB: but decompression read only %d bytes.\n"
......@@ -298,6 +318,7 @@ fil_decompress_page(
ut_error;
}
#endif /* HAVE_LZ4 */
} else {
fprintf(stderr,
"InnoDB: Corruption: Page is marked as compressed\n"
......
This diff is collapsed.
This diff is collapsed.
......@@ -16607,11 +16607,12 @@ static MYSQL_SYSVAR_BOOL(use_trim, srv_use_trim,
"Use trim.",
NULL, NULL, TRUE);
#ifdef HAVE_LZ4
static MYSQL_SYSVAR_BOOL(use_lz4, srv_use_lz4,
PLUGIN_VAR_OPCMDARG ,
"Use LZ4 for page compression",
NULL, NULL, FALSE);
#endif /* HAVE_LZ4 */
static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(additional_mem_pool_size),
......
......@@ -54,12 +54,12 @@ dict_tf_verify_flags(
DBUG_EXECUTE_IF("dict_tf_verify_flags_failure",
return(ULINT_UNDEFINED););
ut_ad(!table_unused);
ut_ad(!fsp_unused);
ut_ad(page_ssize == 0 || page_ssize != 0); /* silence compiler */
ut_ad(compact == 0 || compact == 1); /* silence compiler */
ut_ad(data_dir == 0 || data_dir == 1); /* silence compiler */
ut_ad(post_antelope == 0 || post_antelope == 1); /* silence compiler */
ut_a(!table_unused);
ut_a(!fsp_unused);
ut_a(page_ssize == 0 || page_ssize != 0); /* silence compiler */
ut_a(compact == 0 || compact == 1); /* silence compiler */
ut_a(data_dir == 0 || data_dir == 1); /* silence compiler */
ut_a(post_antelope == 0 || post_antelope == 1); /* silence compiler */
if (ssize != zip_ssize) {
fprintf(stderr,
......
......@@ -18,6 +18,9 @@
INCLUDE(CheckFunctionExists)
INCLUDE(CheckCSourceCompiles)
INCLUDE(CheckCSourceRuns)
INCLUDE(lz4)
MYSQL_CHECK_SHARED_LZ4()
# OS tests
IF(UNIX)
......@@ -299,7 +302,6 @@ SET(INNOBASE_SOURCES
eval/eval0proc.cc
fil/fil0fil.cc
fil/fil0pagecompress.cc
fil/lz4.c
fsp/fsp0fsp.cc
fut/fut0fut.cc
fut/fut0lst.cc
......
......@@ -1863,8 +1863,10 @@ buf_flush_start(
/* There is already a flush batch of the same type running */
fprintf(stderr, "Error: flush_type %d n_flush %lu init_flush\n",
#ifdef UNIV_DEBUG
fprintf(stderr, "Error: flush_type %d n_flush %lu init_flush %lu\n",
flush_type, buf_pool->n_flush[flush_type], buf_pool->init_flush[flush_type]);
#endif
mutex_exit(&buf_pool->flush_state_mutex);
......
......@@ -554,7 +554,7 @@ buf_mtflu_flush_work_items(
if((int)done_wi->id_usr == -1 &&
done_wi->wi_status == WRK_ITEM_SET ) {
fprintf(stderr,
"**Set/Unused work_item[%lu] flush_type=%lu\n",
"**Set/Unused work_item[%lu] flush_type=%d\n",
i,
done_wi->wr.flush_type);
ut_a(0);
......
......@@ -63,7 +63,9 @@ static ulint srv_data_read, srv_data_written;
#include <linux/falloc.h>
#endif
#include "row0mysql.h"
#ifdef HAVE_LZ4
#include "lz4.h"
#endif
/****************************************************************//**
For page compressed pages compress the page before actual write
......@@ -108,10 +110,11 @@ fil_compress_page(
fprintf(stderr,
"InnoDB: Note: Preparing for compress for space %lu name %s len %lu\n",
space_id, fil_space_name(space), len);
#endif
#endif /* UNIV_DEBUG */
write_size = UNIV_PAGE_SIZE - header_len;
#ifdef HAVE_LZ4
if (srv_use_lz4) {
err = LZ4_compress_limitedOutput((const char *)buf, (char *)out_buf+header_len, len, write_size);
write_size = err;
......@@ -127,6 +130,7 @@ fil_compress_page(
return (buf);
}
} else {
#endif /* HAVE_LZ4 */
err = compress2(out_buf+header_len, &write_size, buf, len, level);
if (err != Z_OK) {
......@@ -139,7 +143,9 @@ fil_compress_page(
*out_len = len;
return (buf);
}
#ifdef HAVE_LZ4
}
#endif /* HAVE_LZ4 */
/* Set up the page header */
memcpy(out_buf, buf, FIL_PAGE_DATA);
......@@ -148,11 +154,15 @@ fil_compress_page(
/* Set up the correct page type */
mach_write_to_2(out_buf+FIL_PAGE_TYPE, FIL_PAGE_PAGE_COMPRESSED);
/* Set up the flush lsn to be compression algorithm */
#ifdef HAVE_LZ4
if (srv_use_lz4) {
mach_write_to_8(out_buf+FIL_PAGE_FILE_FLUSH_LSN, FIL_PAGE_COMPRESSION_LZ4);
} else {
#endif /* HAVE_LZ4 */
mach_write_to_8(out_buf+FIL_PAGE_FILE_FLUSH_LSN, FIL_PAGE_COMPRESSION_ZLIB);
#ifdef HAVE_LZ4
}
#endif /* HAVE_LZ4 */
/* Set up the actual payload lenght */
mach_write_to_2(out_buf+FIL_PAGE_DATA, write_size);
......@@ -161,12 +171,17 @@ fil_compress_page(
ut_ad(fil_page_is_compressed(out_buf));
ut_ad(mach_read_from_4(out_buf+FIL_PAGE_SPACE_OR_CHKSUM) == BUF_NO_CHECKSUM_MAGIC);
ut_ad(mach_read_from_2(out_buf+FIL_PAGE_DATA) == write_size);
#ifdef HAVE_LZ4
if (srv_use_lz4) {
ut_ad(mach_read_from_8(out_buf+FIL_PAGE_FILE_FLUSH_LSN) == FIL_PAGE_COMPRESSION_LZ4);
} else {
#endif /* HAVE_LZ4 */
ut_ad(mach_read_from_8(out_buf+FIL_PAGE_FILE_FLUSH_LSN) == FIL_PAGE_COMPRESSION_ZLIB);
#ifdef HAVE_LZ4
}
#endif
#endif /* HAVE_LZ4 */
#endif /* UNIV_DEBUG */
write_size+=header_len;
/* Actual write needs to be alligned on block size */
......@@ -178,7 +193,7 @@ fil_compress_page(
fprintf(stderr,
"InnoDB: Note: Compression succeeded for space %lu name %s len %lu out_len %lu\n",
space_id, fil_space_name(space), len, write_size);
#endif
#endif /* UNIV_DEBUG */
#define SECT_SIZE 512
......@@ -236,8 +251,8 @@ fil_decompress_page(
if (page_buf == NULL) {
#ifdef UNIV_DEBUG
fprintf(stderr,
"InnoDB: Note: Compression buffer not given, allocating...\n");
#endif
"InnoDB: FIL: Note: Compression buffer not given, allocating...\n");
#endif /* UNIV_DEBUG */
in_buf = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE));
} else {
in_buf = page_buf;
......@@ -261,11 +276,10 @@ fil_decompress_page(
fprintf(stderr,
"InnoDB: Note: Preparing for decompress for len %lu\n",
actual_size);
#endif
#endif /* UNIV_DEBUG */
err= uncompress(in_buf, &len, buf+FIL_PAGE_DATA+FIL_PAGE_COMPRESSED_SIZE, (unsigned long)actual_size);
/* If uncompress fails it means that page is corrupted */
if (err != Z_OK) {
......@@ -284,11 +298,12 @@ fil_decompress_page(
fprintf(stderr,
"InnoDB: Note: Decompression succeeded for len %lu \n",
len);
#endif
#endif /* UNIV_DEBUG */
#ifdef HAVE_LZ4
} else if (compression_alg == FIL_PAGE_COMPRESSION_LZ4) {
err = LZ4_decompress_fast((const char *)buf+FIL_PAGE_DATA+FIL_PAGE_COMPRESSED_SIZE, (char *)in_buf, UNIV_PAGE_SIZE);
if (err != actual_size) {
if (err != (int)actual_size) {
fprintf(stderr,
"InnoDB: Corruption: Page is marked as compressed\n"
"InnoDB: but decompression read only %d bytes.\n"
......@@ -298,6 +313,7 @@ fil_decompress_page(
ut_error;
}
#endif /* HAVE_LZ4 */
} else {
fprintf(stderr,
"InnoDB: Corruption: Page is marked as compressed\n"
......
This diff is collapsed.
This diff is collapsed.
......@@ -17968,10 +17968,12 @@ static MYSQL_SYSVAR_BOOL(use_trim, srv_use_trim,
"Use trim.",
NULL, NULL, TRUE);
#ifdef HAVE_LZ4
static MYSQL_SYSVAR_BOOL(use_lz4, srv_use_lz4,
PLUGIN_VAR_OPCMDARG ,
"Use LZ4 for page compression",
NULL, NULL, FALSE);
#endif /* HAVE_LZ4 */
static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(log_block_size),
......
......@@ -54,12 +54,12 @@ dict_tf_verify_flags(
DBUG_EXECUTE_IF("dict_tf_verify_flags_failure",
return(ULINT_UNDEFINED););
ut_ad(!table_unused);
ut_ad(!fsp_unused);
ut_ad(page_ssize == 0 || page_ssize != 0); /* silence compiler */
ut_ad(compact == 0 || compact == 1); /* silence compiler */
ut_ad(data_dir == 0 || data_dir == 1); /* silence compiler */
ut_ad(post_antelope == 0 || post_antelope == 1); /* silence compiler */
ut_a(!table_unused);
ut_a(!fsp_unused);
ut_a(page_ssize == 0 || page_ssize != 0); /* silence compiler */
ut_a(compact == 0 || compact == 1); /* silence compiler */
ut_a(data_dir == 0 || data_dir == 1); /* silence compiler */
ut_a(post_antelope == 0 || post_antelope == 1); /* silence compiler */
if (ssize != zip_ssize) {
fprintf(stderr,
......
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