summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-04-08 17:13:37 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-04-08 21:38:43 +0300
commitee7a4f4462e312d7aca81eb96e81224905741acd (patch)
treeb3f00132434c343e3c6082bbf7c2d7f6258acca8
parent05b84b2568ea62a3af69dc50ec346a22c0ac96c6 (diff)
downloadmariadb-git-ee7a4f4462e312d7aca81eb96e81224905741acd.tar.gz
MDEV-12266: Pass fil_space_t* to fseg_free_page()
fseg_free_page_func(): Avoid an unnecessary tablespace ID lookup. The callers should pass the tablespace that they already know.
-rw-r--r--storage/innobase/btr/btr0btr.cc3
-rw-r--r--storage/innobase/fsp/fsp0fsp.cc34
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.cc3
-rw-r--r--storage/innobase/include/fsp0fsp.h28
-rw-r--r--storage/innobase/trx/trx0undo.cc31
5 files changed, 51 insertions, 48 deletions
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc
index 67b5af6c63d..a0a75fae1cf 100644
--- a/storage/innobase/btr/btr0btr.cc
+++ b/storage/innobase/btr/btr0btr.cc
@@ -750,8 +750,7 @@ void btr_page_free(dict_index_t* index, buf_block_t* block, mtr_t* mtr,
? PAGE_HEADER + PAGE_BTR_SEG_LEAF
: PAGE_HEADER + PAGE_BTR_SEG_TOP];
fseg_free_page(seg_header,
- block->page.id.space(),
- block->page.id.page_no(),
+ index->table->space, block->page.id.page_no(),
block->index != NULL, mtr);
/* The page was marked free in the allocation bitmap, but it
diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc
index 30473dd563e..2b22cd253eb 100644
--- a/storage/innobase/fsp/fsp0fsp.cc
+++ b/storage/innobase/fsp/fsp0fsp.cc
@@ -1360,7 +1360,7 @@ fsp_alloc_free_page(
/** Frees a single page of a space.
The page is marked as free and clean.
@param[in,out] space tablespace
-@param[in] page_id page id
+@param[in] offset page number
@param[in] page_size page size
@param[in,out] mtr mini-transaction */
static
@@ -2923,35 +2923,39 @@ fseg_free_page_low(
fseg_free_page_low(inode, space, offset, page_size, mtr)
#endif /* !BTR_CUR_HASH_ADAPT */
-/**********************************************************************//**
-Frees a single page of a segment. */
+/** Free a page in a file segment.
+@param[in,out] seg_header file segment header
+@param[in,out] space tablespace
+@param[in] offset page number
+@param[in] ahi whether we may need to drop the adaptive
+hash index
+@param[in,out] mtr mini-transaction */
void
fseg_free_page_func(
- fseg_header_t* seg_header, /*!< in: segment header */
- ulint space_id,/*!< in: space id */
- ulint page, /*!< in: page offset */
+ fseg_header_t* seg_header,
+ fil_space_t* space,
+ ulint offset,
#ifdef BTR_CUR_HASH_ADAPT
- bool ahi, /*!< in: whether we may need to drop
- the adaptive hash index */
+ bool ahi,
#endif /* BTR_CUR_HASH_ADAPT */
- mtr_t* mtr) /*!< in/out: mini-transaction */
+ mtr_t* mtr)
{
DBUG_ENTER("fseg_free_page");
fseg_inode_t* seg_inode;
buf_block_t* iblock;
- fil_space_t* space = mtr_x_lock_space(space_id, mtr);
+ mtr_x_lock(&space->latch, mtr);
const page_size_t page_size(space->flags);
- DBUG_LOG("fseg_free_page", "space_id: " << space_id
- << ", page_no: " << page);
+ DBUG_LOG("fseg_free_page", "space_id: " << space->id
+ << ", page_no: " << offset);
- seg_inode = fseg_inode_get(seg_header, space_id, page_size, mtr,
+ seg_inode = fseg_inode_get(seg_header, space->id, page_size, mtr,
&iblock);
fil_block_check_type(*iblock, FIL_PAGE_INODE, mtr);
- fseg_free_page_low(seg_inode, space, page, page_size, ahi, mtr);
+ fseg_free_page_low(seg_inode, space, offset, page_size, ahi, mtr);
- ut_d(buf_page_set_file_page_was_freed(page_id_t(space_id, page)));
+ ut_d(buf_page_set_file_page_was_freed(page_id_t(space->id, offset)));
DBUG_VOID_RETURN;
}
diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc
index 261fbb05c63..e3c61ca29cc 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.cc
+++ b/storage/innobase/ibuf/ibuf0ibuf.cc
@@ -2139,8 +2139,9 @@ ibuf_remove_free_page(void)
the free list was so long that they cannot have taken the last
page from it. */
+ compile_time_assert(IBUF_SPACE_ID == 0);
fseg_free_page(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER,
- IBUF_SPACE_ID, page_no, false, &mtr);
+ fil_system.sys_space, page_no, false, &mtr);
const page_id_t page_id(IBUF_SPACE_ID, page_no);
diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h
index b8952a5ee17..5709a0bb11b 100644
--- a/storage/innobase/include/fsp0fsp.h
+++ b/storage/innobase/include/fsp0fsp.h
@@ -508,24 +508,28 @@ fsp_reserve_free_extents(
mtr_t* mtr,
ulint n_pages = 2);
-/**********************************************************************//**
-Frees a single page of a segment. */
+/** Free a page in a file segment.
+@param[in,out] seg_header file segment header
+@param[in,out] space tablespace
+@param[in] offset page number
+@param[in] ahi whether we may need to drop the adaptive
+hash index
+@param[in,out] mtr mini-transaction */
void
fseg_free_page_func(
- fseg_header_t* seg_header, /*!< in: segment header */
- ulint space_id, /*!< in: space id */
- ulint page, /*!< in: page offset */
+ fseg_header_t* seg_header,
+ fil_space_t* space,
+ ulint offset,
#ifdef BTR_CUR_HASH_ADAPT
- bool ahi, /*!< in: whether we may need to drop
- the adaptive hash index */
+ bool ahi,
#endif /* BTR_CUR_HASH_ADAPT */
- mtr_t* mtr); /*!< in/out: mini-transaction */
+ mtr_t* mtr);
#ifdef BTR_CUR_HASH_ADAPT
-# define fseg_free_page(header, space_id, page, ahi, mtr) \
- fseg_free_page_func(header, space_id, page, ahi, mtr)
+# define fseg_free_page(header, space, offset, ahi, mtr) \
+ fseg_free_page_func(header, space, offset, ahi, mtr)
#else /* BTR_CUR_HASH_ADAPT */
-# define fseg_free_page(header, space_id, page, ahi, mtr) \
- fseg_free_page_func(header, space_id, page, mtr)
+# define fseg_free_page(header, space, offset, ahi, mtr) \
+ fseg_free_page_func(header, space, offset, mtr)
#endif /* BTR_CUR_HASH_ADAPT */
/** Determine whether a page is free.
@param[in,out] space tablespace
diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc
index 354d3c8d848..45088b688ed 100644
--- a/storage/innobase/trx/trx0undo.cc
+++ b/storage/innobase/trx/trx0undo.cc
@@ -831,35 +831,30 @@ trx_undo_free_page(
undo log page; the caller must have reserved
the rollback segment mutex */
{
- page_t* header_page;
- page_t* undo_page;
- fil_addr_t last_addr;
- trx_rsegf_t* rseg_header;
- ulint hist_size;
const ulint space = rseg->space->id;
ut_a(hdr_page_no != page_no);
ut_ad(mutex_own(&(rseg->mutex)));
- undo_page = trx_undo_page_get(page_id_t(space, page_no), mtr);
+ page_t* undo_page = trx_undo_page_get(page_id_t(space, page_no), mtr);
+ page_t* header_page = trx_undo_page_get(page_id_t(space, hdr_page_no),
+ mtr);
- header_page = trx_undo_page_get(page_id_t(space, hdr_page_no), mtr);
+ flst_remove(TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST + header_page,
+ TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE + undo_page, mtr);
- flst_remove(header_page + TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST,
- undo_page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE, mtr);
+ fseg_free_page(TRX_UNDO_SEG_HDR + TRX_UNDO_FSEG_HEADER + header_page,
+ rseg->space, page_no, false, mtr);
- fseg_free_page(header_page + TRX_UNDO_SEG_HDR + TRX_UNDO_FSEG_HEADER,
- space, page_no, false, mtr);
-
- last_addr = flst_get_last(header_page + TRX_UNDO_SEG_HDR
- + TRX_UNDO_PAGE_LIST, mtr);
+ const fil_addr_t last_addr = flst_get_last(
+ TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST + header_page, mtr);
rseg->curr_size--;
if (in_history) {
- rseg_header = trx_rsegf_get(rseg->space, rseg->page_no, mtr);
-
- hist_size = mtr_read_ulint(rseg_header + TRX_RSEG_HISTORY_SIZE,
- MLOG_4BYTES, mtr);
+ trx_rsegf_t* rseg_header = trx_rsegf_get(
+ rseg->space, rseg->page_no, mtr);
+ uint32_t hist_size = mach_read_from_4(
+ rseg_header + TRX_RSEG_HISTORY_SIZE);
ut_ad(hist_size > 0);
mlog_write_ulint(rseg_header + TRX_RSEG_HISTORY_SIZE,
hist_size - 1, MLOG_4BYTES, mtr);