Commit a1315a65 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-11202 InnoDB 10.1 -> 10.2 migration does not work

This is the final preparation for the merge of MDEV-11623
from MariaDB Server 10.1 (correcting the assignment of
FSP_SPACE_FLAGS in MariaDB Server 10.1).

We must avoid reading FSP_SPACE_FLAGS directly from page 0,
because the flags that affect the uncompressed page size
cannot be trusted if we are upgrading from MariaDB 10.1.

We will pass fil_space_t* instead of a numeric tablespace ID
in many low-level functions, so that fil_space_t::flags
will be available. This will also reduce the amount o
tablespace ID lookups and the pressure on fil_system->mutex.

fil_space_is_being_truncated(), fil_space_is_redo_skipped(),
PageCallback::set_page_size(), fsp_header_get_page_size(): Remove.

fil_node_open_file(), fil_space_get_crypt_data(): Use space->flags.

fsp_free_extent(), fseg_get_first_extent(), fsp_get_space_header(),
xdes_get_descriptor_with_space_hdr(), xdes_get_descriptor(),
xdes_lst_get_descriptor(), fsp_space_modify_check(),
fsp_init_file_page(), fsp_alloc_free_extent(), fsp_page_create(),
fsp_alloc_free_page(), fsp_free_page(), fsp_alloc_seg_inode_page(),
fsp_alloc_seg_inode(), fsp_free_seg_inode(), fseg_fill_free_list(),
fseg_mark_page_used(), fseg_free_page_low(), fseg_free_extent():
Take fil_space_t* as a parameter, instead of taking a numeric ID.
parent 8780b895
......@@ -659,7 +659,7 @@ fil_node_open_file(
os_file_close(node->handle);
const page_size_t page_size(flags);
const page_size_t page_size(space->flags);
min_size = FIL_IBD_FILE_INITIAL_SIZE * page_size.physical();
......@@ -1903,20 +1903,6 @@ fil_space_get_flags(
return(flags);
}
/** Check if table is mark for truncate.
@param[in] id space id
@return true if tablespace is marked for truncate. */
bool
fil_space_is_being_truncated(
ulint id)
{
bool mark_for_truncate;
mutex_enter(&fil_system->mutex);
mark_for_truncate = fil_space_get_by_id(id)->is_being_truncated;
mutex_exit(&fil_system->mutex);
return(mark_for_truncate);
}
/** 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 */
......@@ -3312,30 +3298,6 @@ fil_space_dec_redo_skipped_count(
mutex_exit(&fil_system->mutex);
}
/**
Check whether a single-table tablespace is redo skipped.
@param[in] id space id
@return true if redo skipped */
bool
fil_space_is_redo_skipped(
ulint id)
{
fil_space_t* space;
bool is_redo_skipped;
mutex_enter(&fil_system->mutex);
space = fil_space_get_by_id(id);
ut_a(space != NULL);
is_redo_skipped = space->redo_skipped_count > 0;
mutex_exit(&fil_system->mutex);
return(is_redo_skipped);
}
#endif /* UNIV_DEBUG */
/*******************************************************************//**
......@@ -6131,15 +6093,6 @@ fil_tablespace_iterate(
return(err);
}
/** Set the tablespace table size.
@param[in] page a page belonging to the tablespace */
void
PageCallback::set_page_size(
const buf_frame_t* page) UNIV_NOTHROW
{
m_page_size.copy_from(fsp_header_get_page_size(page));
}
/********************************************************************//**
Delete the tablespace file and any related files like .cfg.
This should not be called for temporary tables.
......@@ -6656,10 +6609,9 @@ fil_space_get_crypt_data(
byte *page = static_cast<byte*>(ut_align(buf, UNIV_PAGE_SIZE));
fil_read(page_id_t(space_id, 0), univ_page_size, 0, univ_page_size.physical(),
page);
ulint flags = fsp_header_get_flags(page);
ulint offset = FSP_HEADER_OFFSET
+ fsp_header_get_encryption_offset(
page_size_t(flags));
page_size_t(space->flags));
space->crypt_data = fil_space_read_crypt_data(space_id, page, offset);
ut_free(buf);
......
......@@ -353,7 +353,7 @@ Datafile::read_first_page(bool read_only_mode)
m_crypt_info = fil_space_read_crypt_data(
m_space_id, m_first_page,
FSP_HEADER_OFFSET + fsp_header_get_encryption_offset(
fsp_header_get_page_size(m_first_page)));
page_size_t(m_flags)));
return(err);
}
......
This diff is collapsed.
......@@ -630,13 +630,6 @@ fil_space_get_flags(
/*================*/
ulint id); /*!< in: space id */
/** Check if table is mark for truncate.
@param[in] id space id
@return true if tablespace is marked for truncate. */
bool
fil_space_is_being_truncated(
ulint 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. */
......@@ -1275,14 +1268,6 @@ fil_space_inc_redo_skipped_count(
void
fil_space_dec_redo_skipped_count(
ulint id);
/*******************************************************************//**
Check whether a single-table tablespace is redo skipped.
@return true if redo skipped */
bool
fil_space_is_redo_skipped(
/*======================*/
ulint id); /*!< in: space id */
#endif
/********************************************************************//**
......@@ -1341,10 +1326,6 @@ struct PageCallback {
@retval the space flags of the tablespace being iterated over */
virtual ulint get_space_flags() const UNIV_NOTHROW = 0;
/** Set the tablespace table size.
@param[in] page a page belonging to the tablespace */
void set_page_size(const buf_frame_t* page) UNIV_NOTHROW;
/** The compressed page size
@return the compressed page size */
const page_size_t& get_page_size() const
......
......@@ -329,13 +329,6 @@ fsp_header_get_flags(const page_t* page)
return(fsp_header_get_field(page, FSP_SPACE_FLAGS));
}
/** Reads the page size from the first page of a tablespace.
@param[in] page first page of a tablespace
@return page size */
page_size_t
fsp_header_get_page_size(
const page_t* page);
/** Get the byte offset of encryption information in page 0.
@param[in] ps page size
@return byte offset relative to FSP_HEADER_OFFSET */
......@@ -688,27 +681,6 @@ xdes_calc_descriptor_index(
const page_size_t& page_size,
ulint offset);
/** Gets pointer to a the extent descriptor of a page.
The page where the extent descriptor resides is x-locked. If the page offset
is equal to the free limit of the space, adds new extents from above the free
limit to the space free list, if not free limit == space size. This adding
is necessary to make the descriptor defined, as they are uninitialized
above the free limit.
@param[in] space_id space id
@param[in] offset page offset; if equal to the free limit, we
try to add new extents to the space free list
@param[in] page_size page size
@param[in,out] mtr mini-transaction
@return pointer to the extent descriptor, NULL if the page does not
exist in the space or if the offset exceeds the free limit */
xdes_t*
xdes_get_descriptor(
ulint space_id,
ulint offset,
const page_size_t& page_size,
mtr_t* mtr)
MY_ATTRIBUTE((warn_unused_result));
/**********************************************************************//**
Gets a descriptor bit of a page.
@return TRUE if free */
......
/*****************************************************************************
Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2016, MariaDB Corporation.
Copyright (c) 2015, 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
......@@ -384,6 +384,12 @@ class AbstractCallback : public PageCallback {
return(get_page_size().is_compressed());
}
/** @return the tablespace flags */
ulint get_space_flags() const
{
return(m_space_flags);
}
protected:
/** Get the data page depending on the table type, compressed or not.
@param block block read from disk
......@@ -541,13 +547,7 @@ AbstractCallback::init(
const page_t* page = block->frame;
m_space_flags = fsp_header_get_flags(page);
/* Since we don't know whether it is a compressed table
or not, the data is always read into the block->frame. */
set_page_size(block->frame);
/* Set the page size used to traverse the tablespace. */
m_page_size.copy_from(page_size_t(m_space_flags));
if (!is_compressed_table() && !m_page_size.equals_to(univ_page_size)) {
......@@ -614,13 +614,6 @@ struct FetchIndexRootPages : public AbstractCallback {
return(m_space);
}
/**
@retval the space flags of the tablespace being iterated over */
virtual ulint get_space_flags() const UNIV_NOTHROW
{
return(m_space_flags);
}
/** Check if the .ibd file row format is the same as the table's.
@param ibd_table_flags determined from space and page.
@return DB_SUCCESS or error code. */
......@@ -849,13 +842,6 @@ class PageConverter : public AbstractCallback {
return(m_cfg->m_table->space);
}
/**
@retval the space flags of the tablespace being iterated over */
virtual ulint get_space_flags() const UNIV_NOTHROW
{
return(m_space_flags);
}
/** Called for each block as it is read from the file.
@param offset physical offset in the file
@param block block to convert, it is not from the buffer pool.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment