summaryrefslogtreecommitdiff
path: root/storage/innobase/include
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-12-29 13:23:18 +0100
committerSergei Golubchik <serg@mariadb.org>2016-12-29 13:23:18 +0100
commit4a5d25c338a5d1d2cc16343380193d6bf25ae6ae (patch)
tree73b84a9c8f3d5e3e3383fa79465b11f9ded512d3 /storage/innobase/include
parent48dc7cc66ef5b69fcf28ec0b2ecf0338c188cf4e (diff)
parentc13b5011629b5ff7b969d648265002e4d1ba94c2 (diff)
downloadmariadb-git-4a5d25c338a5d1d2cc16343380193d6bf25ae6ae.tar.gz
Merge branch '10.1' into 10.2
Diffstat (limited to 'storage/innobase/include')
-rw-r--r--storage/innobase/include/btr0btr.h13
-rw-r--r--storage/innobase/include/btr0btr.ic35
-rw-r--r--storage/innobase/include/dict0mem.h2
-rw-r--r--storage/innobase/include/fil0crypt.h112
-rw-r--r--storage/innobase/include/fil0fil.h6
-rw-r--r--storage/innobase/include/fil0pagecompress.h1
-rw-r--r--storage/innobase/include/srv0mon.h1
-rw-r--r--storage/innobase/include/srv0srv.h10
8 files changed, 171 insertions, 9 deletions
diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h
index c177f23824f..48c5eb42724 100644
--- a/storage/innobase/include/btr0btr.h
+++ b/storage/innobase/include/btr0btr.h
@@ -242,9 +242,16 @@ btr_block_get_func(
@param index index tree, may be NULL if not the insert buffer tree
@param mtr mini-transaction handle
@return the uncompressed page frame */
-# define btr_page_get(page_id, page_size, mode, index, mtr) \
- buf_block_get_frame(btr_block_get(page_id, page_size, \
- mode, index, mtr))
+UNIV_INLINE
+page_t*
+btr_page_get(
+/*=========*/
+ const page_id_t& page_id,
+ const page_size_t& page_size,
+ ulint mode,
+ dict_index_t* index,
+ mtr_t* mtr)
+ MY_ATTRIBUTE((warn_unused_result));
#endif /* !UNIV_HOTBACKUP */
/**************************************************************//**
Gets the index id field of a page.
diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic
index 58a0c6755b1..d01e19b5202 100644
--- a/storage/innobase/include/btr0btr.ic
+++ b/storage/innobase/include/btr0btr.ic
@@ -63,7 +63,9 @@ btr_block_get_func(
page_id, page_size, mode, NULL, BUF_GET, file, line, mtr, &err);
if (err == DB_DECRYPTION_FAILED) {
- index->table->is_encrypted = true;
+ if (index && index->table) {
+ index->table->is_encrypted = true;
+ }
}
if (block) {
@@ -99,6 +101,37 @@ btr_page_set_index_id(
mlog_write_ull(page + (PAGE_HEADER + PAGE_INDEX_ID), id, mtr);
}
}
+
+/** Gets a buffer page and declares its latching order level.
+@param space tablespace identifier
+@param zip_size compressed page size in bytes or 0 for uncompressed pages
+@param page_no page number
+@param mode latch mode
+@param idx index tree, may be NULL if not the insert buffer tree
+@param mtr mini-transaction handle
+@return the uncompressed page frame */
+UNIV_INLINE
+page_t*
+btr_page_get(
+/*=========*/
+ const page_id_t& page_id,
+ const page_size_t& page_size,
+ ulint mode,
+ dict_index_t* index,
+ mtr_t* mtr)
+{
+ buf_block_t* block=NULL;
+ buf_frame_t* frame=NULL;
+
+ block = btr_block_get(page_id, page_size, mode, index, mtr);
+
+ if (block) {
+ frame = buf_block_get_frame(block);
+ }
+
+ return ((page_t*)frame);
+}
+
#endif /* !UNIV_HOTBACKUP */
/**************************************************************//**
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index c81d893ed5a..8cefdddad65 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -1372,6 +1372,8 @@ struct dict_table_t {
inline void acquire();
void* thd; /*!< thd */
+ bool page_0_read; /*!< true if page 0 has
+ been already read */
fil_space_crypt_t *crypt_data; /*!< crypt data if present */
/** Release the table handle. */
diff --git a/storage/innobase/include/fil0crypt.h b/storage/innobase/include/fil0crypt.h
index acac155ef3f..eb6eaa229b5 100644
--- a/storage/innobase/include/fil0crypt.h
+++ b/storage/innobase/include/fil0crypt.h
@@ -75,6 +75,17 @@ struct key_struct
(that is L in CRYPT_SCHEME_1) */
};
+/** is encryption enabled */
+extern ulong srv_encrypt_tables;
+
+/** Mutex helper for crypt_data->scheme
+@param[in, out] schme encryption scheme
+@param[in] exit should we exit or enter mutex ? */
+void
+crypt_data_scheme_locker(
+ st_encryption_scheme* scheme,
+ int exit);
+
struct fil_space_rotate_state_t
{
time_t start_time; /*!< time when rotation started */
@@ -96,13 +107,109 @@ struct fil_space_rotate_state_t
struct fil_space_crypt_struct : st_encryption_scheme
{
+ public:
+ /** Constructor. Does not initialize the members!
+ The object is expected to be placed in a buffer that
+ has been zero-initialized. */
+ fil_space_crypt_struct(
+ ulint new_type,
+ uint new_min_key_version,
+ uint new_key_id,
+ ulint offset,
+ fil_encryption_t new_encryption)
+ : st_encryption_scheme(),
+ min_key_version(new_min_key_version),
+ page0_offset(offset),
+ encryption(new_encryption),
+ closing(false),
+ key_found(),
+ rotate_state()
+ {
+ key_found = new_min_key_version;
+ key_id = new_key_id;
+ my_random_bytes(iv, sizeof(iv));
+ mutex_create(LATCH_ID_FIL_CRYPT_DATA_MUTEX, &mutex);
+ locker = crypt_data_scheme_locker;
+ type = new_type;
+
+ if (new_encryption == FIL_SPACE_ENCRYPTION_OFF ||
+ (!srv_encrypt_tables &&
+ new_encryption == FIL_SPACE_ENCRYPTION_DEFAULT)) {
+ type = CRYPT_SCHEME_UNENCRYPTED;
+ } else {
+ type = CRYPT_SCHEME_1;
+ min_key_version = key_get_latest_version();
+ }
+ }
+
+ /** Destructor */
+ ~fil_space_crypt_struct()
+ {
+ closing = true;
+ mutex_free(&mutex);
+ }
+
+ /** Get latest key version from encryption plugin
+ @retval key_version or
+ @retval ENCRYPTION_KEY_VERSION_INVALID if used key_id
+ is not found from encryption plugin. */
+ uint key_get_latest_version(void);
+
+ /** Returns true if key was found from encryption plugin
+ and false if not. */
+ bool is_key_found() const {
+ return key_found != ENCRYPTION_KEY_VERSION_INVALID;
+ }
+
+ /** Returns true if tablespace should be encrypted */
+ bool should_encrypt() const {
+ return ((encryption == FIL_SPACE_ENCRYPTION_ON) ||
+ (srv_encrypt_tables &&
+ encryption == FIL_SPACE_ENCRYPTION_DEFAULT));
+ }
+
+ /** Return true if tablespace is encrypted. */
+ bool is_encrypted() const {
+ return (encryption != FIL_SPACE_ENCRYPTION_OFF);
+ }
+
+ /** Return true if default tablespace encryption is used, */
+ bool is_default_encryption() const {
+ return (encryption == FIL_SPACE_ENCRYPTION_DEFAULT);
+ }
+
+ /** Return true if tablespace is not encrypted. */
+ bool not_encrypted() const {
+ return (encryption == FIL_SPACE_ENCRYPTION_OFF);
+ }
+
+ /** Is this tablespace closing. */
+ bool is_closing(bool is_fixed) {
+ bool closed;
+ if (!is_fixed) {
+ mutex_enter(&mutex);
+ }
+ closed = closing;
+ if (!is_fixed) {
+ mutex_exit(&mutex);
+ }
+ return closed;
+ }
+
uint min_key_version; // min key version for this space
ulint page0_offset; // byte offset on page 0 for crypt data
fil_encryption_t encryption; // Encryption setup
ib_mutex_t mutex; // mutex protecting following variables
bool closing; // is tablespace being closed
- bool inited;
+
+ /** Return code from encryption_key_get_latest_version.
+ If ENCRYPTION_KEY_VERSION_INVALID encryption plugin
+ could not find the key and there is no need to call
+ get_latest_key_version again as keys are read only
+ at startup. */
+ uint key_found;
+
fil_space_rotate_state_t rotate_state;
};
@@ -321,7 +428,8 @@ UNIV_INTERN
void
fil_space_crypt_mark_space_closing(
/*===============================*/
- ulint space); /*!< in: tablespace id */
+ ulint space, /*!< in: tablespace id */
+ fil_space_crypt_t* crypt_data); /*!< in: crypt_data or NULL */
/*********************************************************************
Wait for crypt threads to stop accessing space */
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index bd31ed58283..65f73448c6e 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -235,6 +235,9 @@ struct fil_space_t {
/** MariaDB encryption data */
fil_space_crypt_t* crypt_data;
+ /** tablespace crypt data has been read */
+ bool page_0_crypt_read;
+
/** Space file block size */
ulint file_block_size;
@@ -751,7 +754,8 @@ fil_space_create(
ulint id,
ulint flags,
fil_type_t purpose, /*!< in: FIL_TABLESPACE, or FIL_LOG if log */
- fil_space_crypt_t* crypt_data) /*!< in: crypt data */
+ fil_space_crypt_t* crypt_data, /*!< in: crypt data */
+ bool create_table) /*!< in: true if create table */
MY_ATTRIBUTE((warn_unused_result));
/*******************************************************************//**
diff --git a/storage/innobase/include/fil0pagecompress.h b/storage/innobase/include/fil0pagecompress.h
index 2948207133b..d4cc54c7b2a 100644
--- a/storage/innobase/include/fil0pagecompress.h
+++ b/storage/innobase/include/fil0pagecompress.h
@@ -124,5 +124,4 @@ fil_node_get_block_size(
/*====================*/
fil_node_t* node); /*!< in: Node where to get block
size */
-
#endif
diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h
index 125401373ba..d5a305bdf68 100644
--- a/storage/innobase/include/srv0mon.h
+++ b/storage/innobase/include/srv0mon.h
@@ -180,6 +180,7 @@ enum monitor_id_t {
MONITOR_OVLD_INDEX_PAGES_WRITTEN,
MONITOR_OVLD_NON_INDEX_PAGES_WRITTEN,
MONITOR_OVLD_PAGES_READ,
+ MONITOR_OVLD_PAGES0_READ,
MONITOR_OVLD_INDEX_SEC_REC_CLUSTER_READS,
MONITOR_OVLD_INDEX_SEC_REC_CLUSTER_READS_AVOIDED,
MONITOR_OVLD_BYTE_READ,
diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
index 4f9bee7019f..056a6267347 100644
--- a/storage/innobase/include/srv0srv.h
+++ b/storage/innobase/include/srv0srv.h
@@ -189,6 +189,12 @@ struct srv_stats_t {
/** Number of times prefix optimization avoided triggering cluster lookup */
ulint_ctr_64_t n_sec_rec_cluster_reads_avoided;
+
+ /** Number of times page 0 is read from tablespace */
+ ulint_ctr_64_t page0_read;
+
+ /** Number of encryption_get_latest_key_version calls */
+ ulint_ctr_64_t n_key_requests;
};
extern const char* srv_main_thread_op_info;
@@ -1028,7 +1034,8 @@ struct export_var_t{
ulint innodb_os_log_pending_fsyncs; /*!< fil_n_pending_log_flushes */
ulint innodb_page_size; /*!< UNIV_PAGE_SIZE */
ulint innodb_pages_created; /*!< buf_pool->stat.n_pages_created */
- ulint innodb_pages_read; /*!< buf_pool->stat.n_pages_read */
+ ulint innodb_pages_read; /*!< buf_pool->stat.n_pages_read*/
+ ulint innodb_page0_read; /*!< srv_stats.page0_read */
ulint innodb_pages_written; /*!< buf_pool->stat.n_pages_written */
ulint innodb_row_lock_waits; /*!< srv_n_lock_wait_count */
ulint innodb_row_lock_current_waits; /*!< srv_n_lock_wait_current_count */
@@ -1118,6 +1125,7 @@ struct export_var_t{
ulint innodb_encryption_rotation_pages_modified;
ulint innodb_encryption_rotation_pages_flushed;
ulint innodb_encryption_rotation_estimated_iops;
+ int64_t innodb_encryption_key_requests;
ulint innodb_scrub_page_reorganizations;
ulint innodb_scrub_page_splits;