diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-11-14 11:40:33 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-11-14 11:40:33 +0200 |
commit | 3d4a80153345209bad736235d4f66dcaa51a9d51 (patch) | |
tree | d9b6b5e1fcbe8e1e96b7c02880ee25bf84a7437b /storage/innobase/include/mtr0mtr.h | |
parent | 4ded5fb9ac0cf94ec0d16b69acebdecc4066c5f2 (diff) | |
download | mariadb-git-3d4a80153345209bad736235d4f66dcaa51a9d51.tar.gz |
MDEV-12353 preparation: Replace mtr_x_lock() and friends
Apart from page latches (buf_block_t::lock), mini-transactions
are keeping track of at most one dict_index_t::lock and
fil_space_t::latch at a time, and in a rare case, purge_sys.latch.
Let us introduce interfaces for acquiring an index latch
or a tablespace latch.
In a later version, we may want to introduce mtr_t members
for holding a latched dict_index_t* and fil_space_t*,
and replace the remaining use of mtr_t::m_memo
with std::set<buf_block_t*> or with a map<buf_block_t*,byte*>
pointing to log records.
Diffstat (limited to 'storage/innobase/include/mtr0mtr.h')
-rw-r--r-- | storage/innobase/include/mtr0mtr.h | 89 |
1 files changed, 58 insertions, 31 deletions
diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index 3ca753d06e4..074f55971b3 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -85,17 +85,12 @@ savepoint. */ /** Push an object to an mtr memo stack. */ #define mtr_memo_push(m, o, t) (m)->memo_push(o, t) -/** Lock an rw-lock in s-mode. */ -#define mtr_s_lock(l, m) (m)->s_lock((l), __FILE__, __LINE__) - -/** Lock an rw-lock in x-mode. */ -#define mtr_x_lock(l, m) (m)->x_lock((l), __FILE__, __LINE__) - -/** Lock a tablespace in x-mode. */ +#define mtr_s_lock_space(s, m) (m)->s_lock_space((s), __FILE__, __LINE__) #define mtr_x_lock_space(s, m) (m)->x_lock_space((s), __FILE__, __LINE__) -/** Lock an rw-lock in sx-mode. */ -#define mtr_sx_lock(l, m) (m)->sx_lock((l), __FILE__, __LINE__) +#define mtr_s_lock_index(i, m) (m)->s_lock(&(i)->lock, __FILE__, __LINE__) +#define mtr_x_lock_index(i, m) (m)->x_lock(&(i)->lock, __FILE__, __LINE__) +#define mtr_sx_lock_index(i, m) (m)->sx_lock(&(i)->lock, __FILE__, __LINE__) #define mtr_memo_contains_flagged(m, p, l) \ (m)->memo_contains_flagged((p), (l)) @@ -251,29 +246,7 @@ struct mtr_t { inline ulint read_ulint(const byte* ptr, mlog_id_t type) const MY_ATTRIBUTE((warn_unused_result)); - /** Locks a rw-latch in S mode. - NOTE: use mtr_s_lock(). - @param lock rw-lock - @param file file name from where called - @param line line number in file */ - inline void s_lock(rw_lock_t* lock, const char* file, unsigned line); - - /** Locks a rw-latch in X mode. - NOTE: use mtr_x_lock(). - @param lock rw-lock - @param file file name from where called - @param line line number in file */ - inline void x_lock(rw_lock_t* lock, const char* file, unsigned line); - - /** Locks a rw-latch in X mode. - NOTE: use mtr_sx_lock(). - @param lock rw-lock - @param file file name from where called - @param line line number in file */ - inline void sx_lock(rw_lock_t* lock, const char* file, unsigned line); - /** Acquire a tablespace X-latch. - NOTE: use mtr_x_lock_space(). @param[in] space_id tablespace ID @param[in] file file name from where called @param[in] line line number in file @@ -283,6 +256,60 @@ struct mtr_t { const char* file, unsigned line); + /** Acquire a shared rw-latch. + @param[in] lock rw-latch + @param[in] file file name from where called + @param[in] line line number in file */ + void s_lock(rw_lock_t* lock, const char* file, unsigned line) + { + rw_lock_s_lock_inline(lock, 0, file, line); + memo_push(lock, MTR_MEMO_S_LOCK); + } + + /** Acquire an exclusive rw-latch. + @param[in] lock rw-latch + @param[in] file file name from where called + @param[in] line line number in file */ + void x_lock(rw_lock_t* lock, const char* file, unsigned line) + { + rw_lock_x_lock_inline(lock, 0, file, line); + memo_push(lock, MTR_MEMO_X_LOCK); + } + + /** Acquire an shared/exclusive rw-latch. + @param[in] lock rw-latch + @param[in] file file name from where called + @param[in] line line number in file */ + void sx_lock(rw_lock_t* lock, const char* file, unsigned line) + { + rw_lock_sx_lock_inline(lock, 0, file, line); + memo_push(lock, MTR_MEMO_SX_LOCK); + } + + /** Acquire a tablespace S-latch. + @param[in] space tablespace + @param[in] file file name from where called + @param[in] line line number in file */ + void s_lock_space(fil_space_t* space, const char* file, unsigned line) + { + ut_ad(space->purpose == FIL_TYPE_TEMPORARY + || space->purpose == FIL_TYPE_IMPORT + || space->purpose == FIL_TYPE_TABLESPACE); + s_lock(&space->latch, file, line); + } + + /** Acquire a tablespace X-latch. + @param[in] space tablespace + @param[in] file file name from where called + @param[in] line line number in file */ + void x_lock_space(fil_space_t* space, const char* file, unsigned line) + { + ut_ad(space->purpose == FIL_TYPE_TEMPORARY + || space->purpose == FIL_TYPE_IMPORT + || space->purpose == FIL_TYPE_TABLESPACE); + x_lock(&space->latch, file, line); + } + /** Release an object in the memo stack. @param object object @param type object type: MTR_MEMO_S_LOCK, ... |