summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-03-28 09:29:14 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-03-29 19:18:11 +0300
commit2ac8b1a90709f3484377aae72d4280ee9000e794 (patch)
treea4986d1f9977b313c6f78e4bb16a24c2aa26a8e3
parent600c85e85a26f5c401223983f842fdaecdc4671e (diff)
downloadmariadb-git-2ac8b1a90709f3484377aae72d4280ee9000e794.tar.gz
MDEV-12266: Add fil_system.sys_space, temp_space
Add fil_system_t::sys_space, fil_system_t::temp_space. These will replace lookups for TRX_SYS_SPACE or SRV_TMP_SPACE_ID. mtr_t::m_undo_space, mtr_t::m_sys_space: Remove. mtr_t::set_sys_modified(): Remove. fil_space_get_type(), fil_space_get_n_reserved_extents(): Remove. fsp_header_get_tablespace_size(), fsp_header_inc_size(): Merge to the only caller, innobase_start_or_create_for_mysql().
-rw-r--r--extra/mariabackup/xtrabackup.cc4
-rw-r--r--storage/innobase/fil/fil0fil.cc107
-rw-r--r--storage/innobase/fsp/fsp0fsp.cc57
-rw-r--r--storage/innobase/fsp/fsp0sysspace.cc22
-rw-r--r--storage/innobase/handler/ha_innodb.cc5
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.cc26
-rw-r--r--storage/innobase/include/fil0fil.h35
-rw-r--r--storage/innobase/include/fsp0fsp.h20
-rw-r--r--storage/innobase/include/mtr0mtr.h52
-rw-r--r--storage/innobase/mtr/mtr0mtr.cc80
-rw-r--r--storage/innobase/srv/srv0srv.cc4
-rw-r--r--storage/innobase/srv/srv0start.cc85
-rw-r--r--storage/innobase/trx/trx0rseg.cc6
-rw-r--r--storage/innobase/trx/trx0sys.cc2
14 files changed, 139 insertions, 366 deletions
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 6e16e44153d..ac6101575e4 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -2779,11 +2779,11 @@ xb_load_single_table_tablespace(
/* by opening the tablespace we forcing node and space objects
in the cache to be populated with fields from space header */
- fil_space_open(space->name);
+ space->open();
if (srv_operation == SRV_OPERATION_RESTORE_DELTA
|| xb_close_files) {
- fil_space_close(space->name);
+ space->close();
}
}
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index ff956f3eb89..6f7f4fef293 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -393,28 +393,6 @@ fil_space_get_latch(
return(&(space->latch));
}
-/** Gets the type of a file space.
-@param[in] id tablespace identifier
-@return file type */
-fil_type_t
-fil_space_get_type(
- ulint id)
-{
- fil_space_t* space;
-
- ut_ad(fil_system.is_initialised());
-
- mutex_enter(&fil_system.mutex);
-
- space = fil_space_get_by_id(id);
-
- ut_a(space);
-
- mutex_exit(&fil_system.mutex);
-
- return(space->purpose);
-}
-
/** Note that a tablespace has been imported.
It is initially marked as FIL_TYPE_IMPORT so that no logging is
done during the import process when the space ID is stamped to each page.
@@ -1373,6 +1351,12 @@ fil_space_detach(
fil_node_close_to_free(fil_node, space);
}
+
+ if (space == fil_system.sys_space) {
+ fil_system.sys_space = NULL;
+ } else if (space == fil_system.temp_space) {
+ fil_system.temp_space = NULL;
+ }
}
/** Free a tablespace object on which fil_space_detach() was invoked.
@@ -1828,58 +1812,47 @@ fil_space_get_flags(
return(flags);
}
-/** Open each fil_node_t of a named fil_space_t if not already open.
-@param[in] name Tablespace name
-@return true if all nodes are open */
-bool
-fil_space_open(
- const char* name)
+/** Open each file. Only invoked on fil_system.temp_space.
+@return whether all files were opened */
+bool fil_space_t::open()
{
ut_ad(fil_system.is_initialised());
mutex_enter(&fil_system.mutex);
+ ut_ad(this == fil_system.temp_space
+ || srv_operation == SRV_OPERATION_BACKUP
+ || srv_operation == SRV_OPERATION_RESTORE
+ || srv_operation == SRV_OPERATION_RESTORE_DELTA);
- fil_space_t* space = fil_space_get_by_name(name);
- fil_node_t* node;
-
- for (node = UT_LIST_GET_FIRST(space->chain);
+ for (fil_node_t* node = UT_LIST_GET_FIRST(chain);
node != NULL;
node = UT_LIST_GET_NEXT(chain, node)) {
-
- if (!node->is_open()
- && !fil_node_open_file(node)) {
+ if (!node->is_open() && !fil_node_open_file(node)) {
mutex_exit(&fil_system.mutex);
- return(false);
+ return false;
}
}
mutex_exit(&fil_system.mutex);
-
- return(true);
+ return true;
}
-/** Close each fil_node_t of a named fil_space_t if open.
-@param[in] name Tablespace name */
-void
-fil_space_close(
- const char* name)
+/** Close each file. Only invoked on fil_system.temp_space. */
+void fil_space_t::close()
{
if (!fil_system.is_initialised()) {
return;
}
mutex_enter(&fil_system.mutex);
+ ut_ad(this == fil_system.temp_space
+ || srv_operation == SRV_OPERATION_BACKUP
+ || srv_operation == SRV_OPERATION_RESTORE
+ || srv_operation == SRV_OPERATION_RESTORE_DELTA);
- fil_space_t* space = fil_space_get_by_name(name);
- if (space == NULL) {
- mutex_exit(&fil_system.mutex);
- return;
- }
-
- for (fil_node_t* node = UT_LIST_GET_FIRST(space->chain);
+ for (fil_node_t* node = UT_LIST_GET_FIRST(chain);
node != NULL;
node = UT_LIST_GET_NEXT(chain, node)) {
-
if (node->is_open()) {
fil_node_close_file(node);
}
@@ -1940,6 +1913,8 @@ void fil_system_t::close()
ut_a(!UT_LIST_GET_LEN(LRU));
ut_a(!UT_LIST_GET_LEN(unflushed_spaces));
ut_a(!UT_LIST_GET_LEN(space_list));
+ ut_ad(!sys_space);
+ ut_ad(!temp_space);
if (is_initialised()) {
m_initialised = false;
@@ -4854,32 +4829,6 @@ fil_space_release_free_extents(
mutex_exit(&fil_system.mutex);
}
-/*******************************************************************//**
-Gets the number of reserved extents. If the database is silent, this number
-should be zero. */
-ulint
-fil_space_get_n_reserved_extents(
-/*=============================*/
- ulint id) /*!< in: space id */
-{
- fil_space_t* space;
- ulint n;
-
- ut_ad(fil_system.is_initialised());
-
- mutex_enter(&fil_system.mutex);
-
- space = fil_space_get_by_id(id);
-
- ut_a(space);
-
- n = space->n_reserved_extents;
-
- mutex_exit(&fil_system.mutex);
-
- return(n);
-}
-
/*============================ FILE I/O ================================*/
/********************************************************************//**
@@ -5498,6 +5447,10 @@ struct Check {
Check check;
ut_list_validate(space->chain, check);
ut_a(space->size == check.size);
+ ut_ad(space->id != TRX_SYS_SPACE
+ || space == fil_system.sys_space);
+ ut_ad(space->id != SRV_TMP_SPACE_ID
+ || space == fil_system.temp_space);
return(check.n_open);
}
};
diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc
index a337b6f171f..fb1a650b3f5 100644
--- a/storage/innobase/fsp/fsp0fsp.cc
+++ b/storage/innobase/fsp/fsp0fsp.cc
@@ -812,63 +812,6 @@ fsp_header_get_space_id(
return(id);
}
-/**********************************************************************//**
-Increases the space size field of a space. */
-void
-fsp_header_inc_size(
-/*================*/
- ulint space_id, /*!< in: space id */
- ulint size_inc, /*!< in: size increment in pages */
- mtr_t* mtr) /*!< in/out: mini-transaction */
-{
- fsp_header_t* header;
- ulint size;
-
- ut_ad(mtr);
-
- fil_space_t* space = mtr_x_lock_space(space_id, mtr);
- ut_d(fsp_space_modify_check(space, mtr));
-
- header = fsp_get_space_header(
- space, page_size_t(space->flags), mtr);
-
- size = mach_read_from_4(header + FSP_SIZE);
- ut_ad(size == space->size_in_header);
-
- size += size_inc;
-
- mlog_write_ulint(header + FSP_SIZE, size, MLOG_4BYTES, mtr);
- space->size_in_header = size;
-}
-
-/**********************************************************************//**
-Gets the size of the system tablespace from the tablespace header. If
-we do not have an auto-extending data file, this should be equal to
-the size of the data files. If there is an auto-extending data file,
-this can be smaller.
-@return size in pages */
-ulint
-fsp_header_get_tablespace_size(void)
-/*================================*/
-{
- fsp_header_t* header;
- ulint size;
- mtr_t mtr;
-
- mtr_start(&mtr);
-
- fil_space_t* space = mtr_x_lock_space(TRX_SYS_SPACE, &mtr);
-
- header = fsp_get_space_header(space, univ_page_size, &mtr);
-
- size = mach_read_from_4(header + FSP_SIZE);
- ut_ad(space->size_in_header == size);
-
- mtr_commit(&mtr);
-
- return(size);
-}
-
/** Try to extend a single-table tablespace so that a page would fit in the
data file.
@param[in,out] space tablespace
diff --git a/storage/innobase/fsp/fsp0sysspace.cc b/storage/innobase/fsp/fsp0sysspace.cc
index e9f04cbd6c5..b7bdb8609da 100644
--- a/storage/innobase/fsp/fsp0sysspace.cc
+++ b/storage/innobase/fsp/fsp0sysspace.cc
@@ -912,15 +912,19 @@ SysTablespace::open_or_create(
it->close();
it->m_exists = true;
- if (it == begin) {
- /* First data file. */
-
- /* Create the tablespace entry for the multi-file
- tablespace in the tablespace manager. */
- space = fil_space_create(
- name(), space_id(), flags(), is_temp
- ? FIL_TYPE_TEMPORARY : FIL_TYPE_TABLESPACE,
- NULL);
+ if (it != begin) {
+ } else if (is_temp) {
+ ut_ad(!fil_system.temp_space);
+ ut_ad(space_id() == SRV_TMP_SPACE_ID);
+ space = fil_system.temp_space = fil_space_create(
+ name(), SRV_TMP_SPACE_ID, flags(),
+ FIL_TYPE_TEMPORARY, NULL);
+ } else {
+ ut_ad(!fil_system.sys_space);
+ ut_ad(space_id() == TRX_SYS_SPACE);
+ space = fil_system.sys_space = fil_space_create(
+ name(), TRX_SYS_SPACE, flags(),
+ FIL_TYPE_TABLESPACE, NULL);
}
ut_a(fil_validate());
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 5c017e91776..fff9ec45455 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -3489,9 +3489,12 @@ innobase_space_shutdown()
{
DBUG_ENTER("innobase_space_shutdown");
+ if (fil_system.temp_space) {
+ fil_system.temp_space->close();
+ }
+
srv_sys_space.shutdown();
if (srv_tmp_space.get_sanity_check_status()) {
- fil_space_close(srv_tmp_space.name());
srv_tmp_space.delete_files();
}
srv_tmp_space.shutdown();
diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc
index 8b132b62255..a88084c369f 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.cc
+++ b/storage/innobase/ibuf/ibuf0ibuf.cc
@@ -522,7 +522,9 @@ ibuf_init_at_db_start(void)
mtr_start(&mtr);
- mtr_x_lock_space(IBUF_SPACE_ID, &mtr);
+ compile_time_assert(IBUF_SPACE_ID == TRX_SYS_SPACE);
+ compile_time_assert(IBUF_SPACE_ID == 0);
+ mtr_x_lock(&fil_system.sys_space->latch, &mtr);
mutex_enter(&ibuf_mutex);
@@ -1151,7 +1153,8 @@ ibuf_page_low(
return(FALSE);
}
- ut_ad(fil_space_get_type(IBUF_SPACE_ID) == FIL_TYPE_TABLESPACE);
+ compile_time_assert(IBUF_SPACE_ID == 0);
+ ut_ad(fil_system.sys_space->purpose == FIL_TYPE_TABLESPACE);
#ifdef UNIV_DEBUG
if (!x_latch) {
@@ -2028,11 +2031,9 @@ ibuf_add_free_page(void)
page_t* bitmap_page;
mtr_start(&mtr);
- fil_space_t* space = mtr.set_sys_modified();
-
/* Acquire the fsp latch before the ibuf header, obeying the latching
order */
- mtr_x_lock(&space->latch, &mtr);
+ mtr_x_lock(&fil_system.sys_space->latch, &mtr);
header_page = ibuf_header_page_get(&mtr);
/* Allocate a new page: NOTE that if the page has been a part of a
@@ -2078,13 +2079,11 @@ ibuf_add_free_page(void)
(level 2 page) */
const page_id_t page_id(IBUF_SPACE_ID, block->page.id.page_no());
- const page_size_t page_size(space->flags);
-
- bitmap_page = ibuf_bitmap_get_map_page(page_id, page_size, &mtr);
+ bitmap_page = ibuf_bitmap_get_map_page(page_id, univ_page_size, &mtr);
mutex_exit(&ibuf_mutex);
- ibuf_bitmap_page_set_bits(bitmap_page, page_id, page_size,
+ ibuf_bitmap_page_set_bits(bitmap_page, page_id, univ_page_size,
IBUF_BITMAP_IBUF, TRUE, &mtr);
ibuf_mtr_commit(&mtr);
@@ -2110,13 +2109,10 @@ ibuf_remove_free_page(void)
log_free_check();
mtr_start(&mtr);
- fil_space_t* space = mtr.set_sys_modified();
- const page_size_t page_size(space->flags);
-
/* Acquire the fsp latch before the ibuf header, obeying the latching
order */
- mtr_x_lock(&space->latch, &mtr);
+ mtr_x_lock(&fil_system.sys_space->latch, &mtr);
header_page = ibuf_header_page_get(&mtr);
/* Prevent pessimistic inserts to insert buffer trees for a while */
@@ -2195,12 +2191,12 @@ ibuf_remove_free_page(void)
/* Set the bit indicating that this page is no more an ibuf tree page
(level 2 page) */
- bitmap_page = ibuf_bitmap_get_map_page(page_id, page_size, &mtr);
+ bitmap_page = ibuf_bitmap_get_map_page(page_id, univ_page_size, &mtr);
mutex_exit(&ibuf_mutex);
ibuf_bitmap_page_set_bits(
- bitmap_page, page_id, page_size, IBUF_BITMAP_IBUF, FALSE,
+ bitmap_page, page_id, univ_page_size, IBUF_BITMAP_IBUF, FALSE,
&mtr);
ut_d(buf_page_set_file_page_was_freed(page_id));
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index 96fe6b7e5f3..a78eb5debb1 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -204,6 +204,12 @@ struct fil_space_t {
return !atomic_write_supported
&& srv_use_doublewrite_buf && buf_dblwr;
}
+
+ /** Open each file. Only invoked on fil_system.temp_space.
+ @return whether all files were opened */
+ bool open();
+ /** Close each file. Only invoked on fil_system.temp_space. */
+ void close();
};
/** Value of fil_space_t::magic_n */
@@ -517,6 +523,8 @@ private:
bool m_initialised;
public:
ib_mutex_t mutex; /*!< The mutex protecting the cache */
+ fil_space_t* sys_space; /*!< The innodb_system tablespace */
+ fil_space_t* temp_space; /*!< The innodb_temporary tablespace */
hash_table_t* spaces; /*!< The hash table of spaces in the
system; they are hashed on the space
id */
@@ -580,13 +588,6 @@ fil_space_get_latch(
ulint id,
ulint* flags);
-/** Gets the type of a file space.
-@param[in] id tablespace identifier
-@return file type */
-fil_type_t
-fil_space_get_type(
- ulint id);
-
/** Note that a tablespace has been imported.
It is initially marked as FIL_TYPE_IMPORT so that no logging is
done during the import process when the space ID is stamped to each page.
@@ -691,19 +692,6 @@ fil_space_get_flags(
/*================*/
ulint id); /*!< in: space id */
-/** Open each fil_node_t of a named fil_space_t if not already open.
-@param[in] name Tablespace name
-@return true if all file nodes are opened. */
-bool
-fil_space_open(
- const char* name);
-
-/** Close each fil_node_t of a named fil_space_t if open.
-@param[in] name Tablespace name */
-void
-fil_space_close(
- const char* name);
-
/** Returns the page size of the space and whether it is compressed or not.
The tablespace must be cached in the memory cache.
@param[in] id space id
@@ -1235,13 +1223,6 @@ fil_space_release_free_extents(
/*===========================*/
ulint id, /*!< in: space id */
ulint n_reserved); /*!< in: how many one reserved */
-/*******************************************************************//**
-Gets the number of reserved extents. If the database is silent, this number
-should be zero. */
-ulint
-fil_space_get_n_reserved_extents(
-/*=============================*/
- ulint id); /*!< in: space id */
/** Reads or writes data. This operation could be asynchronous (aio).
diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h
index e0999c84ee9..9dafd5cdc3a 100644
--- a/storage/innobase/include/fsp0fsp.h
+++ b/storage/innobase/include/fsp0fsp.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2013, 2017, MariaDB Corporation.
+Copyright (c) 2013, 2018, 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
@@ -294,16 +294,6 @@ the extent are free and which contain old tuple version to clean. */
#ifndef UNIV_INNOCHECKSUM
/* @} */
-/**********************************************************************//**
-Gets the size of the system tablespace from the tablespace header. If
-we do not have an auto-extending data file, this should be equal to
-the size of the data files. If there is an auto-extending data file,
-this can be smaller.
-@return size in pages */
-ulint
-fsp_header_get_tablespace_size(void);
-/*================================*/
-
/** Calculate the number of pages to extend a datafile.
We extend single-table tablespaces first one extent at a time,
but 4 at a time for bigger tablespaces. It is not enough to extend always
@@ -398,14 +388,6 @@ void
fsp_header_init(ulint space_id, ulint size, mtr_t* mtr);
/**********************************************************************//**
-Increases the space size field of a space. */
-void
-fsp_header_inc_size(
-/*================*/
- ulint space_id, /*!< in: space id */
- ulint size_inc, /*!< in: size increment in pages */
- mtr_t* mtr); /*!< in/out: mini-transaction */
-/**********************************************************************//**
Creates a new segment.
@return the block where the segment header is placed, x-latched, NULL
if could not create segment because of lack of space */
diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h
index 6639a3448ea..20d9d2066a0 100644
--- a/storage/innobase/include/mtr0mtr.h
+++ b/storage/innobase/include/mtr0mtr.h
@@ -29,9 +29,7 @@ Created 11/26/1995 Heikki Tuuri
#define mtr0mtr_h
#include "univ.i"
-#include "log0types.h"
-#include "mtr0types.h"
-#include "buf0types.h"
+#include "fil0fil.h"
#include "dyn0buf.h"
/** Start a mini-transaction. */
@@ -140,9 +138,6 @@ savepoint. */
@return true if the mtr is dirtying a clean page. */
#define mtr_block_dirtied(b) mtr_t::is_block_dirtied((b))
-/** Forward declaration of a tablespace object */
-struct fil_space_t;
-
/** Append records to the system-wide redo log buffer.
@param[in] log redo log records */
void
@@ -194,12 +189,6 @@ struct mtr_t {
/** User tablespace that is being modified by the
mini-transaction */
fil_space_t* m_user_space;
- /** Undo tablespace that is being modified by the
- mini-transaction */
- fil_space_t* m_undo_space;
- /** System tablespace if it is being modified by the
- mini-transaction */
- fil_space_t* m_sys_space;
/** State of the transaction */
mtr_state_t m_state;
@@ -302,17 +291,6 @@ struct mtr_t {
@return old mode */
inline mtr_log_t set_log_mode(mtr_log_t mode);
- /** Note that the mini-transaction is modifying the system tablespace
- (for example, for the change buffer or for undo logs)
- @return the system tablespace */
- fil_space_t* set_sys_modified()
- {
- if (!m_impl.m_sys_space) {
- lookup_sys_space();
- }
- return(m_impl.m_sys_space);
- }
-
/** Copy the tablespaces associated with the mini-transaction
(needed for generating MLOG_FILE_NAME records)
@param[in] mtr mini-transaction that may modify
@@ -321,13 +299,9 @@ struct mtr_t {
{
ut_ad(!m_impl.m_user_space_id);
ut_ad(!m_impl.m_user_space);
- ut_ad(!m_impl.m_undo_space);
- ut_ad(!m_impl.m_sys_space);
ut_d(m_impl.m_user_space_id = mtr.m_impl.m_user_space_id);
m_impl.m_user_space = mtr.m_impl.m_user_space;
- m_impl.m_undo_space = mtr.m_impl.m_undo_space;
- m_impl.m_sys_space = mtr.m_impl.m_sys_space;
}
/** Set the tablespace associated with the mini-transaction
@@ -339,17 +313,27 @@ struct mtr_t {
ut_ad(!m_impl.m_user_space_id);
ut_d(m_impl.m_user_space_id = space_id);
if (!space_id) {
- return(set_sys_modified());
+ return fil_system.sys_space;
} else {
- lookup_user_space(space_id);
- return(m_impl.m_user_space);
+ ut_ad(m_impl.m_user_space_id == space_id);
+ ut_ad(!m_impl.m_user_space);
+ m_impl.m_user_space = fil_space_get(space_id);
+ ut_ad(m_impl.m_user_space);
+ return m_impl.m_user_space;
}
}
/** Set the tablespace associated with the mini-transaction
(needed for generating a MLOG_FILE_NAME record)
@param[in] space user or system tablespace */
- void set_named_space(fil_space_t* space);
+ void set_named_space(fil_space_t* space)
+ {
+ ut_ad(m_impl.m_user_space_id == TRX_SYS_SPACE);
+ ut_d(m_impl.m_user_space_id = space->id);
+ if (space->id != TRX_SYS_SPACE) {
+ m_impl.m_user_space = space;
+ }
+ }
#ifdef UNIV_DEBUG
/** Check the tablespace associated with the mini-transaction
@@ -582,12 +566,6 @@ struct mtr_t {
MY_ATTRIBUTE((warn_unused_result));
private:
- /** Look up the system tablespace. */
- void lookup_sys_space();
- /** Look up the user tablespace.
- @param[in] space_id tablespace ID */
- void lookup_user_space(ulint space_id);
-
class Command;
friend class Command;
diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc
index 72b24b08871..7926ac312ef 100644
--- a/storage/innobase/mtr/mtr0mtr.cc
+++ b/storage/innobase/mtr/mtr0mtr.cc
@@ -514,8 +514,6 @@ mtr_t::start(bool sync, bool read_only)
m_impl.m_state = MTR_STATE_ACTIVE;
ut_d(m_impl.m_user_space_id = TRX_SYS_SPACE);
m_impl.m_user_space = NULL;
- m_impl.m_undo_space = NULL;
- m_impl.m_sys_space = NULL;
m_impl.m_flush_observer = NULL;
ut_d(m_impl.m_magic_n = MTR_MAGIC_N);
@@ -638,18 +636,8 @@ mtr_t::commit_checkpoint(
bool
mtr_t::is_named_space(ulint space) const
{
- ut_ad(!m_impl.m_sys_space
- || m_impl.m_sys_space->id == TRX_SYS_SPACE);
- ut_ad(!m_impl.m_undo_space
- || m_impl.m_undo_space->id != TRX_SYS_SPACE);
ut_ad(!m_impl.m_user_space
|| m_impl.m_user_space->id != TRX_SYS_SPACE);
- ut_ad(!m_impl.m_sys_space
- || m_impl.m_sys_space != m_impl.m_user_space);
- ut_ad(!m_impl.m_sys_space
- || m_impl.m_sys_space != m_impl.m_undo_space);
- ut_ad(!m_impl.m_user_space
- || m_impl.m_user_space != m_impl.m_undo_space);
switch (get_log_mode()) {
case MTR_LOG_NONE:
@@ -681,22 +669,15 @@ mtr_t::x_lock_space(ulint space_id, const char* file, unsigned line)
ut_ad(is_active());
if (space_id == TRX_SYS_SPACE) {
- space = m_impl.m_sys_space;
-
- if (!space) {
- space = m_impl.m_sys_space = fil_space_get(space_id);
- }
+ space = fil_system.sys_space;
} else if ((space = m_impl.m_user_space) && space_id == space->id) {
- } else if ((space = m_impl.m_undo_space) && space_id == space->id) {
- } else if (get_log_mode() == MTR_LOG_NO_REDO) {
+ } else {
space = fil_space_get(space_id);
- ut_ad(space->purpose == FIL_TYPE_TEMPORARY
+ ut_ad(get_log_mode() != MTR_LOG_NO_REDO
+ || space->purpose == FIL_TYPE_TEMPORARY
|| space->purpose == FIL_TYPE_IMPORT
|| space->redo_skipped_count > 0
|| srv_is_tablespace_truncated(space->id));
- } else {
- /* called from trx_rseg_create() */
- space = m_impl.m_undo_space = fil_space_get(space_id);
}
ut_ad(space);
@@ -708,44 +689,6 @@ mtr_t::x_lock_space(ulint space_id, const char* file, unsigned line)
return(space);
}
-/** Look up the system tablespace. */
-void
-mtr_t::lookup_sys_space()
-{
- ut_ad(!m_impl.m_sys_space);
- m_impl.m_sys_space = fil_space_get(TRX_SYS_SPACE);
- ut_ad(m_impl.m_sys_space);
-}
-
-/** Look up the user tablespace.
-@param[in] space_id tablespace ID */
-void
-mtr_t::lookup_user_space(ulint space_id)
-{
- ut_ad(space_id != TRX_SYS_SPACE);
- ut_ad(m_impl.m_user_space_id == space_id);
- ut_ad(!m_impl.m_user_space);
- m_impl.m_user_space = fil_space_get(space_id);
- ut_ad(m_impl.m_user_space);
-}
-
-/** Set the tablespace associated with the mini-transaction
-(needed for generating a MLOG_FILE_NAME record)
-@param[in] space user or system tablespace */
-void
-mtr_t::set_named_space(fil_space_t* space)
-{
- ut_ad(m_impl.m_user_space_id == TRX_SYS_SPACE);
- ut_d(m_impl.m_user_space_id = space->id);
- if (space->id == TRX_SYS_SPACE) {
- ut_ad(m_impl.m_sys_space == NULL
- || m_impl.m_sys_space == space);
- m_impl.m_sys_space = space;
- } else {
- m_impl.m_user_space = space;
- }
-}
-
/** Release an object in the memo stack.
@return true if released */
bool
@@ -985,25 +928,16 @@ mtr_t::release_free_extents(ulint n_reserved)
{
fil_space_t* space;
- ut_ad(m_impl.m_undo_space == NULL);
-
if (m_impl.m_user_space != NULL) {
-
ut_ad(m_impl.m_user_space->id
== m_impl.m_user_space_id);
- ut_ad(memo_contains(get_memo(), &m_impl.m_user_space->latch,
- MTR_MEMO_X_LOCK));
-
space = m_impl.m_user_space;
} else {
-
- ut_ad(m_impl.m_sys_space->id == TRX_SYS_SPACE);
- ut_ad(memo_contains(get_memo(), &m_impl.m_sys_space->latch,
- MTR_MEMO_X_LOCK));
-
- space = m_impl.m_sys_space;
+ space = fil_system.sys_space;
}
+ ut_ad(memo_contains(get_memo(), &space->latch, MTR_MEMO_X_LOCK));
+
space->release_free_extents(n_reserved);
}
diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc
index fef5ed3e37b..ce19cdd0817 100644
--- a/storage/innobase/srv/srv0srv.cc
+++ b/storage/innobase/srv/srv0srv.cc
@@ -1204,7 +1204,6 @@ srv_printf_innodb_monitor(
{
double time_elapsed;
time_t current_time;
- ulint n_reserved;
ibool ret;
mutex_enter(&srv_innodb_monitor_mutex);
@@ -1367,8 +1366,7 @@ srv_printf_innodb_monitor(
fprintf(file, ULINTPF " read views open inside InnoDB\n",
trx_sys.view_count());
- n_reserved = fil_space_get_n_reserved_extents(0);
- if (n_reserved > 0) {
+ if (ulint n_reserved = fil_system.sys_space->n_reserved_extents) {
fprintf(file,
ULINTPF " tablespace extents now reserved for"
" B-tree split operations\n",
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index 866aa6990d1..af60e846c7e 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -1173,47 +1173,30 @@ srv_open_tmp_tablespace(bool create_new_db)
&create_new_temp_space, 12 * 1024 * 1024);
if (err == DB_FAIL) {
-
- ib::error() << "The " << srv_tmp_space.name()
- << " data file must be writable!";
-
+ ib::error() << "The innodb_temporary"
+ " data file must be writable!";
err = DB_ERROR;
-
} else if (err != DB_SUCCESS) {
- ib::error() << "Could not create the shared "
- << srv_tmp_space.name() << ".";
-
+ ib::error() << "Could not create the shared innodb_temporary.";
} else if ((err = srv_tmp_space.open_or_create(
true, create_new_db, &sum_of_new_sizes, NULL))
!= DB_SUCCESS) {
-
- ib::error() << "Unable to create the shared "
- << srv_tmp_space.name();
-
+ ib::error() << "Unable to create the shared innodb_temporary";
+ } else if (fil_system.temp_space->open()) {
+ /* Initialize the header page */
+ mtr_t mtr;
+ mtr.start();
+ mtr.set_log_mode(MTR_LOG_NO_REDO);
+ fsp_header_init(SRV_TMP_SPACE_ID,
+ srv_tmp_space.get_sum_of_sizes(),
+ &mtr);
+ mtr.commit();
} else {
-
- mtr_t mtr;
- ulint size = srv_tmp_space.get_sum_of_sizes();
-
- /* Open this shared temp tablespace in the fil_system so that
- it stays open until shutdown. */
- if (fil_space_open(srv_tmp_space.name())) {
-
- /* Initialize the header page */
- mtr_start(&mtr);
- mtr_set_log_mode(&mtr, MTR_LOG_NO_REDO);
-
- fsp_header_init(SRV_TMP_SPACE_ID, size, &mtr);
-
- mtr_commit(&mtr);
- } else {
- /* This file was just opened in the code above! */
- ib::error() << "The " << srv_tmp_space.name()
- << " data file cannot be re-opened"
- " after check_file_spec() succeeded!";
-
- err = DB_ERROR;
- }
+ /* This file was just opened in the code above! */
+ ib::error() << "The innodb_temporary"
+ " data file cannot be re-opened"
+ " after check_file_spec() succeeded!";
+ err = DB_ERROR;
}
return(err);
@@ -2121,7 +2104,7 @@ files_checked:
shutdown */
fil_open_log_and_system_tablespace_files();
- ut_d(fil_space_get(0)->recv_size = srv_sys_space_size_debug);
+ ut_d(fil_system.sys_space->recv_size = srv_sys_space_size_debug);
err = srv_undo_tablespaces_init(create_new_db);
@@ -2269,7 +2252,19 @@ files_checked:
if (sum_of_new_sizes > 0) {
/* New data file(s) were added */
mtr.start();
- fsp_header_inc_size(0, sum_of_new_sizes, &mtr);
+ buf_block_t* block = buf_page_get(
+ page_id_t(0, 0), univ_page_size,
+ RW_SX_LATCH, &mtr);
+ ulint size = mach_read_from_4(
+ FSP_HEADER_OFFSET + FSP_SIZE
+ + block->frame);
+ ut_ad(size == fil_system.sys_space
+ ->size_in_header);
+ size += sum_of_new_sizes;
+ mlog_write_ulint(FSP_HEADER_OFFSET + FSP_SIZE
+ + block->frame, size,
+ MLOG_4BYTES, &mtr);
+ fil_system.sys_space->size_in_header = size;
mtr.commit();
/* Immediately write the log record about
increased tablespace size to disk, so that it
@@ -2279,8 +2274,20 @@ files_checked:
}
}
+#ifdef UNIV_DEBUG
+ {
+ mtr.start();
+ buf_block_t* block = buf_page_get(page_id_t(0, 0),
+ univ_page_size,
+ RW_S_LATCH, &mtr);
+ ut_ad(mach_read_from_4(FSP_SIZE + FSP_HEADER_OFFSET
+ + block->frame)
+ == fil_system.sys_space->size_in_header);
+ mtr.commit();
+ }
+#endif
const ulint tablespace_size_in_header
- = fsp_header_get_tablespace_size();
+ = fil_system.sys_space->size_in_header;
const ulint sum_of_data_file_sizes
= srv_sys_space.get_sum_of_sizes();
/* Compare the system tablespace file size to what is
@@ -2430,10 +2437,8 @@ files_checked:
/* Validate a few system page types that were left
uninitialized by older versions of MySQL. */
if (!high_level_read_only) {
- mtr_t mtr;
buf_block_t* block;
mtr.start();
- mtr.set_sys_modified();
/* Bitmap page types will be reset in
buf_dblwr_check_block() without redo logging. */
block = buf_page_get(
diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc
index 9a2d1d97875..c12f9b319fa 100644
--- a/storage/innobase/trx/trx0rseg.cc
+++ b/storage/innobase/trx/trx0rseg.cc
@@ -640,11 +640,7 @@ trx_temp_rseg_create()
for (ulong i = 0; i < TRX_SYS_N_RSEGS; i++) {
mtr.start();
mtr.set_log_mode(MTR_LOG_NO_REDO);
-#ifdef UNIV_DEBUG
- const fil_space_t* space =
-#endif /* UNIV_DEBUG */
- mtr_x_lock_space(SRV_TMP_SPACE_ID, &mtr);
- ut_ad(space->purpose == FIL_TYPE_TEMPORARY);
+ mtr_x_lock(&fil_system.temp_space->latch, &mtr);
ulint page_no = trx_rseg_header_create(
SRV_TMP_SPACE_ID, i, NULL, &mtr);
diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc
index 13ebe27f539..4d4f8e2e83d 100644
--- a/storage/innobase/trx/trx0sys.cc
+++ b/storage/innobase/trx/trx0sys.cc
@@ -162,7 +162,7 @@ trx_sysf_create(
then enter the kernel: we must do it in this order to conform
to the latching order rules. */
- mtr_x_lock_space(TRX_SYS_SPACE, mtr);
+ mtr_x_lock(&fil_system.sys_space->latch, mtr);
/* Create the trx sys file block in a new allocated file segment */
block = fseg_create(TRX_SYS_SPACE, 0, TRX_SYS + TRX_SYS_FSEG_HEADER,