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

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.
parent 05b84b25
......@@ -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
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
header_page = trx_undo_page_get(page_id_t(space, hdr_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);
flst_remove(header_page + TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST,
undo_page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE, mtr);
flst_remove(TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST + header_page,
TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE + undo_page, mtr);
fseg_free_page(header_page + TRX_UNDO_SEG_HDR + TRX_UNDO_FSEG_HEADER,
space, page_no, false, mtr);
fseg_free_page(TRX_UNDO_SEG_HDR + TRX_UNDO_FSEG_HEADER + header_page,
rseg->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);
......
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