diff options
Diffstat (limited to 'storage/innobase/include/fil0fil.h')
-rw-r--r-- | storage/innobase/include/fil0fil.h | 139 |
1 files changed, 78 insertions, 61 deletions
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 66d79bd24b5..abd9ff9a9ed 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2013, 2017, 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 @@ -28,6 +28,8 @@ Created 10/25/1995 Heikki Tuuri #define fil0fil_h #include "univ.i" +struct fil_space_t; + #ifndef UNIV_INNOCHECKSUM #include "log0recv.h" @@ -43,11 +45,11 @@ struct trx_t; class page_id_t; class truncate_t; -/* structure containing encryption specification */ -typedef struct fil_space_crypt_struct fil_space_crypt_t; - typedef std::list<char*, ut_allocator<char*> > space_name_list_t; +/** Structure containing encryption specification */ +struct fil_space_crypt_t; + /** File types */ enum fil_type_t { /** temporary tablespace (temporary undo log or tables) */ @@ -163,9 +165,13 @@ struct fil_space_t { unflushed_spaces */ UT_LIST_NODE_T(fil_space_t) space_list; /*!< list of all spaces */ + /** other tablespaces needing key rotation */ + UT_LIST_NODE_T(fil_space_t) rotation_list; + /** whether this tablespace needs key rotation */ + bool is_in_rotation_list; /** MariaDB encryption data */ - fil_space_crypt_t* crypt_data; + fil_space_crypt_t* crypt_data; /** tablespace crypt data has been read */ bool page_0_crypt_read; @@ -173,11 +179,8 @@ struct fil_space_t { /** True if we have already printed compression failure */ bool printed_compression_failure; - /** True if page 0 of tablespace is read */ - bool read_page0; - - /** True if the device this filespace is on supports atomic writes */ - bool atomic_write_supported; + /** True if the device this filespace is on supports atomic writes */ + bool atomic_write_supported; /** Release the reserved free extents. @param[in] n_reserved number of reserved extents */ @@ -188,6 +191,13 @@ struct fil_space_t { bool punch_hole; ulint magic_n;/*!< FIL_SPACE_MAGIC_N */ + + /** @return whether the tablespace is about to be dropped or + truncated */ + bool is_stopping() const + { + return stop_new_ops || is_being_truncated; + } }; /** Value of fil_space_t::magic_n */ @@ -419,6 +429,16 @@ index */ #ifndef UNIV_INNOCHECKSUM +/** Enum values for encryption table option */ +enum fil_encryption_t { + /** Encrypted if innodb_encrypt_tables=ON (srv_encrypt_tables) */ + FIL_ENCRYPTION_DEFAULT, + /** Encrypted */ + FIL_ENCRYPTION_ON, + /** Not encrypted */ + FIL_ENCRYPTION_OFF +}; + /** The number of fsyncs done to the log */ extern ulint fil_n_log_flushes; @@ -490,6 +510,10 @@ struct fil_system_t { record has been written since the latest redo log checkpoint. Protected only by log_sys->mutex. */ + UT_LIST_BASE_NODE_T(fil_space_t) rotation_list; + /*!< list of all file spaces needing + key rotation.*/ + ibool space_id_reuse_warned; /* !< TRUE if fil_space_create() has issued a warning about @@ -558,22 +582,25 @@ fil_node_create( MY_ATTRIBUTE((warn_unused_result)); /** Create a space memory object and put it to the fil_system hash table. -The tablespace name is independent from the tablespace file-name. Error messages are issued to the server log. -@param[in] name tablespace name -@param[in] id tablespace identifier -@param[in] flags tablespace flags -@param[in] purpose tablespace purpose +@param[in] name tablespace name +@param[in] id tablespace identifier +@param[in] flags tablespace flags +@param[in] purpose tablespace purpose +@param[in,out] crypt_data encryption information +@param[in] create_table whether this is CREATE TABLE +@param[in] mode encryption mode @return pointer to created tablespace, to be filled in with fil_node_create() @retval NULL on failure (such as when the same tablespace exists) */ fil_space_t* fil_space_create( - const char* name, - 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 */ - bool create_table) /*!< in: true if create table */ + const char* name, + ulint id, + ulint flags, + fil_type_t purpose, + fil_space_crypt_t* crypt_data, + bool create_table, + fil_encryption_t mode = FIL_ENCRYPTION_DEFAULT) MY_ATTRIBUTE((warn_unused_result)); /*******************************************************************//** @@ -730,6 +757,32 @@ void fil_space_release( fil_space_t* space); +/** Return the next fil_space_t. +Once started, the caller must keep calling this until it returns NULL. +fil_space_acquire() and fil_space_release() are invoked here which +blocks a concurrent operation from dropping the tablespace. +@param[in,out] prev_space Pointer to the previous fil_space_t. +If NULL, use the first fil_space_t on fil_system->space_list. +@return pointer to the next fil_space_t. +@retval NULL if this was the last */ +fil_space_t* +fil_space_next( + fil_space_t* prev_space) + MY_ATTRIBUTE((warn_unused_result)); + +/** Return the next fil_space_t from key rotation list. +Once started, the caller must keep calling this until it returns NULL. +fil_space_acquire() and fil_space_release() are invoked here which +blocks a concurrent operation from dropping the tablespace. +@param[in,out] prev_space Pointer to the previous fil_space_t. +If NULL, use the first fil_space_t on fil_system->space_list. +@return pointer to the next fil_space_t. +@retval NULL if this was the last*/ +fil_space_t* +fil_space_keyrotate_next( + fil_space_t* prev_space) + MY_ATTRIBUTE((warn_unused_result)); + /** Wrapper with reference-counting for a fil_space_t. */ class FilSpace { @@ -1420,16 +1473,10 @@ fil_mtr_rename_log( mtr_t* mtr) MY_ATTRIBUTE((warn_unused_result)); -/****************************************************************//** -Acquire fil_system mutex */ -void -fil_system_enter(void); -/*==================*/ -/****************************************************************//** -Release fil_system mutex */ -void -fil_system_exit(void); -/*==================*/ +/** Acquire the fil_system mutex. */ +#define fil_system_enter() mutex_enter(&fil_system->mutex) +/** Release the fil_system mutex. */ +#define fil_system_exit() mutex_exit(&fil_system->mutex) /*******************************************************************//** Returns the table space by a given id, NULL if not found. */ @@ -1445,36 +1492,6 @@ fil_space_get_by_id( /*================*/ ulint id); /*!< in: space id */ -/****************************************************************** -Get id of first tablespace or ULINT_UNDEFINED if none */ -UNIV_INTERN -ulint -fil_get_first_space(); -/*=================*/ - -/****************************************************************** -Get id of next tablespace or ULINT_UNDEFINED if none */ -UNIV_INTERN -ulint -fil_get_next_space( - ulint id); /*!< in: space id */ - -/****************************************************************** -Get id of first tablespace that has node or ULINT_UNDEFINED if none */ -UNIV_INTERN -ulint -fil_get_first_space_safe(); -/*======================*/ - -/****************************************************************** -Get id of next tablespace that has node or ULINT_UNDEFINED if none */ -UNIV_INTERN -ulint -fil_get_next_space_safe( -/*====================*/ - ulint id); /*!< in: previous space id */ - - /*******************************************************************//** by redo log. @param[in,out] space tablespace */ |