Skip to content

Commit fa9f5f6

Browse files
author
Jan Lindström
committed
Removed unnecessary files and set lz4 under HAVE_LZ4 compiler
option using cmake find_library. Fixed bunch of compiler warnings.
1 parent a5cf3a8 commit fa9f5f6

File tree

17 files changed

+121
-2109
lines changed

17 files changed

+121
-2109
lines changed

cmake/lz4.cmake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (C) 2014, SkySQL Ab. All Rights Reserved.
2+
#
3+
# This program is free software; you can redistribute it and/or modify it under
4+
# the terms of the GNU General Public License as published by the Free Software
5+
# Foundation; version 2 of the License.
6+
#
7+
# This program is distributed in the hope that it will be useful, but WITHOUT
8+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9+
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
10+
#
11+
# You should have received a copy of the GNU General Public License along with
12+
# this program; if not, write to the Free Software Foundation, Inc.,
13+
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
14+
15+
MACRO (MYSQL_CHECK_LZ4)
16+
17+
CHECK_INCLUDE_FILES(lz4.h HAVE_LZ4_H)
18+
CHECK_LIBRARY_EXISTS(liblz4.a LZ4_compress_limitedOutput "" HAVE_LZ4_LIB)
19+
20+
IF(HAVE_LZ4_LIB AND HAVE_LZ4_H)
21+
ADD_DEFINITIONS(-DHAVE_LZ4=1)
22+
LINK_LIBRARIES(liblz4.a)
23+
ENDIF()
24+
ENDMACRO()
25+
26+
MACRO (MYSQL_CHECK_SHARED_LZ4)
27+
28+
CHECK_INCLUDE_FILES(lz4.h HAVE_LZ4_H)
29+
CHECK_LIBRARY_EXISTS(lz4 LZ4_compress_limitedOutput "" HAVE_LZ4_SHARED_LIB)
30+
31+
IF (HAVE_LZ4_SHARED_LIB AND HAVE_LZ4_H)
32+
ADD_DEFINITIONS(-DHAVE_LZ4=1)
33+
LINK_LIBRARIES(lz4)
34+
ENDIF()
35+
ENDMACRO()

storage/innobase/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
INCLUDE(CheckFunctionExists)
1919
INCLUDE(CheckCSourceCompiles)
2020
INCLUDE(CheckCSourceRuns)
21+
INCLUDE(lz4)
22+
23+
MYSQL_CHECK_LZ4()
2124

2225
# OS tests
2326
IF(UNIX)
@@ -293,7 +296,6 @@ SET(INNOBASE_SOURCES
293296
eval/eval0proc.cc
294297
fil/fil0fil.cc
295298
fil/fil0pagecompress.cc
296-
fil/lz4.c
297299
fsp/fsp0fsp.cc
298300
fut/fut0fut.cc
299301
fut/fut0lst.cc

storage/innobase/buf/buf0flu.cc

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,7 +2390,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
23902390
ulint next_loop_time = ut_time_ms() + 1000;
23912391
ulint n_flushed = 0;
23922392
ulint last_activity = srv_get_activity_count();
2393-
ulint n_lru=0, n_pgc_flush=0, n_pgc_batch=0;
2393+
ulint n_lru=0;
23942394

23952395
ut_ad(!srv_read_only_mode);
23962396

@@ -2429,17 +2429,12 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
24292429
#endif
24302430

24312431
/* Flush pages from flush_list if required */
2432-
n_flushed += n_pgc_flush = page_cleaner_flush_pages_if_needed();
2432+
n_flushed += page_cleaner_flush_pages_if_needed();
24332433

2434-
#ifdef UNIV_DEBUG
2435-
if (n_pgc_flush) {
2436-
fprintf(stderr,"n_pgc_flush:%lu ",n_pgc_flush);
2437-
}
2438-
#endif
24392434
} else {
2440-
n_pgc_batch = n_flushed = page_cleaner_do_flush_batch(
2441-
PCT_IO(100),
2442-
LSN_MAX);
2435+
n_flushed = page_cleaner_do_flush_batch(
2436+
PCT_IO(100),
2437+
LSN_MAX);
24432438

24442439
if (n_flushed) {
24452440
MONITOR_INC_VALUE_CUMULATIVE(
@@ -2448,21 +2443,11 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
24482443
MONITOR_FLUSH_BACKGROUND_PAGES,
24492444
n_flushed);
24502445
}
2451-
#ifdef UNIV_DEBUG
2452-
if (n_pgc_batch) {
2453-
fprintf(stderr,"n_pgc_batch:%lu ",n_pgc_batch);
2454-
}
2455-
#endif
2456-
}
2457-
#ifdef UNIV_DEBUG
2458-
if (n_lru || n_pgc_flush || n_pgc_batch) {
2459-
fprintf(stderr,"\n");
2460-
n_lru = n_pgc_flush = n_pgc_batch = 0;
24612446
}
2462-
#endif
24632447
}
24642448

24652449
ut_ad(srv_shutdown_state > 0);
2450+
24662451
if (srv_fast_shutdown == 2) {
24672452
/* In very fast shutdown we simulate a crash of
24682453
buffer pool. We are not required to do any flushing */

storage/innobase/buf/buf0mtflu.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ buf_mtflu_flush_work_items(
548548
if((int)done_wi->id_usr == -1 &&
549549
done_wi->wi_status == WRK_ITEM_SET ) {
550550
fprintf(stderr,
551-
"**Set/Unused work_item[%lu] flush_type=%lu\n",
551+
"**Set/Unused work_item[%lu] flush_type=%d\n",
552552
i,
553553
done_wi->wr.flush_type);
554554
ut_a(0);

storage/innobase/fil/fil0pagecompress.cc

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ static ulint srv_data_read, srv_data_written;
6363
#include <linux/falloc.h>
6464
#endif
6565
#include "row0mysql.h"
66+
#ifdef HAVE_LZ4
6667
#include "lz4.h"
68+
#endif
6769

6870
/****************************************************************//**
6971
For page compressed pages compress the page before actual write
@@ -108,10 +110,11 @@ fil_compress_page(
108110
fprintf(stderr,
109111
"InnoDB: Note: Preparing for compress for space %lu name %s len %lu\n",
110112
space_id, fil_space_name(space), len);
111-
#endif
113+
#endif /* UNIV_DEBUG */
112114

113115
write_size = UNIV_PAGE_SIZE - header_len;
114116

117+
#ifdef HAVE_LZ4
115118
if (srv_use_lz4) {
116119
err = LZ4_compress_limitedOutput((const char *)buf, (char *)out_buf+header_len, len, write_size);
117120
write_size = err;
@@ -127,6 +130,7 @@ fil_compress_page(
127130
return (buf);
128131
}
129132
} else {
133+
#endif /* HAVE_LZ4 */
130134
err = compress2(out_buf+header_len, &write_size, buf, len, level);
131135

132136
if (err != Z_OK) {
@@ -139,7 +143,9 @@ fil_compress_page(
139143
*out_len = len;
140144
return (buf);
141145
}
146+
#ifdef HAVE_LZ4
142147
}
148+
#endif /* HAVE_LZ4 */
143149

144150
/* Set up the page header */
145151
memcpy(out_buf, buf, FIL_PAGE_DATA);
@@ -148,11 +154,18 @@ fil_compress_page(
148154
/* Set up the correct page type */
149155
mach_write_to_2(out_buf+FIL_PAGE_TYPE, FIL_PAGE_PAGE_COMPRESSED);
150156
/* Set up the flush lsn to be compression algorithm */
157+
158+
#ifdef HAVE_LZ4
151159
if (srv_use_lz4) {
152160
mach_write_to_8(out_buf+FIL_PAGE_FILE_FLUSH_LSN, FIL_PAGE_COMPRESSION_LZ4);
153161
} else {
162+
#endif /* HAVE_LZ4 */
154163
mach_write_to_8(out_buf+FIL_PAGE_FILE_FLUSH_LSN, FIL_PAGE_COMPRESSION_ZLIB);
164+
165+
#ifdef HAVE_LZ4
155166
}
167+
#endif /* HAVE_LZ4 */
168+
156169
/* Set up the actual payload lenght */
157170
mach_write_to_2(out_buf+FIL_PAGE_DATA, write_size);
158171

@@ -161,12 +174,18 @@ fil_compress_page(
161174
ut_ad(fil_page_is_compressed(out_buf));
162175
ut_ad(mach_read_from_4(out_buf+FIL_PAGE_SPACE_OR_CHKSUM) == BUF_NO_CHECKSUM_MAGIC);
163176
ut_ad(mach_read_from_2(out_buf+FIL_PAGE_DATA) == write_size);
177+
178+
#ifdef HAVE_LZ4
164179
if (srv_use_lz4) {
165180
ut_ad(mach_read_from_8(out_buf+FIL_PAGE_FILE_FLUSH_LSN) == FIL_PAGE_COMPRESSION_LZ4);
166181
} else {
182+
#endif /* HAVE_LZ4 */
167183
ut_ad(mach_read_from_8(out_buf+FIL_PAGE_FILE_FLUSH_LSN) == FIL_PAGE_COMPRESSION_ZLIB);
184+
185+
#ifdef HAVE_LZ4
168186
}
169-
#endif
187+
#endif /* HAVE_LZ4 */
188+
#endif /* UNIV_DEBUG */
170189

171190
write_size+=header_len;
172191
/* Actual write needs to be alligned on block size */
@@ -236,8 +255,8 @@ fil_decompress_page(
236255
if (page_buf == NULL) {
237256
#ifdef UNIV_DEBUG
238257
fprintf(stderr,
239-
"InnoDB: Note: Compression buffer not given, allocating...\n");
240-
#endif
258+
"InnoDB: Note: FIL: Compression buffer not given, allocating...\n");
259+
#endif /* UNIV_DEBUG */
241260
in_buf = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE));
242261
} else {
243262
in_buf = page_buf;
@@ -261,7 +280,7 @@ fil_decompress_page(
261280
fprintf(stderr,
262281
"InnoDB: Note: Preparing for decompress for len %lu\n",
263282
actual_size);
264-
#endif
283+
#endif /* UNIV_DEBUG */
265284

266285
err= uncompress(in_buf, &len, buf+FIL_PAGE_DATA+FIL_PAGE_COMPRESSED_SIZE, (unsigned long)actual_size);
267286

@@ -284,11 +303,12 @@ fil_decompress_page(
284303
fprintf(stderr,
285304
"InnoDB: Note: Decompression succeeded for len %lu \n",
286305
len);
287-
#endif
306+
#endif /* UNIV_DEBUG */
307+
#ifdef HAVE_LZ4
288308
} else if (compression_alg == FIL_PAGE_COMPRESSION_LZ4) {
289309
err = LZ4_decompress_fast((const char *)buf+FIL_PAGE_DATA+FIL_PAGE_COMPRESSED_SIZE, (char *)in_buf, UNIV_PAGE_SIZE);
290310

291-
if (err != actual_size) {
311+
if (err != (int)actual_size) {
292312
fprintf(stderr,
293313
"InnoDB: Corruption: Page is marked as compressed\n"
294314
"InnoDB: but decompression read only %d bytes.\n"
@@ -298,6 +318,7 @@ fil_decompress_page(
298318

299319
ut_error;
300320
}
321+
#endif /* HAVE_LZ4 */
301322
} else {
302323
fprintf(stderr,
303324
"InnoDB: Corruption: Page is marked as compressed\n"

0 commit comments

Comments
 (0)