Commit 5e55d1ce authored by Jan Lindström's avatar Jan Lindström

Changes for Fusion-io multi-threaded flush, page compressed tables and

tables using atomic write/table.

This is work in progress and some parts are at most POC quality.
parent 1f4f425a
......@@ -278,6 +278,8 @@ SET(INNOBASE_SOURCES
buf/buf0flu.cc
buf/buf0lru.cc
buf/buf0rea.cc
# TODO: JAN uncomment
# buf/buf0mtflu.cc
data/data0data.cc
data/data0type.cc
dict/dict0boot.cc
......@@ -291,6 +293,7 @@ SET(INNOBASE_SOURCES
eval/eval0eval.cc
eval/eval0proc.cc
fil/fil0fil.cc
fil/fil0pagecompress.cc
fsp/fsp0fsp.cc
fut/fut0fut.cc
fut/fut0lst.cc
......
......@@ -2,6 +2,7 @@
Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
......@@ -3254,6 +3255,7 @@ buf_page_init_low(
bpage->access_time = 0;
bpage->newest_modification = 0;
bpage->oldest_modification = 0;
bpage->write_size = 0;
HASH_INVALIDATE(bpage, hash);
#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
bpage->file_page_was_freed = FALSE;
......
/*****************************************************************************
Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 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
......@@ -365,8 +366,8 @@ buf_dblwr_init_or_restore_pages(
/* Read the trx sys header to check if we are using the doublewrite
buffer */
fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO, 0,
UNIV_PAGE_SIZE, read_buf, NULL);
fil_io(OS_FILE_READ, true, TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO, 0,
UNIV_PAGE_SIZE, read_buf, NULL, 0);
doublewrite = read_buf + TRX_SYS_DOUBLEWRITE;
if (mach_read_from_4(doublewrite + TRX_SYS_DOUBLEWRITE_MAGIC)
......@@ -402,11 +403,11 @@ buf_dblwr_init_or_restore_pages(
fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, 0, block1, 0,
TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
buf, NULL);
fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, 0, block2, 0,
buf, NULL, 0);
fil_io(OS_FILE_READ, true, TRX_SYS_SPACE, 0, block2, 0,
TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
buf + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
NULL);
NULL, 0);
/* Check if any of these pages is half-written in data files, in the
intended position */
......@@ -433,8 +434,8 @@ buf_dblwr_init_or_restore_pages(
+ i - TRX_SYS_DOUBLEWRITE_BLOCK_SIZE;
}
fil_io(OS_FILE_WRITE, TRUE, 0, 0, source_page_no, 0,
UNIV_PAGE_SIZE, page, NULL);
fil_io(OS_FILE_WRITE, true, 0, 0, source_page_no, 0,
UNIV_PAGE_SIZE, page, NULL, 0);
} else {
space_id = mach_read_from_4(
......@@ -476,7 +477,7 @@ buf_dblwr_init_or_restore_pages(
fil_io(OS_FILE_READ, TRUE, space_id, zip_size,
page_no, 0,
zip_size ? zip_size : UNIV_PAGE_SIZE,
read_buf, NULL);
read_buf, NULL, 0);
/* Check if the page is corrupt */
......@@ -528,7 +529,7 @@ buf_dblwr_init_or_restore_pages(
fil_io(OS_FILE_WRITE, TRUE, space_id,
zip_size, page_no, 0,
zip_size ? zip_size : UNIV_PAGE_SIZE,
page, NULL);
page, NULL, 0);
ib_logf(IB_LOG_LEVEL_INFO,
"Recovered the page from"
......@@ -714,7 +715,7 @@ buf_dblwr_write_block_to_datafile(
buf_page_get_page_no(bpage), 0,
buf_page_get_zip_size(bpage),
(void*) bpage->zip.data,
(void*) bpage);
(void*) bpage, 0);
return;
}
......@@ -727,7 +728,7 @@ buf_dblwr_write_block_to_datafile(
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE, buf_block_get_space(block), 0,
buf_block_get_page_no(block), 0, UNIV_PAGE_SIZE,
(void*) block->frame, (void*) block);
(void*) block->frame, (void*) block, 0);
}
/********************************************************************//**
......@@ -820,7 +821,7 @@ try_again:
fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0,
buf_dblwr->block1, 0, len,
(void*) write_buf, NULL);
(void*) write_buf, NULL, 0);
if (buf_dblwr->first_free <= TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) {
/* No unwritten pages in the second block. */
......@@ -836,7 +837,7 @@ try_again:
fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0,
buf_dblwr->block2, 0, len,
(void*) write_buf, NULL);
(void*) write_buf, NULL, 0);
flush:
/* increment the doublewrite flushed pages counter */
......@@ -1056,14 +1057,14 @@ retry:
fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0,
offset, 0, UNIV_PAGE_SIZE,
(void*) (buf_dblwr->write_buf
+ UNIV_PAGE_SIZE * i), NULL);
+ UNIV_PAGE_SIZE * i), NULL, 0);
} else {
/* It is a regular page. Write it directly to the
doublewrite buffer */
fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0,
offset, 0, UNIV_PAGE_SIZE,
(void*) ((buf_block_t*) bpage)->frame,
NULL);
NULL, 0);
}
/* Now flush the doublewrite buffer data to disk */
......
This diff is collapsed.
This diff is collapsed.
/*****************************************************************************
Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 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
......@@ -182,14 +183,14 @@ buf_read_page_low(
*err = fil_io(OS_FILE_READ | wake_later
| ignore_nonexistent_pages,
sync, space, zip_size, offset, 0, zip_size,
bpage->zip.data, bpage);
bpage->zip.data, bpage, 0);
} else {
ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE);
*err = fil_io(OS_FILE_READ | wake_later
| ignore_nonexistent_pages,
sync, space, 0, offset, 0, UNIV_PAGE_SIZE,
((buf_block_t*) bpage)->frame, bpage);
((buf_block_t*) bpage)->frame, bpage, 0);
}
thd_wait_end(NULL);
......
......@@ -2,6 +2,7 @@
Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 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
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*****************************************************************************
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 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
......@@ -56,6 +57,18 @@ typedef struct st_innobase_share {
/** Prebuilt structures in an InnoDB table handle used within MySQL */
struct row_prebuilt_t;
/** Engine specific table options are definined using this struct */
struct ha_table_option_struct
{
bool page_compressed; /*!< Table is using page compression
if this option is true. */
int page_compression_level; /*!< Table page compression level
or UNIV_UNSPECIFIED. */
bool atomic_writes; /*!< Use atomic writes for this
table if this options is true. */
};
/** The class defining a handle to an Innodb table */
class ha_innobase: public handler
{
......@@ -182,6 +195,8 @@ class ha_innobase: public handler
char* norm_name,
char* temp_path,
char* remote_path);
const char* check_table_options(THD *thd, TABLE* table,
HA_CREATE_INFO* create_info, const bool use_tablespace, const ulint file_format);
int create(const char *name, register TABLE *form,
HA_CREATE_INFO *create_info);
int truncate();
......
/*****************************************************************************
Copyright (c) 2005, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 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
......@@ -248,6 +249,22 @@ ha_innobase::check_if_supported_inplace_alter(
update_thd();
trx_search_latch_release_if_reserved(prebuilt->trx);
/* Change on engine specific table options require rebuild of the
table */
if (ha_alter_info->handler_flags
== Alter_inplace_info::CHANGE_CREATE_OPTION) {
ha_table_option_struct *new_options= ha_alter_info->create_info->option_struct;
ha_table_option_struct *old_options= table->s->option_struct;
if (new_options->page_compressed != old_options->page_compressed ||
new_options->page_compression_level != old_options->page_compression_level ||
new_options->atomic_writes != old_options->page_compression_level) {
ha_alter_info->unsupported_reason = innobase_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON);
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
}
}
if (ha_alter_info->handler_flags
& ~(INNOBASE_ONLINE_OPERATIONS | INNOBASE_INPLACE_REBUILD)) {
if (ha_alter_info->handler_flags
......@@ -3331,6 +3348,17 @@ ha_innobase::prepare_inplace_alter_table(
if (ha_alter_info->handler_flags
& Alter_inplace_info::CHANGE_CREATE_OPTION) {
/* Check engine specific table options */
if (const char* invalid_tbopt = check_table_options(
user_thd, altered_table,
ha_alter_info->create_info,
prebuilt->table->space != 0,
srv_file_format)) {
my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0),
table_type(), invalid_tbopt);
goto err_exit_no_heap;
}
if (const char* invalid_opt = create_options_are_invalid(
user_thd, altered_table,
ha_alter_info->create_info,
......
/*****************************************************************************
Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 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
......@@ -1470,6 +1471,11 @@ struct buf_page_t{
state == BUF_BLOCK_ZIP_PAGE and
zip.data == NULL means an active
buf_pool->watch */
ulint write_size; /* Write size is set when this
page is first time written and then
if written again we check is TRIM
operation needed. */
#ifndef UNIV_HOTBACKUP
buf_page_t* hash; /*!< node used in chaining to
buf_pool->page_hash or
......
......@@ -2,6 +2,7 @@
Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 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
......@@ -42,6 +43,8 @@ Created 1/8/1996 Heikki Tuuri
#include "ut0byte.h"
#include "trx0types.h"
#include "row0types.h"
#include "fsp0fsp.h"
#include "dict0pagecompress.h"
#ifndef UNIV_HOTBACKUP
# include "sync0sync.h"
......@@ -878,7 +881,14 @@ dict_tf_set(
ulint* flags, /*!< in/out: table */
rec_format_t format, /*!< in: file format */
ulint zip_ssize, /*!< in: zip shift size */
bool remote_path) /*!< in: table uses DATA DIRECTORY */
bool remote_path, /*!< in: table uses DATA DIRECTORY
*/
bool page_compressed,/*!< in: table uses page compressed
pages */
ulint page_compression_level, /*!< in: table page compression
level */
bool atomic_writes) /*!< in: table uses atomic
writes */
__attribute__((nonnull));
/********************************************************************//**
Convert a 32 bit integer table flags to the 32 bit integer that is
......@@ -906,6 +916,7 @@ dict_tf_get_zip_size(
/*=================*/
ulint flags) /*!< in: flags */
__attribute__((const));
/********************************************************************//**
Check whether the table uses the compressed compact page format.
@return compressed page size, or 0 if not compressed */
......@@ -1779,6 +1790,7 @@ dict_tf_to_row_format_string(
#endif /* !UNIV_HOTBACKUP */
#ifndef UNIV_NONINL
#include "dict0dict.ic"
#endif
......
/*****************************************************************************
Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 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
......@@ -537,9 +538,25 @@ dict_tf_is_valid(
ulint zip_ssize = DICT_TF_GET_ZIP_SSIZE(flags);
ulint atomic_blobs = DICT_TF_HAS_ATOMIC_BLOBS(flags);
ulint unused = DICT_TF_GET_UNUSED(flags);
ulint page_compression = DICT_TF_GET_PAGE_COMPRESSION(flags);
ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(flags);
ulint data_dir = DICT_TF_HAS_DATA_DIR(flags);
ulint atomic_writes = DICT_TF_GET_ATOMIC_WRITES(flags);
/* Make sure there are no bits that we do not know about. */
if (unused != 0) {
fprintf(stderr,
"InnoDB: Error: table unused flags are %ld"
" in the data dictionary and are corrupted\n"
"InnoDB: Error: data dictionary flags are\n"
"InnoDB: compact %ld atomic_blobs %ld\n"
"InnoDB: unused %ld data_dir %ld zip_ssize %ld\n"
"InnoDB: page_compression %ld page_compression_level %ld\n"
"InnoDB: atomic_writes %ld\n",
unused,
compact, atomic_blobs, unused, data_dir, zip_ssize,
page_compression, page_compression_level, atomic_writes
);
return(false);
......@@ -550,12 +567,34 @@ dict_tf_is_valid(
data stored off-page in the clustered index. */
if (!compact) {
fprintf(stderr,
"InnoDB: Error: table compact flags are %ld"
" in the data dictionary and are corrupted\n"
"InnoDB: Error: data dictionary flags are\n"
"InnoDB: compact %ld atomic_blobs %ld\n"
"InnoDB: unused %ld data_dir %ld zip_ssize %ld\n"
"InnoDB: page_compression %ld page_compression_level %ld\n"
"InnoDB: atomic_writes %ld\n",
compact, compact, atomic_blobs, unused, data_dir, zip_ssize,
page_compression, page_compression_level, atomic_writes
);
return(false);
}
} else if (zip_ssize) {
/* Antelope does not support COMPRESSED row format. */
fprintf(stderr,
"InnoDB: Error: table flags are %ld"
" in the data dictionary and are corrupted\n"
"InnoDB: Error: data dictionary flags are\n"
"InnoDB: compact %ld atomic_blobs %ld\n"
"InnoDB: unused %ld data_dir %ld zip_ssize %ld\n"
"InnoDB: page_compression %ld page_compression_level %ld\n"
"InnoDB: atomic_writes %ld\n",
flags, compact, atomic_blobs, unused, data_dir, zip_ssize,
page_compression, page_compression_level, atomic_writes
);
return(false);
}
......@@ -568,6 +607,40 @@ dict_tf_is_valid(
|| !atomic_blobs
|| zip_ssize > PAGE_ZIP_SSIZE_MAX) {
fprintf(stderr,
"InnoDB: Error: table compact flags are %ld in the data dictionary and are corrupted\n"
"InnoDB: Error: data dictionary flags are\n"
"InnoDB: compact %ld atomic_blobs %ld\n"
"InnoDB: unused %ld data_dir %ld zip_ssize %ld\n"
"InnoDB: page_compression %ld page_compression_level %ld\n"
"InnoDB: atomic_writes %ld\n",
flags,
compact, atomic_blobs, unused, data_dir, zip_ssize,
page_compression, page_compression_level, atomic_writes
);
return(false);
}
}
if (page_compression || page_compression_level) {
/* Page compression format must have compact and
atomic_blobs and page_compression_level requires
page_compression */
if (!compact
|| !page_compression
|| !atomic_blobs) {
fprintf(stderr,
"InnoDB: Error: table flags are %ld in the data dictionary and are corrupted\n"
"InnoDB: Error: data dictionary flags are\n"
"InnoDB: compact %ld atomic_blobs %ld\n"
"InnoDB: unused %ld data_dir %ld zip_ssize %ld\n"
"InnoDB: page_compression %ld page_compression_level %ld\n"
"InnoDB: atomic_writes %ld\n",
flags, compact, atomic_blobs, unused, data_dir, zip_ssize,
page_compression, page_compression_level, atomic_writes
);
return(false);
}
}
......@@ -594,6 +667,9 @@ dict_sys_tables_type_validate(
ulint zip_ssize = DICT_TF_GET_ZIP_SSIZE(type);
ulint atomic_blobs = DICT_TF_HAS_ATOMIC_BLOBS(type);
ulint unused = DICT_TF_GET_UNUSED(type);
ulint page_compression = DICT_TF_GET_PAGE_COMPRESSION(type);
ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(type);
ulint atomic_writes = DICT_TF_GET_ATOMIC_WRITES(type);
/* The low order bit of SYS_TABLES.TYPE is always set to 1.
If the format is UNIV_FORMAT_B or higher, this field is the same
......@@ -647,6 +723,23 @@ dict_sys_tables_type_validate(
format, so the DATA_DIR flag is compatible with any other
table flags. However, it is not used with TEMPORARY tables.*/
if (page_compression || page_compression_level) {
/* page compressed row format must have low_order_bit and
atomic_blobs bits set and the DICT_N_COLS_COMPACT flag
should be in N_COLS, but we already know about the
low_order_bit and DICT_N_COLS_COMPACT flags. */
if (!atomic_blobs || !page_compression) {
return(ULINT_UNDEFINED);
}
}
if (atomic_writes) {
if (!atomic_blobs) {
return(ULINT_UNDEFINED);
}
}
/* Return the validated SYS_TABLES.TYPE. */
return(type);
}
......@@ -719,7 +812,14 @@ dict_tf_set(
ulint* flags, /*!< in/out: table flags */
rec_format_t format, /*!< in: file format */
ulint zip_ssize, /*!< in: zip shift size */
bool use_data_dir) /*!< in: table uses DATA DIRECTORY */
bool use_data_dir, /*!< in: table uses DATA DIRECTORY
*/
bool page_compressed,/*!< in: table uses page compressed
pages */
ulint page_compression_level, /*!< in: table page compression
level */
bool atomic_writes) /*!< in: table uses atomic
writes */
{
switch (format) {
case REC_FORMAT_REDUNDANT:
......@@ -742,6 +842,22 @@ dict_tf_set(
break;
}
if (page_compressed) {
*flags = DICT_TF_COMPACT
| (1 << DICT_TF_POS_ATOMIC_BLOBS)
| (1 << DICT_TF_POS_PAGE_COMPRESSION)
| (page_compression_level << DICT_TF_POS_PAGE_COMPRESSION_LEVEL);
ut_ad(zip_ssize == 0);
ut_ad(dict_tf_get_page_compression(*flags) == TRUE);
ut_ad(dict_tf_get_page_compression_level(*flags) == page_compression_level);
}
if (atomic_writes) {
*flags |= (1 << DICT_TF_POS_ATOMIC_WRITES);
ut_ad(dict_tf_get_atomic_writes(*flags) == TRUE);
}
if (use_data_dir) {
*flags |= (1 << DICT_TF_POS_DATA_DIR);
}
......@@ -765,6 +881,9 @@ dict_tf_to_fsp_flags(
ulint table_flags) /*!< in: dict_table_t::flags */
{
ulint fsp_flags;
ulint page_compression = DICT_TF_GET_PAGE_COMPRESSION(table_flags);
ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(table_flags);
ulint atomic_writes = DICT_TF_GET_ATOMIC_WRITES(table_flags);
DBUG_EXECUTE_IF("dict_tf_to_fsp_flags_failure",
return(ULINT_UNDEFINED););
......@@ -783,7 +902,20 @@ dict_tf_to_fsp_flags(
fsp_flags |= DICT_TF_HAS_DATA_DIR(table_flags)
? FSP_FLAGS_MASK_DATA_DIR : 0;
/* In addition, tablespace flags also contain if the page
compression is used for this table. */
fsp_flags |= FSP_FLAGS_SET_PAGE_COMPRESSION(fsp_flags, page_compression);
/* In addition, tablespace flags also contain page compression level
if page compression is used for this table. */
fsp_flags |= FSP_FLAGS_SET_PAGE_COMPRESSION_LEVEL(fsp_flags, page_compression_level);
/* In addition, tablespace flags also contain flag if atomic writes
is used for this table */
fsp_flags |= FSP_FLAGS_SET_ATOMIC_WRITES(fsp_flags, atomic_writes);
ut_a(fsp_flags_is_valid(fsp_flags));
ut_a(dict_tf_verify_flags(table_flags, fsp_flags));
return(fsp_flags);
}
......@@ -811,10 +943,15 @@ dict_sys_tables_type_to_tf(
/* Adjust bit zero. */
flags = redundant ? 0 : 1;
/* ZIP_SSIZE, ATOMIC_BLOBS & DATA_DIR are the same. */
/* ZIP_SSIZE, ATOMIC_BLOBS, DATA_DIR, PAGE_COMPRESSION,
PAGE_COMPRESSION_LEVEL, ATOMIC_WRITES are the same. */
flags |= type & (DICT_TF_MASK_ZIP_SSIZE
| DICT_TF_MASK_ATOMIC_BLOBS
| DICT_TF_MASK_DATA_DIR);
| DICT_TF_MASK_DATA_DIR
| DICT_TF_MASK_PAGE_COMPRESSION
| DICT_TF_MASK_PAGE_COMPRESSION_LEVEL
| DICT_TF_MASK_ATOMIC_WRITES
);
return(flags);
}
......@@ -842,10 +979,14 @@ dict_tf_to_sys_tables_type(
/* Adjust bit zero. It is always 1 in SYS_TABLES.TYPE */
type = 1;
/* ZIP_SSIZE, ATOMIC_BLOBS & DATA_DIR are the same. */
/* ZIP_SSIZE, ATOMIC_BLOBS, DATA_DIR, PAGE_COMPRESSION,
PAGE_COMPRESSION_LEVEL, ATOMIC_WRITES are the same. */
type |= flags & (DICT_TF_MASK_ZIP_SSIZE
| DICT_TF_MASK_ATOMIC_BLOBS
| DICT_TF_MASK_DATA_DIR);
| DICT_TF_MASK_DATA_DIR
| DICT_TF_MASK_PAGE_COMPRESSION
| DICT_TF_MASK_PAGE_COMPRESSION_LEVEL
| DICT_TF_MASK_ATOMIC_WRITES);
return(type);
}
......
......@@ -2,6 +2,7 @@
Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 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
......@@ -120,11 +121,25 @@ This flag prevents older engines from attempting to open the table and
allows InnoDB to update_create_info() accordingly. */
#define DICT_TF_WIDTH_DATA_DIR 1
/**
Width of the page compression flag
*/
#define DICT_TF_WIDTH_PAGE_COMPRESSION 1
#define DICT_TF_WIDTH_PAGE_COMPRESSION_LEVEL 4
/**
Width of atomic writes flag
*/
#define DICT_TF_WIDTH_ATOMIC_WRITES 1
/** Width of all the currently known table flags */
#define DICT_TF_BITS (DICT_TF_WIDTH_COMPACT \
+ DICT_TF_WIDTH_ZIP_SSIZE \
+ DICT_TF_WIDTH_ATOMIC_BLOBS \
+ DICT_TF_WIDTH_DATA_DIR)
+ DICT_TF_WIDTH_DATA_DIR \
+ DICT_TF_WIDTH_PAGE_COMPRESSION \
+ DICT_TF_WIDTH_PAGE_COMPRESSION_LEVEL \
+ DICT_TF_WIDTH_ATOMIC_WRITES)
/** A mask of all the known/used bits in table flags */
#define DICT_TF_BIT_MASK (~(~0 << DICT_TF_BITS))
......@@ -140,9 +155,19 @@ allows InnoDB to update_create_info() accordingly. */
/** Zero relative shift position of the DATA_DIR field */
#define DICT_TF_POS_DATA_DIR (DICT_TF_POS_ATOMIC_BLOBS \
+ DICT_TF_WIDTH_ATOMIC_BLOBS)
/** Zero relative shift position of the start of the UNUSED bits */
#define DICT_TF_POS_UNUSED (DICT_TF_POS_DATA_DIR \
/** Zero relative shift position of the PAGE_COMPRESSION field */
#define DICT_TF_POS_PAGE_COMPRESSION (DICT_TF_POS_DATA_DIR \
+ DICT_TF_WIDTH_DATA_DIR)
/** Zero relative shift position of the PAGE_COMPRESSION_LEVEL field */
#define DICT_TF_POS_PAGE_COMPRESSION_LEVEL (DICT_TF_POS_PAGE_COMPRESSION \
+ DICT_TF_WIDTH_PAGE_COMPRESSION)
/** Zero relative shift position of the ATOMIC_WRITES field */
#define DICT_TF_POS_ATOMIC_WRITES (DICT_TF_POS_PAGE_COMPRESSION_LEVEL \
+ DICT_TF_WIDTH_PAGE_COMPRESSION_LEVEL)
/** Zero relative shift position of the start of the UNUSED bits */
#define DICT_TF_POS_UNUSED (DICT_TF_POS_ATOMIC_WRITES \
+ DICT_TF_WIDTH_ATOMIC_WRITES)
/** Bit mask of the COMPACT field */
#define DICT_TF_MASK_COMPACT \
......@@ -160,6 +185,18 @@ allows InnoDB to update_create_info() accordingly. */
#define DICT_TF_MASK_DATA_DIR \
((~(~0 << DICT_TF_WIDTH_DATA_DIR)) \
<< DICT_TF_POS_DATA_DIR)
/** Bit mask of the PAGE_COMPRESSION field */
#define DICT_TF_MASK_PAGE_COMPRESSION \
((~(~0 << DICT_TF_WIDTH_PAGE_COMPRESSION)) \
<< DICT_TF_POS_PAGE_COMPRESSION)
/** Bit mask of the PAGE_COMPRESSION_LEVEL field */
#define DICT_TF_MASK_PAGE_COMPRESSION_LEVEL \
((~(~0 << DICT_TF_WIDTH_PAGE_COMPRESSION_LEVEL)) \
<< DICT_TF_POS_PAGE_COMPRESSION_LEVEL)
/** Bit mask of the ATOMIC_WRITES field */
#define DICT_TF_MASK_ATOMIC_WRITES \
((~(~0 << DICT_TF_WIDTH_ATOMIC_WRITES)) \
<< DICT_TF_POS_ATOMIC_WRITES)
/** Return the value of the COMPACT field */
#define DICT_TF_GET_COMPACT(flags) \
......@@ -177,6 +214,19 @@ allows InnoDB to update_create_info() accordingly. */
#define DICT_TF_HAS_DATA_DIR(flags) \
((flags & DICT_TF_MASK_DATA_DIR) \
>> DICT_TF_POS_DATA_DIR)
/** Return the value of the PAGE_COMPRESSION field */
#define DICT_TF_GET_PAGE_COMPRESSION(flags) \
((flags & DICT_TF_MASK_PAGE_COMPRESSION) \
>> DICT_TF_POS_PAGE_COMPRESSION)
/** Return the value of the PAGE_COMPRESSION_LEVEL field */
#define DICT_TF_GET_PAGE_COMPRESSION_LEVEL(flags) \
((flags & DICT_TF_MASK_PAGE_COMPRESSION_LEVEL) \
>> DICT_TF_POS_PAGE_COMPRESSION_LEVEL)
/** Return the value of the ATOMIC_WRITES field */
#define DICT_TF_GET_ATOMIC_WRITES(flags) \
((flags & DICT_TF_MASK_ATOMIC_WRITES) \
>> DICT_TF_POS_ATOMIC_WRITES)
/** Return the contents of the UNUSED bits */
#define DICT_TF_GET_UNUSED(flags) \
(flags >> DICT_TF_POS_UNUSED)
......
/*****************************************************************************
Copyright (C) 2013 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
*****************************************************************************/
/******************************************************************//**
@file include/dict0pagecompress.h
Helper functions for extracting/storing page compression information
to dictionary.
Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com
***********************************************************************/
#ifndef dict0pagecompress_h
#define dict0pagecompress_h
/********************************************************************//**
Extract the page compression level from table flags.
@return page compression level, or 0 if not compressed */
UNIV_INLINE
ulint
dict_tf_get_page_compression_level(
/*===============================*/
ulint flags) /*!< in: flags */
__attribute__((const));
/********************************************************************//**
Extract the page compression flag from table flags
@return page compression flag, or false if not compressed */
UNIV_INLINE
ibool
dict_tf_get_page_compression(
/*==========================*/
ulint flags) /*!< in: flags */
__attribute__((const));
/********************************************************************//**
Check whether the table uses the page compressed page format.
@return page compression level, or 0 if not compressed */
UNIV_INLINE
ulint
dict_table_page_compression_level(
/*==============================*/
const dict_table_t* table) /*!< in: table */
__attribute__((const));
/********************************************************************//**
Verify that dictionary flags match tablespace flags
@return true if flags match, false if not */
UNIV_INLINE
ibool
dict_tf_verify_flags(
/*=================*/
ulint table_flags, /*!< in: dict_table_t::flags */
ulint fsp_flags) /*!< in: fil_space_t::flags */
__attribute__((const));
/********************************************************************//**
Extract the atomic writes flag from table flags.
@return true if atomic writes are used, false if not used */
UNIV_INLINE
ibool
dict_tf_get_atomic_writes(
/*======================*/
ulint flags) /*!< in: flags */
__attribute__((const));
/********************************************************************//**
Check whether the table uses the atomic writes.
@return true if atomic writes is used, false if not */
UNIV_INLINE
ibool
dict_table_get_atomic_writes(
/*=========================*/
const dict_table_t* table); /*!< in: table */
#ifndef UNIV_NONINL
#include "dict0pagecompress.ic"
#endif
#endif
/*****************************************************************************
Copyright (C) 2013 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
*****************************************************************************/
/******************************************************************//**
@file include/dict0pagecompress.ic
Inline implementation for helper functions for extracting/storing
page compression and atomic writes information to dictionary.
Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com
***********************************************************************/
/********************************************************************//**
Verify that dictionary flags match tablespace flags
@return true if flags match, false if not */
UNIV_INLINE
ibool
dict_tf_verify_flags(
/*=================*/
ulint table_flags, /*!< in: dict_table_t::flags */
ulint fsp_flags) /*!< in: fil_space_t::flags */
{
ulint table_unused = DICT_TF_GET_UNUSED(table_flags);
ulint compact = DICT_TF_GET_COMPACT(table_flags);
ulint ssize = DICT_TF_GET_ZIP_SSIZE(table_flags);
ulint atomic_blobs = DICT_TF_HAS_ATOMIC_BLOBS(table_flags);
ulint data_dir = DICT_TF_HAS_DATA_DIR(table_flags);
ulint page_compression = DICT_TF_GET_PAGE_COMPRESSION(table_flags);
ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(table_flags);
ulint atomic_writes = DICT_TF_GET_ATOMIC_WRITES(table_flags);
ulint post_antelope = FSP_FLAGS_GET_POST_ANTELOPE(fsp_flags);
ulint zip_ssize = FSP_FLAGS_GET_ZIP_SSIZE(fsp_flags);
ulint fsp_atomic_blobs = FSP_FLAGS_HAS_ATOMIC_BLOBS(fsp_flags);
ulint page_ssize = FSP_FLAGS_GET_PAGE_SSIZE(fsp_flags);
ulint fsp_unused = FSP_FLAGS_GET_UNUSED(fsp_flags);
ulint fsp_page_compression = FSP_FLAGS_GET_PAGE_COMPRESSION(fsp_flags);
ulint fsp_page_compression_level = FSP_FLAGS_GET_PAGE_COMPRESSION_LEVEL(fsp_flags);
ulint fsp_atomic_writes = FSP_FLAGS_GET_ATOMIC_WRITES(fsp_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 */
if (ssize != zip_ssize) {
fprintf(stderr,
"InnoDB: Error: table flags has zip_ssize %ld"
" in the data dictionary\n"
"InnoDB: but the flags in file has zip_ssize %ld\n",
ssize, zip_ssize);
return (FALSE);
}
if (atomic_blobs != fsp_atomic_blobs) {
fprintf(stderr,
"InnoDB: Error: table flags has atomic_blobs %ld"
" in the data dictionary\n"
"InnoDB: but the flags in file has atomic_blobs %ld\n",
atomic_blobs, fsp_atomic_blobs);
return (FALSE);
}
if (page_compression != fsp_page_compression) {
fprintf(stderr,
"InnoDB: Error: table flags has page_compression %ld"
" in the data dictionary\n"
"InnoDB: but the flags in file ahas page_compression %ld\n",
page_compression, fsp_page_compression);
return (FALSE);
}
if (page_compression_level != fsp_page_compression_level) {
fprintf(stderr,
"InnoDB: Error: table flags has page_compression_level %ld"
" in the data dictionary\n"
"InnoDB: but the flags in file has page_compression_level %ld\n",
page_compression_level, fsp_page_compression_level);
return (FALSE);
}
if (atomic_writes != fsp_atomic_writes) {
fprintf(stderr,
"InnoDB: Error: table flags has atomic writes %ld"
" in the data dictionary\n"
"InnoDB: but the flags in file has atomic_writes %ld\n",
atomic_writes, fsp_atomic_writes);
return (FALSE);
}
return(TRUE);
}
/********************************************************************//**
Extract the page compression level from dict_table_t::flags.
These flags are in memory, so assert that they are valid.
@return page compression level, or 0 if not compressed */
UNIV_INLINE
ulint
dict_tf_get_page_compression_level(
/*===============================*/
ulint flags) /*!< in: flags */
{
ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(flags);
ut_ad(page_compression_level >= 0 && page_compression_level <= 9);
return(page_compression_level);
}
/********************************************************************//**
Check whether the table uses the page compression page format.
@return page compression level, or 0 if not compressed */
UNIV_INLINE
ulint
dict_table_page_compression_level(
/*==============================*/
const dict_table_t* table) /*!< in: table */
{
ut_ad(table);
ut_ad(dict_tf_get_page_compression(table->flags));
return(dict_tf_get_page_compression_level(table->flags));
}
/********************************************************************//**
Check whether the table uses the page compression page format.
@return true if page compressed, false if not */
UNIV_INLINE
ibool
dict_tf_get_page_compression(
/*=========================*/
ulint flags) /*!< in: flags */
{
return(DICT_TF_GET_PAGE_COMPRESSION(flags));
}
/********************************************************************//**
Check whether the table uses the page compression page format.
@return true if page compressed, false if not */
UNIV_INLINE
ibool
dict_table_is_page_compressed(
/*==========================*/
const dict_table_t* table) /*!< in: table */
{
return (dict_tf_get_page_compression(table->flags));
}
/********************************************************************//**
Extract the atomic writes flag from table flags.
@return true if atomic writes are used, false if not used */
UNIV_INLINE
ibool
dict_tf_get_atomic_writes(
/*======================*/
ulint flags) /*!< in: flags */
{
return(DICT_TF_GET_ATOMIC_WRITES(flags));
}
/********************************************************************//**
Check whether the table uses the atomic writes.
@return true if atomic writes is used, false if not */
UNIV_INLINE
ibool
dict_table_get_atomic_writes(
/*=========================*/
const dict_table_t* table) /*!< in: table */
{
return (dict_tf_get_atomic_writes(table->flags));
}
/*****************************************************************************
Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 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
......@@ -128,6 +129,12 @@ extern fil_addr_t fil_addr_null;
#define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID 34 /*!< starting from 4.1.x this
contains the space id of the page */
#define FIL_PAGE_DATA 38 /*!< start of the data on the page */
/* Following are used when page compression is used */
#define FIL_PAGE_COMPRESSED_SIZE 2 /*!< Number of bytes used to store
actual payload data size on
compressed pages. */
#define FIL_PAGE_COMPRESSION_ZLIB 1 /*!< Compressin algorithm ZLIB. */
/* @} */
/** File page trailer @{ */
#define FIL_PAGE_END_LSN_OLD_CHKSUM 8 /*!< the low 4 bytes of this are used
......@@ -140,6 +147,7 @@ extern fil_addr_t fil_addr_null;
#ifndef UNIV_INNOCHECKSUM
/** File page types (values of FIL_PAGE_TYPE) @{ */
#define FIL_PAGE_PAGE_COMPRESSED 34354 /*!< page compressed page */
#define FIL_PAGE_INDEX 17855 /*!< B-tree node */
#define FIL_PAGE_UNDO_LOG 2 /*!< Undo log page */
#define FIL_PAGE_INODE 3 /*!< Index node */
......@@ -202,6 +210,7 @@ ulint
fil_space_get_type(
/*===============*/
ulint id); /*!< in: space id */
#endif /* !UNIV_HOTBACKUP */
/*******************************************************************//**
Appends a new file to the chain of files of a space. File must be closed.
......@@ -742,8 +751,13 @@ fil_io(
void* buf, /*!< in/out: buffer where to store read data
or from where to write; in aio this must be
appropriately aligned */
void* message) /*!< in: message for aio handler if non-sync
void* message, /*!< in: message for aio handler if non-sync
aio used, else ignored */
ulint write_size) /*!< in/out: Actual write size initialized
after fist successfull trim
operation for this page and if
initialized we do not trim again if
actual page size does not decrease. */
__attribute__((nonnull(8)));
/**********************************************************************//**
Waits for an aio operation to complete. This function is used to write the
......@@ -977,8 +991,33 @@ fil_mtr_rename_log(
ulint new_space_id, /*!< in: tablespace id of the new
table */
const char* new_name, /*!< in: new table name */
const char* tmp_name); /*!< in: temp table name used while
const char* tmp_name) /*!< in: temp table name used while
swapping */
__attribute__((nonnull));
#endif /* !UNIV_INNOCHECKSUM */
/****************************************************************//**
Acquire fil_system mutex */
void
fil_system_enter(void);
/*==================*/
/****************************************************************//**
Release fil_system mutex */
void
fil_system_exit(void);
/*==================*/
/*******************************************************************//**
Returns the table space by a given id, NULL if not found. */
fil_space_t*
fil_space_get_by_id(
/*================*/
ulint id); /*!< in: space id */
/*******************************************************************//**
Return space name */
char*
fil_space_name(
/*===========*/
fil_space_t* space); /*!< in: space */
#endif /* fil0fil_h */
/*****************************************************************************
Copyright (C) 2013 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
*****************************************************************************/
#ifndef fil0pagecompress_h
#define fil0pagecompress_h
#include "fsp0fsp.h"
#include "fsp0pagecompress.h"
/******************************************************************//**
@file include/fil0pagecompress.h
Helper functions for extracting/storing page compression and
atomic writes information to table space.
Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com
***********************************************************************/
/*******************************************************************//**
Returns the page compression level flag of the space, or 0 if the space
is not compressed. The tablespace must be cached in the memory cache.
@return page compression level if page compressed, ULINT_UNDEFINED if space not found */
ulint
fil_space_get_page_compression_level(
/*=================================*/
ulint id); /*!< in: space id */
/*******************************************************************//**
Returns the page compression flag of the space, or false if the space
is not compressed. The tablespace must be cached in the memory cache.
@return true if page compressed, false if not or space not found */
ibool
fil_space_is_page_compressed(
/*=========================*/
ulint id); /*!< in: space id */
/*******************************************************************//**
Returns the atomic writes flag of the space, or false if the space
is not using atomic writes. The tablespace must be cached in the memory cache.
@return true if space using atomic writes, false if not */
ibool
fil_space_get_atomic_writes(
/*=========================*/
ulint id); /*!< in: space id */
/*******************************************************************//**
Find out wheather the page is index page or not
@return true if page type index page, false if not */
ibool
fil_page_is_index_page(
/*===================*/
byte *buf); /*!< in: page */
/****************************************************************//**
Get the name of the compression algorithm used for page
compression.
@return compression algorithm name or "UNKNOWN" if not known*/
const char*
fil_get_compression_alg_name(
/*=========================*/
ulint comp_alg); /*!<in: compression algorithm number */
/****************************************************************//**
For page compressed pages compress the page before actual write
operation.
@return compressed page to be written*/
byte*
fil_compress_page(
/*==============*/
ulint space_id, /*!< in: tablespace id of the
table. */
byte* buf, /*!< in: buffer from which to write; in aio
this must be appropriately aligned */
byte* out_buf, /*!< out: compressed buffer */
ulint len, /*!< in: length of input buffer.*/
ulint* out_len); /*!< out: actual length of compressed page */
/****************************************************************//**
For page compressed pages decompress the page after actual read
operation.
@return uncompressed page */
void
fil_decompress_page(
/*================*/
byte* page_buf, /*!< in: preallocated buffer or NULL */
byte* buf, /*!< out: buffer from which to read; in aio
this must be appropriately aligned */
ulint len); /*!< in: length of output buffer.*/
/****************************************************************//**
Get space id from fil node
@return space id*/
ulint
fil_node_get_space_id(
/*==================*/
fil_node_t* node); /*!< in: Node where to get space id*/
/*******************************************************************//**
Find out wheather the page is page compressed
@return true if page is page compressed*/
ibool
fil_page_is_compressed(
/*===================*/
byte *buf); /*!< in: page */
#endif
/*****************************************************************************
Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 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
......@@ -53,12 +54,21 @@ to the two Barracuda row formats COMPRESSED and DYNAMIC. */
/** Width of the DATA_DIR flag. This flag indicates that the tablespace
is found in a remote location, not the default data directory. */
#define FSP_FLAGS_WIDTH_DATA_DIR 1
/** Number of flag bits used to indicate the page compression and compression level */
#define FSP_FLAGS_WIDTH_PAGE_COMPRESSION 1
#define FSP_FLAGS_WIDTH_PAGE_COMPRESSION_LEVEL 4
/** Number of flag bits used to indicate atomic writes for this tablespace */
#define FSP_FLAGS_WIDTH_ATOMIC_WRITES 1
/** Width of all the currently known tablespace flags */
#define FSP_FLAGS_WIDTH (FSP_FLAGS_WIDTH_POST_ANTELOPE \
+ FSP_FLAGS_WIDTH_ZIP_SSIZE \
+ FSP_FLAGS_WIDTH_ATOMIC_BLOBS \
+ FSP_FLAGS_WIDTH_PAGE_SSIZE \
+ FSP_FLAGS_WIDTH_DATA_DIR)
+ FSP_FLAGS_WIDTH_DATA_DIR \
+ FSP_FLAGS_WIDTH_PAGE_COMPRESSION \
+ FSP_FLAGS_WIDTH_PAGE_COMPRESSION_LEVEL \
+ FSP_FLAGS_WIDTH_ATOMIC_WRITES)
/** A mask of all the known/used bits in tablespace flags */
#define FSP_FLAGS_MASK (~(~0 << FSP_FLAGS_WIDTH))
......@@ -71,9 +81,20 @@ is found in a remote location, not the default data directory. */
/** Zero relative shift position of the ATOMIC_BLOBS field */
#define FSP_FLAGS_POS_ATOMIC_BLOBS (FSP_FLAGS_POS_ZIP_SSIZE \
+ FSP_FLAGS_WIDTH_ZIP_SSIZE)
/** Zero relative shift position of the PAGE_SSIZE field */
#define FSP_FLAGS_POS_PAGE_SSIZE (FSP_FLAGS_POS_ATOMIC_BLOBS \
/** Note that these need to be before the page size to be compatible with
dictionary */
/** Zero relative shift position of the PAGE_COMPRESSION field */
#define FSP_FLAGS_POS_PAGE_COMPRESSION (FSP_FLAGS_POS_ATOMIC_BLOBS \
+ FSP_FLAGS_WIDTH_ATOMIC_BLOBS)
/** Zero relative shift position of the PAGE_COMPRESSION_LEVEL field */
#define FSP_FLAGS_POS_PAGE_COMPRESSION_LEVEL (FSP_FLAGS_POS_PAGE_COMPRESSION \
+ FSP_FLAGS_WIDTH_PAGE_COMPRESSION)
/** Zero relative shift position of the ATOMIC_WRITES field */
#define FSP_FLAGS_POS_ATOMIC_WRITES (FSP_FLAGS_POS_PAGE_COMPRESSION_LEVEL \
+ FSP_FLAGS_WIDTH_PAGE_COMPRESSION_LEVEL)
/** Zero relative shift position of the PAGE_SSIZE field */
#define FSP_FLAGS_POS_PAGE_SSIZE (FSP_FLAGS_POS_ATOMIC_WRITES \
+ FSP_FLAGS_WIDTH_ATOMIC_WRITES)
/** Zero relative shift position of the start of the UNUSED bits */
#define FSP_FLAGS_POS_DATA_DIR (FSP_FLAGS_POS_PAGE_SSIZE \
+ FSP_FLAGS_WIDTH_PAGE_SSIZE)
......@@ -101,6 +122,18 @@ is found in a remote location, not the default data directory. */
#define FSP_FLAGS_MASK_DATA_DIR \
((~(~0 << FSP_FLAGS_WIDTH_DATA_DIR)) \
<< FSP_FLAGS_POS_DATA_DIR)
/** Bit mask of the PAGE_COMPRESSION field */
#define FSP_FLAGS_MASK_PAGE_COMPRESSION \
((~(~0 << FSP_FLAGS_WIDTH_PAGE_COMPRESSION)) \
<< FSP_FLAGS_POS_PAGE_COMPRESSION)
/** Bit mask of the PAGE_COMPRESSION_LEVEL field */
#define FSP_FLAGS_MASK_PAGE_COMPRESSION_LEVEL \
((~(~0 << FSP_FLAGS_WIDTH_PAGE_COMPRESSION_LEVEL)) \
<< FSP_FLAGS_POS_PAGE_COMPRESSION_LEVEL)
/** Bit mask of the ATOMIC_WRITES field */
#define FSP_FLAGS_MASK_ATOMIC_WRITES \
((~(~0 << FSP_FLAGS_WIDTH_ATOMIC_WRITES)) \
<< FSP_FLAGS_POS_ATOMIC_WRITES)
/** Return the value of the POST_ANTELOPE field */
#define FSP_FLAGS_GET_POST_ANTELOPE(flags) \
......@@ -126,11 +159,38 @@ is found in a remote location, not the default data directory. */
#define FSP_FLAGS_GET_UNUSED(flags) \
(flags >> FSP_FLAGS_POS_UNUSED)
/** Return the value of the PAGE_COMPRESSION field */
#define FSP_FLAGS_GET_PAGE_COMPRESSION(flags) \
((flags & FSP_FLAGS_MASK_PAGE_COMPRESSION) \
>> FSP_FLAGS_POS_PAGE_COMPRESSION)
/** Return the value of the PAGE_COMPRESSION_LEVEL field */
#define FSP_FLAGS_GET_PAGE_COMPRESSION_LEVEL(flags) \
((flags & FSP_FLAGS_MASK_PAGE_COMPRESSION_LEVEL) \
>> FSP_FLAGS_POS_PAGE_COMPRESSION_LEVEL)
/** Return the value of the ATOMIC_WRITES field */
#define FSP_FLAGS_GET_ATOMIC_WRITES(flags) \
((flags & FSP_FLAGS_MASK_ATOMIC_WRITES) \
>> FSP_FLAGS_POS_ATOMIC_WRITES)
/** Set a PAGE_SSIZE into the correct bits in a given
tablespace flags. */
#define FSP_FLAGS_SET_PAGE_SSIZE(flags, ssize) \
(flags | (ssize << FSP_FLAGS_POS_PAGE_SSIZE))
/** Set a PAGE_COMPRESSION into the correct bits in a given
tablespace flags. */
#define FSP_FLAGS_SET_PAGE_COMPRESSION(flags, compression) \
(flags | (compression << FSP_FLAGS_POS_PAGE_COMPRESSION))
/** Set a PAGE_COMPRESSION_LEVEL into the correct bits in a given
tablespace flags. */
#define FSP_FLAGS_SET_PAGE_COMPRESSION_LEVEL(flags, level) \
(flags | (level << FSP_FLAGS_POS_PAGE_COMPRESSION_LEVEL))
/** Set a ATOMIC_WRITES into the correct bits in a given
tablespace flags. */
#define FSP_FLAGS_SET_ATOMIC_WRITES(flags, atomics) \
(flags | (atomics << FSP_FLAGS_POS_ATOMIC_WRITES))
/* @} */
/* @defgroup Tablespace Header Constants (moved from fsp0fsp.c) @{ */
......
/*****************************************************************************
Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 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
......@@ -63,6 +64,9 @@ fsp_flags_is_valid(
ulint atomic_blobs = FSP_FLAGS_HAS_ATOMIC_BLOBS(flags);
ulint page_ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags);
ulint unused = FSP_FLAGS_GET_UNUSED(flags);
ulint page_compression = FSP_FLAGS_GET_PAGE_COMPRESSION(flags);
ulint page_compression_level = FSP_FLAGS_GET_PAGE_COMPRESSION_LEVEL(flags);
ulint atomic_writes = FSP_FLAGS_GET_ATOMIC_WRITES(flags);
DBUG_EXECUTE_IF("fsp_flags_is_valid_failure", return(false););
......@@ -104,6 +108,18 @@ fsp_flags_is_valid(
return(false);
}
/* Page compression level requires page compression and atomic blobs
to be set */
if (page_compression_level || page_compression) {
if (!page_compression || !atomic_blobs) {
return(false);
}
}
if (atomic_writes && !atomic_blobs) {
return (false);
}
#if UNIV_FORMAT_MAX != UNIV_FORMAT_B
# error "UNIV_FORMAT_MAX != UNIV_FORMAT_B, Add more validations."
#endif
......@@ -312,3 +328,4 @@ xdes_calc_descriptor_page(
}
#endif /* !UNIV_INNOCHECKSUM */
/*****************************************************************************
Copyright (C) 2013 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
*****************************************************************************/
/******************************************************************//**
@file include/fsp0pagecompress.h
Helper functions for extracting/storing page compression and
atomic writes information to file space.
Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com
***********************************************************************/
#ifndef fsp0pagecompress_h
#define fsp0pagecompress_h
/**********************************************************************//**
Reads the page compression level from the first page of a tablespace.
@return page compression level, or 0 if uncompressed */
UNIV_INTERN
ulint
fsp_header_get_compression_level(
/*=============================*/
const page_t* page); /*!< in: first page of a tablespace */
/********************************************************************//**
Determine if the tablespace is page compressed from dict_table_t::flags.
@return TRUE if page compressed, FALSE if not compressed */
UNIV_INLINE
ibool
fsp_flags_is_page_compressed(
/*=========================*/
ulint flags); /*!< in: tablespace flags */
/********************************************************************//**
Extract the page compression level from tablespace flags.
A tablespace has only one physical page compression level
whether that page is compressed or not.
@return page compression level of the file-per-table tablespace,
or zero if the table is not compressed. */
UNIV_INLINE
ulint
fsp_flags_get_page_compression_level(
/*=================================*/
ulint flags); /*!< in: tablespace flags */
#ifndef UNIV_NONINL
#include "fsp0pagecompress.ic"
#endif
#endif
/*****************************************************************************
Copyright (C) 2013 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
*****************************************************************************/
/******************************************************************//**
@file include/fsp0pagecompress.ic
Implementation for helper functions for extracting/storing page
compression and atomic writes information to file space.
Created 11/12/2013 Jan Lindström jan.lindstrom@skysql.com
***********************************************************************/
/********************************************************************//**
Determine if the tablespace is page compressed from dict_table_t::flags.
@return TRUE if page compressed, FALSE if not page compressed */
UNIV_INLINE
ibool
fsp_flags_is_page_compressed(
/*=========================*/
ulint flags) /*!< in: tablespace flags */
{
return(FSP_FLAGS_GET_PAGE_COMPRESSION(flags));
}
/********************************************************************//**
Determine the tablespace is page compression level from dict_table_t::flags.
@return page compression level or 0 if not compressed*/
UNIV_INLINE
ulint
fsp_flags_get_page_compression_level(
/*=================================*/
ulint flags) /*!< in: tablespace flags */
{
return(FSP_FLAGS_GET_PAGE_COMPRESSION_LEVEL(flags));
}
/********************************************************************//**
Determine the tablespace is using atomic writes from dict_table_t::flags.
@return true if atomic writes is used, false if not */
UNIV_INLINE
ibool
fsp_flags_get_atomic_writes(
/*========================*/
ulint flags) /*!< in: tablespace flags */
{
return(FSP_FLAGS_GET_ATOMIC_WRITES(flags));
}
......@@ -29,6 +29,7 @@ Created May 26, 2009 Vasil Dimov
#include "univ.i"
#include "fil0fil.h" /* for FIL_PAGE_DATA */
#include "ut0byte.h"
/** @name Flags for inserting records in order
If records are inserted in order, there are the following
......
......@@ -2,6 +2,7 @@
Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
Portions of this file contain modifications contributed and copyrighted
by Percona Inc.. Those modifications are
......@@ -150,6 +151,7 @@ enum os_file_create_t {
#define OS_FILE_INSUFFICIENT_RESOURCE 78
#define OS_FILE_AIO_INTERRUPTED 79
#define OS_FILE_OPERATION_ABORTED 80
#define OS_FILE_OPERATION_NOT_SUPPORTED 125
/* @} */
/** Types for aio operations @{ */
......@@ -269,26 +271,26 @@ os_file_write
The wrapper functions have the prefix of "innodb_". */
#ifdef UNIV_PFS_IO
# define os_file_create(key, name, create, purpose, type, success) \
# define os_file_create(key, name, create, purpose, type, success, atomic_writes) \
pfs_os_file_create_func(key, name, create, purpose, type, \
success, __FILE__, __LINE__)
success, atomic_writes, __FILE__, __LINE__)
# define os_file_create_simple(key, name, create, access, success) \
# define os_file_create_simple(key, name, create, access, success, atomic_writes) \
pfs_os_file_create_simple_func(key, name, create, access, \
success, __FILE__, __LINE__)
success, atomic_writes, __FILE__, __LINE__)
# define os_file_create_simple_no_error_handling( \
key, name, create_mode, access, success) \
key, name, create_mode, access, success, atomic_writes) \
pfs_os_file_create_simple_no_error_handling_func( \
key, name, create_mode, access, success, __FILE__, __LINE__)
key, name, create_mode, access, success, atomic_writes, __FILE__, __LINE__)
# define os_file_close(file) \
pfs_os_file_close_func(file, __FILE__, __LINE__)
# define os_aio(type, mode, name, file, buf, offset, \
n, message1, message2) \
n, message1, message2, write_size) \
pfs_os_aio_func(type, mode, name, file, buf, offset, \
n, message1, message2, __FILE__, __LINE__)
n, message1, message2, write_size, __FILE__, __LINE__)
# define os_file_read(file, buf, offset, n) \
pfs_os_file_read_func(file, buf, offset, n, __FILE__, __LINE__)
......@@ -310,22 +312,22 @@ The wrapper functions have the prefix of "innodb_". */
/* If UNIV_PFS_IO is not defined, these I/O APIs point
to original un-instrumented file I/O APIs */
# define os_file_create(key, name, create, purpose, type, success) \
os_file_create_func(name, create, purpose, type, success)
# define os_file_create(key, name, create, purpose, type, success, atomic_writes) \
os_file_create_func(name, create, purpose, type, success, atomic_writes)
# define os_file_create_simple(key, name, create_mode, access, success) \
os_file_create_simple_func(name, create_mode, access, success)
# define os_file_create_simple(key, name, create_mode, access, success, atomic_writes) \
os_file_create_simple_func(name, create_mode, access, success, atomic_writes)
# define os_file_create_simple_no_error_handling( \
key, name, create_mode, access, success) \
key, name, create_mode, access, success, atomic_writes) \
os_file_create_simple_no_error_handling_func( \
name, create_mode, access, success)
name, create_mode, access, success, atomic_writes)
# define os_file_close(file) os_file_close_func(file)
# define os_aio(type, mode, name, file, buf, offset, n, message1, message2) \
# define os_aio(type, mode, name, file, buf, offset, n, message1, message2, write_size) \
os_aio_func(type, mode, name, file, buf, offset, n, \
message1, message2)
message1, message2, write_size)
# define os_file_read(file, buf, offset, n) \
os_file_read_func(file, buf, offset, n)
......@@ -468,7 +470,8 @@ os_file_create_simple_func(
ulint create_mode,/*!< in: create mode */
ulint access_type,/*!< in: OS_FILE_READ_ONLY or
OS_FILE_READ_WRITE */
ibool* success);/*!< out: TRUE if succeed, FALSE if error */
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
ibool atomic_writes); /*!<in TRUE if atomic writes are used */
/****************************************************************//**
NOTE! Use the corresponding macro
os_file_create_simple_no_error_handling(), not directly this function!
......@@ -486,7 +489,8 @@ os_file_create_simple_no_error_handling_func(
OS_FILE_READ_WRITE, or
OS_FILE_READ_ALLOW_DELETE; the last option is
used by a backup program reading the file */
ibool* success)/*!< out: TRUE if succeed, FALSE if error */
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
ibool atomic_writes)/*!<in TRUE if atomic writes are used */
__attribute__((nonnull, warn_unused_result));
/****************************************************************//**
Tries to disable OS caching on an opened file descriptor. */
......@@ -520,7 +524,8 @@ os_file_create_func(
async i/o or unbuffered i/o: look in the
function source code for the exact rules */
ulint type, /*!< in: OS_DATA_FILE or OS_LOG_FILE */
ibool* success)/*!< out: TRUE if succeed, FALSE if error */
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
ibool atomic_writes)/*!<in TRUE if atomic writes are used */
__attribute__((nonnull, warn_unused_result));
/***********************************************************************//**
Deletes a file. The file has to be closed before calling this.
......@@ -585,6 +590,7 @@ pfs_os_file_create_simple_func(
ulint access_type,/*!< in: OS_FILE_READ_ONLY or
OS_FILE_READ_WRITE */
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
ibool atomic_writes,/*!<in TRUE if atomic writes are used */
const char* src_file,/*!< in: file name where func invoked */
ulint src_line)/*!< in: line where the func invoked */
__attribute__((nonnull, warn_unused_result));
......@@ -610,6 +616,7 @@ pfs_os_file_create_simple_no_error_handling_func(
OS_FILE_READ_ALLOW_DELETE; the last option is
used by a backup program reading the file */
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
ibool atomic_writes, /*!<in TRUE if atomic writes are used */
const char* src_file,/*!< in: file name where func invoked */
ulint src_line)/*!< in: line where the func invoked */
__attribute__((nonnull, warn_unused_result));
......@@ -638,6 +645,7 @@ pfs_os_file_create_func(
function source code for the exact rules */
ulint type, /*!< in: OS_DATA_FILE or OS_LOG_FILE */
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
ibool atomic_writes, /*!<in TRUE if atomic writes are used */
const char* src_file,/*!< in: file name where func invoked */
ulint src_line)/*!< in: line where the func invoked */
__attribute__((nonnull, warn_unused_result));
......@@ -716,6 +724,7 @@ pfs_os_aio_func(
(can be used to identify a completed
aio operation); ignored if mode is
OS_AIO_SYNC */
ibool atomic_writes, /*!<in TRUE if atomic writes are used */
const char* src_file,/*!< in: file name where func invoked */
ulint src_line);/*!< in: line where the func invoked */
/*******************************************************************//**
......@@ -1044,10 +1053,16 @@ os_aio_func(
(can be used to identify a completed
aio operation); ignored if mode is
OS_AIO_SYNC */
void* message2);/*!< in: message for the aio handler
void* message2,/*!< in: message for the aio handler
(can be used to identify a completed
aio operation); ignored if mode is
OS_AIO_SYNC */
ulint write_size);/*!< in/out: Actual write size initialized
after fist successfull trim
operation for this page and if
initialized we do not trim again if
actual page size does not decrease. */
/************************************************************************//**
Wakes up all async i/o threads so that they know to exit themselves in
shutdown. */
......
/*****************************************************************************
Copyright (c) 2010, 2011, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 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
......@@ -44,6 +45,7 @@ pfs_os_file_create_simple_func(
ulint access_type,/*!< in: OS_FILE_READ_ONLY or
OS_FILE_READ_WRITE */
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
ibool atomic_writes, /*!<in TRUE if atomic writes are used */
const char* src_file,/*!< in: file name where func invoked */
ulint src_line)/*!< in: line where the func invoked */
{
......@@ -59,7 +61,7 @@ pfs_os_file_create_simple_func(
name, src_file, src_line);
file = os_file_create_simple_func(name, create_mode,
access_type, success);
access_type, success, atomic_writes);
/* Regsiter the returning "file" value with the system */
register_pfs_file_open_end(locker, file);
......@@ -88,6 +90,7 @@ pfs_os_file_create_simple_no_error_handling_func(
OS_FILE_READ_ALLOW_DELETE; the last option is
used by a backup program reading the file */
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
ibool atomic_writes, /*!<in TRUE if atomic writes are used */
const char* src_file,/*!< in: file name where func invoked */
ulint src_line)/*!< in: line where the func invoked */
{
......@@ -103,7 +106,7 @@ pfs_os_file_create_simple_no_error_handling_func(
name, src_file, src_line);
file = os_file_create_simple_no_error_handling_func(
name, create_mode, access_type, success);
name, create_mode, access_type, success, atomic_writes);
register_pfs_file_open_end(locker, file);
......@@ -134,6 +137,7 @@ pfs_os_file_create_func(
function source code for the exact rules */
ulint type, /*!< in: OS_DATA_FILE or OS_LOG_FILE */
ibool* success,/*!< out: TRUE if succeed, FALSE if error */
ibool atomic_writes, /*!<in TRUE if atomic writes are used */
const char* src_file,/*!< in: file name where func invoked */
ulint src_line)/*!< in: line where the func invoked */
{
......@@ -148,7 +152,7 @@ pfs_os_file_create_func(
: PSI_FILE_OPEN),
name, src_file, src_line);
file = os_file_create_func(name, create_mode, purpose, type, success);
file = os_file_create_func(name, create_mode, purpose, type, success, atomic_writes);
register_pfs_file_open_end(locker, file);
......@@ -210,6 +214,7 @@ pfs_os_aio_func(
(can be used to identify a completed
aio operation); ignored if mode is
OS_AIO_SYNC */
ibool atomic_writes, /*!<in TRUE if atomic writes are used */
const char* src_file,/*!< in: file name where func invoked */
ulint src_line)/*!< in: line where the func invoked */
{
......@@ -225,7 +230,7 @@ pfs_os_aio_func(
src_file, src_line);
result = os_aio_func(type, mode, name, file, buf, offset,
n, message1, message2);
n, message1, message2, atomic_writes);
register_pfs_file_io_end(locker, n);
......
......@@ -2,6 +2,7 @@
Copyright (c) 2010, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 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
......@@ -163,6 +164,7 @@ enum monitor_id_t {
MONITOR_OVLD_BUF_POOL_PAGES_FREE,
MONITOR_OVLD_PAGE_CREATED,
MONITOR_OVLD_PAGES_WRITTEN,
MONITOR_OVLD_INDEX_PAGES_WRITTEN,
MONITOR_OVLD_PAGES_READ,
MONITOR_OVLD_BYTE_READ,
MONITOR_OVLD_BYTE_WRITTEN,
......@@ -303,6 +305,14 @@ enum monitor_id_t {
MONITOR_PAGE_DECOMPRESS,
MONITOR_PAD_INCREMENTS,
MONITOR_PAD_DECREMENTS,
/* New monitor variables for page compression */
MONITOR_OVLD_PAGE_COMPRESS_SAVED,
MONITOR_OVLD_PAGE_COMPRESS_TRIM_SECT512,
MONITOR_OVLD_PAGE_COMPRESS_TRIM_SECT4096,
MONITOR_OVLD_PAGES_PAGE_COMPRESSED,
MONITOR_OVLD_PAGE_COMPRESSED_TRIM_OP,
MONITOR_OVLD_PAGE_COMPRESSED_TRIM_OP_SAVED,
MONITOR_OVLD_PAGES_PAGE_DECOMPRESSED,
/* Index related counters */
MONITOR_MODULE_INDEX,
......
......@@ -3,6 +3,7 @@
Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2008, 2009, Google Inc.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
......@@ -102,6 +103,23 @@ struct srv_stats_t {
a disk page */
ulint_ctr_1_t buf_pool_reads;
/** Number of bytes saved by page compression */
ulint_ctr_64_t page_compression_saved;
/** Number of 512Byte TRIM by page compression */
ulint_ctr_64_t page_compression_trim_sect512;
/** Number of 4K TRIM by page compression */
ulint_ctr_64_t page_compression_trim_sect4096;
/* Number of index pages written */
ulint_ctr_64_t index_pages_written;
/* Number of pages compressed with page compression */
ulint_ctr_64_t pages_page_compressed;
/* Number of TRIM operations induced by page compression */
ulint_ctr_64_t page_compressed_trim_op;
/* Number of TRIM operations saved by using actual write size knowledge */
ulint_ctr_64_t page_compressed_trim_op_saved;
/* Number of pages decompressed with page compression */
ulint_ctr_64_t pages_page_decompressed;
/** Number of data read in total (in bytes) */
ulint_ctr_1_t data_read;
......@@ -217,6 +235,29 @@ OS (provided we compiled Innobase with it in), otherwise we will
use simulated aio we build below with threads.
Currently we support native aio on windows and linux */
extern my_bool srv_use_native_aio;
/* Is page compression used */
extern my_bool srv_compress_pages;
/* Is page compression used only for index pages */
extern my_bool srv_page_compress_index_pages;
/* Frequency of trim operations */
extern long srv_trim_pct;
/* Use trim operation */
extern my_bool srv_use_trim;
/* Use posix fallocate */
extern my_bool srv_use_posix_fallocate;
/* Use atomic writes i.e disable doublewrite buffer */
extern my_bool srv_use_atomic_writes;
/* Default zlib compression level */
extern long srv_compress_zlib_level;
#ifdef __WIN__
extern ibool srv_use_native_conditions;
#endif /* __WIN__ */
......@@ -348,11 +389,6 @@ extern ibool srv_use_doublewrite_buf;
extern ulong srv_doublewrite_batch_size;
extern ulong srv_checksum_algorithm;
extern ibool srv_use_atomic_writes;
#ifdef HAVE_POSIX_FALLOCATE
extern ibool srv_use_posix_fallocate;
#endif
extern ulong srv_max_buf_pool_modified_pct;
extern ulong srv_max_purge_lag;
extern ulong srv_max_purge_lag_delay;
......@@ -850,6 +886,24 @@ struct export_var_t{
ulint innodb_purge_view_trx_id_age; /*!< rw_max_trx_id
- purged view's min trx_id */
#endif /* UNIV_DEBUG */
ib_int64_t innodb_page_compression_saved;/*!< Number of bytes saved
by page compression */
ib_int64_t innodb_page_compression_trim_sect512;/*!< Number of 512b TRIM
by page compression */
ib_int64_t innodb_page_compression_trim_sect4096;/*!< Number of 4K byte TRIM
by page compression */
ib_int64_t innodb_index_pages_written; /*!< Number of index pages
written */
ib_int64_t innodb_pages_page_compressed;/*!< Number of pages
compressed by page compression */
ib_int64_t innodb_page_compressed_trim_op;/*!< Number of TRIM operations
induced by page compression */
ib_int64_t innodb_page_compressed_trim_op_saved;/*!< Number of TRIM operations
saved by page compression */
ib_int64_t innodb_pages_page_decompressed;/*!< Number of pages
decompressed by page
compression */
};
/** Thread slot in the thread table. */
......
......@@ -2,6 +2,7 @@
Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Google Inc.
Copyright (c) 2013, SkySQL Ab. All Rights Reserved.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
......@@ -1165,7 +1166,7 @@ log_group_file_header_flush(
(ulint) (dest_offset / UNIV_PAGE_SIZE),
(ulint) (dest_offset % UNIV_PAGE_SIZE),
OS_FILE_LOG_BLOCK_SIZE,
buf, group);
buf, group, 0);
srv_stats.os_log_pending_writes.dec();
}
......@@ -1293,7 +1294,7 @@ loop:
fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->space_id, 0,
(ulint) (next_offset / UNIV_PAGE_SIZE),
(ulint) (next_offset % UNIV_PAGE_SIZE), write_len, buf,
group);
group, 0);
srv_stats.os_log_pending_writes.dec();
......@@ -1859,7 +1860,7 @@ log_group_checkpoint(
write_offset / UNIV_PAGE_SIZE,
write_offset % UNIV_PAGE_SIZE,
OS_FILE_LOG_BLOCK_SIZE,
buf, ((byte*) group + 1));
buf, ((byte*) group + 1), 0);
ut_ad(((ulint) group & 0x1UL) == 0);
}
......@@ -1939,7 +1940,7 @@ log_group_read_checkpoint_info(
fil_io(OS_FILE_READ | OS_FILE_LOG, TRUE, group->space_id, 0,
field / UNIV_PAGE_SIZE, field % UNIV_PAGE_SIZE,
OS_FILE_LOG_BLOCK_SIZE, log_sys->checkpoint_buf, NULL);
OS_FILE_LOG_BLOCK_SIZE, log_sys->checkpoint_buf, NULL, 0);
}
/******************************************************//**
......@@ -2233,7 +2234,7 @@ loop:
fil_io(OS_FILE_READ | OS_FILE_LOG, sync, group->space_id, 0,
(ulint) (source_offset / UNIV_PAGE_SIZE),
(ulint) (source_offset % UNIV_PAGE_SIZE),
len, buf, NULL);
len, buf, NULL, 0);
start_lsn += len;
buf += len;
......@@ -2298,7 +2299,7 @@ log_group_archive_file_header_write(
dest_offset / UNIV_PAGE_SIZE,
dest_offset % UNIV_PAGE_SIZE,
2 * OS_FILE_LOG_BLOCK_SIZE,
buf, &log_archive_io);
buf, &log_archive_io, 0);
}
/******************************************************//**
......@@ -2334,7 +2335,7 @@ log_group_archive_completed_header_write(
dest_offset % UNIV_PAGE_SIZE,
OS_FILE_LOG_BLOCK_SIZE,
buf + LOG_FILE_ARCH_COMPLETED,
&log_archive_io);
&log_archive_io, 0);
}
/******************************************************//**
......@@ -2462,7 +2463,7 @@ loop:
(ulint) (next_offset / UNIV_PAGE_SIZE),
(ulint) (next_offset % UNIV_PAGE_SIZE),
ut_calc_align(len, OS_FILE_LOG_BLOCK_SIZE), buf,
&log_archive_io);
&log_archive_io, 0);
start_lsn += len;
next_offset += len;
......
......@@ -2,6 +2,7 @@
Copyright (c) 1997, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 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
......@@ -2063,7 +2064,7 @@ recv_apply_log_recs_for_backup(void)
error = fil_io(OS_FILE_READ, TRUE,
recv_addr->space, zip_size,
recv_addr->page_no, 0, zip_size,
block->page.zip.data, NULL);
block->page.zip.data, NULL, 0);
if (error == DB_SUCCESS
&& !buf_zip_decompress(block, TRUE)) {
exit(1);
......@@ -2073,7 +2074,7 @@ recv_apply_log_recs_for_backup(void)
recv_addr->space, 0,
recv_addr->page_no, 0,
UNIV_PAGE_SIZE,
block->frame, NULL);
block->frame, NULL, 0);
}
if (error != DB_SUCCESS) {
......@@ -2102,13 +2103,13 @@ recv_apply_log_recs_for_backup(void)
recv_addr->space, zip_size,
recv_addr->page_no, 0,
zip_size,
block->page.zip.data, NULL);
block->page.zip.data, NULL, 0);
} else {
error = fil_io(OS_FILE_WRITE, TRUE,
recv_addr->space, 0,
recv_addr->page_no, 0,
UNIV_PAGE_SIZE,
block->frame, NULL);
block->frame, NULL, 0);
}
skip_this_recv_addr:
recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
......@@ -3074,7 +3075,7 @@ recv_recovery_from_checkpoint_start_func(
fil_io(OS_FILE_READ | OS_FILE_LOG, TRUE, max_cp_group->space_id, 0,
0, 0, LOG_FILE_HDR_SIZE,
log_hdr_buf, max_cp_group);
log_hdr_buf, max_cp_group, 0);
if (0 == ut_memcmp(log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP,
(byte*)"ibbackup", (sizeof "ibbackup") - 1)) {
......@@ -3105,7 +3106,7 @@ recv_recovery_from_checkpoint_start_func(
fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE,
max_cp_group->space_id, 0,
0, 0, OS_FILE_LOG_BLOCK_SIZE,
log_hdr_buf, max_cp_group);
log_hdr_buf, max_cp_group, 0);
}
#ifdef UNIV_LOG_ARCHIVE
......@@ -3753,8 +3754,8 @@ ask_again:
#endif
/* Read the archive file header */
fil_io(OS_FILE_READ | OS_FILE_LOG, TRUE, group->archive_space_id, 0, 0,
LOG_FILE_HDR_SIZE, buf, NULL);
fil_io(OS_FILE_READ | OS_FILE_LOG, true, group->archive_space_id, 0, 0,
LOG_FILE_HDR_SIZE, buf, NULL, 0);
/* Check if the archive file header is consistent */
......@@ -3827,7 +3828,7 @@ ask_again:
fil_io(OS_FILE_READ | OS_FILE_LOG, TRUE,
group->archive_space_id, read_offset / UNIV_PAGE_SIZE,
read_offset % UNIV_PAGE_SIZE, len, buf, NULL);
read_offset % UNIV_PAGE_SIZE, len, buf, NULL, 0);
ret = recv_scan_log_recs(
(buf_pool_get_n_pages()
......
This diff is collapsed.
......@@ -290,6 +290,12 @@ static monitor_info_t innodb_counter_info[] =
MONITOR_EXISTING | MONITOR_DEFAULT_ON),
MONITOR_DEFAULT_START, MONITOR_OVLD_PAGES_WRITTEN},
{"buffer_index_pages_written", "buffer",
"Number of index pages written (innodb_index_pages_written)",
static_cast<monitor_type_t>(
MONITOR_EXISTING | MONITOR_DEFAULT_ON),
MONITOR_DEFAULT_START, MONITOR_OVLD_INDEX_PAGES_WRITTEN},
{"buffer_pages_read", "buffer",
"Number of pages read (innodb_pages_read)",
static_cast<monitor_type_t>(
......@@ -875,6 +881,41 @@ static monitor_info_t innodb_counter_info[] =
MONITOR_NONE,
MONITOR_DEFAULT_START, MONITOR_PAD_DECREMENTS},
{"compress_saved", "compression",
"Number of bytes saved by page compression",
MONITOR_NONE,
MONITOR_DEFAULT_START, MONITOR_OVLD_PAGE_COMPRESS_SAVED},
{"compress_trim_sect512", "compression",
"Number of sect-512 TRIMed by page compression",
MONITOR_NONE,
MONITOR_DEFAULT_START, MONITOR_OVLD_PAGE_COMPRESS_TRIM_SECT512},
{"compress_trim_sect4096", "compression",
"Number of sect-4K TRIMed by page compression",
MONITOR_NONE,
MONITOR_DEFAULT_START, MONITOR_OVLD_PAGE_COMPRESS_TRIM_SECT4096},
{"compress_pages_page_compressed", "compression",
"Number of pages compressed by page compression",
MONITOR_NONE,
MONITOR_DEFAULT_START, MONITOR_OVLD_PAGES_PAGE_COMPRESSED},
{"compress_page_compressed_trim_op", "compression",
"Number of TRIM operation performed by page compression",
MONITOR_NONE,
MONITOR_DEFAULT_START, MONITOR_OVLD_PAGE_COMPRESSED_TRIM_OP},
{"compress_page_compressed_trim_op_saved", "compression",
"Number of TRIM operation saved by page compression",
MONITOR_NONE,
MONITOR_DEFAULT_START, MONITOR_OVLD_PAGE_COMPRESSED_TRIM_OP_SAVED},
{"compress_pages_page_decompressed", "compression",
"Number of pages decompressed by page compression",
MONITOR_NONE,
MONITOR_DEFAULT_START, MONITOR_OVLD_PAGES_PAGE_DECOMPRESSED},
/* ========== Counters for Index ========== */
{"module_index", "index", "Index Manager",
MONITOR_MODULE,
......@@ -1528,6 +1569,11 @@ srv_mon_process_existing_counter(
value = stat.n_pages_written;
break;
/* innodb_index_pages_written, the number of page written */
case MONITOR_OVLD_INDEX_PAGES_WRITTEN:
value = srv_stats.index_pages_written;
break;
/* innodb_pages_read */
case MONITOR_OVLD_PAGES_READ:
buf_get_total_stat(&stat);
......@@ -1769,6 +1815,28 @@ srv_mon_process_existing_counter(
value = btr_cur_n_non_sea;
break;
case MONITOR_OVLD_PAGE_COMPRESS_SAVED:
value = srv_stats.page_compression_saved;
break;
case MONITOR_OVLD_PAGE_COMPRESS_TRIM_SECT512:
value = srv_stats.page_compression_trim_sect512;
break;
case MONITOR_OVLD_PAGE_COMPRESS_TRIM_SECT4096:
value = srv_stats.page_compression_trim_sect4096;
break;
case MONITOR_OVLD_PAGES_PAGE_COMPRESSED:
value = srv_stats.pages_page_compressed;
break;
case MONITOR_OVLD_PAGE_COMPRESSED_TRIM_OP:
value = srv_stats.page_compressed_trim_op;
break;
case MONITOR_OVLD_PAGE_COMPRESSED_TRIM_OP_SAVED:
value = srv_stats.page_compressed_trim_op_saved;
break;
case MONITOR_OVLD_PAGES_PAGE_DECOMPRESSED:
value = srv_stats.pages_page_decompressed;
break;
default:
ut_error;
}
......
......@@ -145,6 +145,24 @@ use simulated aio we build below with threads.
Currently we support native aio on windows and linux */
UNIV_INTERN my_bool srv_use_native_aio = TRUE;
/* If this flag is TRUE, then we will use page compression
to the pages */
UNIV_INTERN my_bool srv_compress_pages = FALSE;
/* If this flag is TRUE, then we will use page compression
only for index pages */
UNIV_INTERN my_bool srv_page_compress_index_pages = FALSE;
UNIV_INTERN long srv_trim_pct = 100;
/* Default compression level if page compression is used and no compression
level is set for the table*/
UNIV_INTERN long srv_compress_zlib_level = 6;
/* If this flag is TRUE, then we will use fallocate(PUCH_HOLE)
to the pages */
UNIV_INTERN my_bool srv_use_trim = TRUE;
/* If this flag is TRUE, then we will use posix fallocate for file extentsion */
UNIV_INTERN my_bool srv_use_posix_fallocate = FALSE;
/* If this flag is TRUE, then we disable doublewrite buffer */
UNIV_INTERN my_bool srv_use_atomic_writes = FALSE;
#ifdef __WIN__
/* Windows native condition variables. We use runtime loading / function
pointers, because they are not available on Windows Server 2003 and
......@@ -347,11 +365,6 @@ batch flushing i.e.: LRU flushing and flush_list flushing. The rest
of the pages are used for single page flushing. */
UNIV_INTERN ulong srv_doublewrite_batch_size = 120;
UNIV_INTERN ibool srv_use_atomic_writes = FALSE;
#ifdef HAVE_POSIX_FALLOCATE
UNIV_INTERN ibool srv_use_posix_fallocate = TRUE;
#endif
UNIV_INTERN ulong srv_replication_delay = 0;
/*-------------------------------------------*/
......@@ -375,6 +388,16 @@ static ulint srv_n_rows_read_old = 0;
UNIV_INTERN ulint srv_truncated_status_writes = 0;
UNIV_INTERN ulint srv_available_undo_logs = 0;
UNIV_INTERN ib_uint64_t srv_page_compression_saved = 0;
UNIV_INTERN ib_uint64_t srv_page_compression_trim_sect512 = 0;
UNIV_INTERN ib_uint64_t srv_page_compression_trim_sect4096 = 0;
UNIV_INTERN ib_uint64_t srv_index_pages_written = 0;
UNIV_INTERN ib_uint64_t srv_pages_page_compressed = 0;
UNIV_INTERN ib_uint64_t srv_page_compressed_trim_op = 0;
UNIV_INTERN ib_uint64_t srv_page_compressed_trim_op_saved = 0;
UNIV_INTERN ib_uint64_t srv_index_page_decompressed = 0;
/* Set the following to 0 if you want InnoDB to write messages on
stderr on startup/shutdown. */
UNIV_INTERN ibool srv_print_verbose_log = TRUE;
......@@ -1457,6 +1480,14 @@ srv_export_innodb_status(void)
srv_truncated_status_writes;
export_vars.innodb_available_undo_logs = srv_available_undo_logs;
export_vars.innodb_page_compression_saved = srv_stats.page_compression_saved;
export_vars.innodb_page_compression_trim_sect512 = srv_stats.page_compression_trim_sect512;
export_vars.innodb_page_compression_trim_sect4096 = srv_stats.page_compression_trim_sect4096;
export_vars.innodb_index_pages_written = srv_stats.index_pages_written;
export_vars.innodb_pages_page_compressed = srv_stats.pages_page_compressed;
export_vars.innodb_page_compressed_trim_op = srv_stats.page_compressed_trim_op;
export_vars.innodb_page_compressed_trim_op_saved = srv_stats.page_compressed_trim_op_saved;
export_vars.innodb_pages_page_decompressed = srv_stats.pages_page_decompressed;
#ifdef UNIV_DEBUG
if (purge_sys->done.trx_no == 0
......
This diff is collapsed.
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