summaryrefslogtreecommitdiff
path: root/storage/innobase/include/fil0crypt.h
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/include/fil0crypt.h')
-rw-r--r--storage/innobase/include/fil0crypt.h115
1 files changed, 29 insertions, 86 deletions
diff --git a/storage/innobase/include/fil0crypt.h b/storage/innobase/include/fil0crypt.h
index 62043003a6c..26272761f43 100644
--- a/storage/innobase/include/fil0crypt.h
+++ b/storage/innobase/include/fil0crypt.h
@@ -1,6 +1,6 @@
/*****************************************************************************
Copyright (C) 2013, 2015, Google Inc. All Rights Reserved.
-Copyright (c) 2015, 2020, MariaDB Corporation.
+Copyright (c) 2015, 2021, MariaDB Corporation.
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
@@ -26,7 +26,6 @@ Created 04/01/2015 Jan Lindström
#ifndef fil0crypt_h
#define fil0crypt_h
-#include "os0event.h"
#include "my_crypt.h"
#include "fil0fil.h"
@@ -41,7 +40,8 @@ static const unsigned char CRYPT_MAGIC[MAGIC_SZ] = {
/* This key will be used if nothing else is given */
#define FIL_DEFAULT_ENCRYPTION_KEY ENCRYPTION_KEY_SYSTEM_DATA
-extern os_event_t fil_crypt_threads_event;
+/** Wake up the encryption threads */
+void fil_crypt_threads_signal(bool broadcast= false);
/**
* CRYPT_SCHEME_UNENCRYPTED
@@ -116,7 +116,7 @@ struct fil_space_crypt_t : st_encryption_scheme
{
key_id = new_key_id;
my_random_bytes(iv, sizeof(iv));
- mutex_create(LATCH_ID_FIL_CRYPT_DATA_MUTEX, &mutex);
+ mysql_mutex_init(0, &mutex, nullptr);
locker = crypt_data_scheme_locker;
type = new_type;
@@ -135,7 +135,7 @@ struct fil_space_crypt_t : st_encryption_scheme
/** Destructor */
~fil_space_crypt_t()
{
- mutex_free(&mutex);
+ mysql_mutex_destroy(&mutex);
}
/** Get latest key version from encryption plugin
@@ -172,12 +172,6 @@ struct fil_space_crypt_t : st_encryption_scheme
return (encryption == FIL_ENCRYPTION_OFF);
}
- /** Fill crypt data information to the give page.
- It should be called during ibd file creation.
- @param[in] flags tablespace flags
- @param[in,out] page first page of the tablespace */
- void fill_page0(ulint flags, byte* page);
-
/** Write encryption metadata to the first page.
@param[in,out] block first page of the tablespace
@param[in,out] mtr mini-transaction */
@@ -186,7 +180,7 @@ struct fil_space_crypt_t : st_encryption_scheme
uint min_key_version; // min key version for this space
fil_encryption_t encryption; // Encryption setup
- ib_mutex_t mutex; // mutex protecting following variables
+ mysql_mutex_t mutex; // mutex protecting following variables
/** Return code from encryption_key_get_latest_version.
If ENCRYPTION_KEY_VERSION_INVALID encryption plugin
@@ -213,25 +207,20 @@ struct fil_space_crypt_status_t {
};
/** Statistics about encryption key rotation */
-struct fil_crypt_stat_t {
- ulint pages_read_from_cache;
- ulint pages_read_from_disk;
- ulint pages_modified;
- ulint pages_flushed;
- ulint estimated_iops;
+struct fil_crypt_stat_t
+{
+ ulint pages_read_from_cache= 0;
+ ulint pages_read_from_disk= 0;
+ ulint pages_modified= 0;
+ ulint pages_flushed= 0;
+ ulint estimated_iops= 0;
};
-/*********************************************************************
-Init space crypt */
-UNIV_INTERN
-void
-fil_space_crypt_init();
+/** Init space crypt */
+void fil_space_crypt_init();
-/*********************************************************************
-Cleanup space crypt */
-UNIV_INTERN
-void
-fil_space_crypt_cleanup();
+/** Cleanup space crypt */
+void fil_space_crypt_cleanup();
/**
Create a fil_space_crypt_t object
@@ -241,23 +230,12 @@ Create a fil_space_crypt_t object
@param[in] key_id Encryption key id
@return crypt object */
-UNIV_INTERN
fil_space_crypt_t*
fil_space_create_crypt_data(
fil_encryption_t encrypt_mode,
uint key_id)
MY_ATTRIBUTE((warn_unused_result));
-/******************************************************************
-Merge fil_space_crypt_t object
-@param[in,out] dst Destination cryp data
-@param[in] src Source crypt data */
-UNIV_INTERN
-void
-fil_space_merge_crypt_data(
- fil_space_crypt_t* dst,
- const fil_space_crypt_t* src);
-
/** Initialize encryption parameters from a tablespace header page.
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] page first page of the tablespace
@@ -269,10 +247,7 @@ fil_space_crypt_t* fil_space_read_crypt_data(ulint zip_size, const byte* page)
/**
Free a crypt data object
@param[in,out] crypt_data crypt data to be freed */
-UNIV_INTERN
-void
-fil_space_destroy_crypt_data(
- fil_space_crypt_t **crypt_data);
+void fil_space_destroy_crypt_data(fil_space_crypt_t **crypt_data);
/** Amend encryption information from redo log.
@param[in] space tablespace
@@ -288,7 +263,6 @@ void fil_crypt_parse(fil_space_t* space, const byte* data);
@param[in,out] dst_frame Output buffer
@param[in] use_full_checksum full crc32 algo is used
@return encrypted buffer or NULL */
-UNIV_INTERN
byte*
fil_encrypt_buf(
fil_space_crypt_t* crypt_data,
@@ -315,7 +289,6 @@ byte* fil_space_encrypt(
byte* dst_frame)
MY_ATTRIBUTE((warn_unused_result));
-
/** Decrypt a page.
@param]in] space_id space id
@param[in] crypt_data crypt_data
@@ -323,8 +296,8 @@ byte* fil_space_encrypt(
@param[in] physical_size page size
@param[in] fsp_flags Tablespace flags
@param[in,out] src_frame Page to decrypt
-@return DB_SUCCESS or error */
-UNIV_INTERN
+@retval DB_SUCCESS on success
+@retval DB_DECRYPTION_FAILED on error */
dberr_t
fil_space_decrypt(
ulint space_id,
@@ -340,8 +313,8 @@ Decrypt a page
@param[in] tmp_frame Temporary buffer used for decrypting
@param[in,out] src_frame Page to decrypt
@return decrypted page, or original not encrypted page if decryption is
-not needed.*/
-UNIV_INTERN
+not needed.
+@retval nullptr on failure */
byte*
fil_space_decrypt(
const fil_space_t* space,
@@ -349,39 +322,20 @@ fil_space_decrypt(
byte* src_frame)
MY_ATTRIBUTE((warn_unused_result));
-/**
-Calculate post encryption checksum
-@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
-@param[in] dst_frame Block where checksum is calculated
-@return page checksum
-not needed. */
-uint32_t
-fil_crypt_calculate_checksum(ulint zip_size, const byte* dst_frame)
- MY_ATTRIBUTE((warn_unused_result));
-
/*********************************************************************
Adjust thread count for key rotation
@param[in] enw_cnt Number of threads to be used */
-UNIV_INTERN
-void
-fil_crypt_set_thread_cnt(
- uint new_cnt);
+void fil_crypt_set_thread_cnt(const uint new_cnt);
/*********************************************************************
Adjust max key age
@param[in] val New max key age */
-UNIV_INTERN
-void
-fil_crypt_set_rotate_key_age(
- uint val);
+void fil_crypt_set_rotate_key_age(uint val);
/*********************************************************************
Adjust rotation iops
@param[in] val New max roation iops */
-UNIV_INTERN
-void
-fil_crypt_set_rotation_iops(
- uint val);
+void fil_crypt_set_rotation_iops(uint val);
/*********************************************************************
Adjust encrypt tables
@@ -390,30 +344,22 @@ void fil_crypt_set_encrypt_tables(ulong val);
/*********************************************************************
Init threads for key rotation */
-UNIV_INTERN
-void
-fil_crypt_threads_init();
+void fil_crypt_threads_init();
/*********************************************************************
Clean up key rotation threads resources */
-UNIV_INTERN
-void
-fil_crypt_threads_cleanup();
+void fil_crypt_threads_cleanup();
/*********************************************************************
Wait for crypt threads to stop accessing space
@param[in] space Tablespace */
-UNIV_INTERN
-void
-fil_space_crypt_close_tablespace(
- const fil_space_t* space);
+void fil_space_crypt_close_tablespace(const fil_space_t *space);
/*********************************************************************
Get crypt status for a space (used by information_schema)
@param[in] space Tablespace
@param[out] status Crypt status
return 0 if crypt data present */
-UNIV_INTERN
void
fil_space_crypt_get_status(
const fil_space_t* space,
@@ -422,10 +368,7 @@ fil_space_crypt_get_status(
/*********************************************************************
Return crypt statistics
@param[out] stat Crypt statistics */
-UNIV_INTERN
-void
-fil_crypt_total_stat(
- fil_crypt_stat_t *stat);
+void fil_crypt_total_stat(fil_crypt_stat_t *stat);
#include "fil0crypt.inl"
#endif /* !UNIV_INNOCHECKSUM */