Commit f116afa7 authored by marko's avatar marko

branches/zip: Remove the fil_space_get_zip_size() call from

buf_page_get_gen().  This saves one mutex operation per block request.

buf_page_get_gen(), various macros and functions: Add parameter zip_size.

btr_node_ptr_get_child(): Add parameter index.

fil_space_get_latch(): Add optional output parameter zip_size.

fil_space_get_zip_size(): Return 0 for space id==0, because the
system tablespace is never compressed.

fsp_header_init(): Remove the parameter zip_size.

ibuf_free_excess_pages(): Remove the parameter zip_size.

trx_rseg_t, trx_undo_t: Add field zip_size.

xdes_lst_get_next(): Remove, unused.
parent fd687bbe
......@@ -89,13 +89,15 @@ btr_root_block_get(
mtr_t* mtr) /* in: mtr */
{
ulint space;
ulint zip_size;
ulint root_page_no;
buf_block_t* block;
space = dict_index_get_space(index);
zip_size = dict_table_zip_size(index->table);
root_page_no = dict_index_get_page(index);
block = btr_block_get(space, root_page_no, RW_X_LATCH, mtr);
block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, mtr);
ut_a((ibool)!!page_is_comp(buf_block_get_frame(block))
== dict_table_is_comp(index->table));
......@@ -130,7 +132,6 @@ btr_get_prev_user_rec(
page_t* page;
page_t* prev_page;
ulint prev_page_no;
ulint space;
if (!page_rec_is_infimum(rec)) {
......@@ -144,14 +145,18 @@ btr_get_prev_user_rec(
page = page_align(rec);
prev_page_no = btr_page_get_prev(page, mtr);
space = page_get_space_id(page);
if (prev_page_no != FIL_NULL) {
ulint space;
ulint zip_size;
buf_block_t* prev_block;
prev_block = buf_page_get_with_no_latch(space, prev_page_no,
mtr);
space = page_get_space_id(page);
zip_size = fil_space_get_zip_size(space);
prev_block = buf_page_get_with_no_latch(space, zip_size,
prev_page_no, mtr);
prev_page = buf_block_get_frame(prev_block);
/* The caller must already have a latch to the brother */
ut_ad(mtr_memo_contains(mtr, prev_block,
......@@ -185,7 +190,6 @@ btr_get_next_user_rec(
page_t* page;
page_t* next_page;
ulint next_page_no;
ulint space;
if (!page_rec_is_supremum(rec)) {
......@@ -199,13 +203,17 @@ btr_get_next_user_rec(
page = page_align(rec);
next_page_no = btr_page_get_next(page, mtr);
space = page_get_space_id(page);
if (next_page_no != FIL_NULL) {
ulint space;
ulint zip_size;
buf_block_t* next_block;
next_block = buf_page_get_with_no_latch(space, next_page_no,
mtr);
space = page_get_space_id(page);
zip_size = fil_space_get_zip_size(space);
next_block = buf_page_get_with_no_latch(space, zip_size,
next_page_no, mtr);
next_page = buf_block_get_frame(next_block);
/* The caller must already have a latch to the brother */
ut_ad(mtr_memo_contains(mtr, next_block, MTR_MEMO_PAGE_S_FIX)
......@@ -275,8 +283,9 @@ btr_page_alloc_for_ibuf(
+ PAGE_BTR_IBUF_FREE_LIST, mtr);
ut_a(node_addr.page != FIL_NULL);
new_block = buf_page_get(dict_index_get_space(index), node_addr.page,
RW_X_LATCH, mtr);
new_block = buf_page_get(dict_index_get_space(index),
dict_table_zip_size(index->table),
node_addr.page, RW_X_LATCH, mtr);
new_page = buf_block_get_frame(new_block);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(new_block, SYNC_TREE_NODE_NEW);
......@@ -337,8 +346,9 @@ btr_page_alloc(
return(NULL);
}
new_block = buf_page_get(dict_index_get_space(index), new_page_no,
RW_X_LATCH, mtr);
new_block = buf_page_get(dict_index_get_space(index),
dict_table_zip_size(index->table),
new_page_no, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(new_block, SYNC_TREE_NODE_NEW);
#endif /* UNIV_SYNC_DEBUG */
......@@ -517,17 +527,19 @@ btr_node_ptr_get_child(
/*===================*/
/* out: child page, x-latched */
const rec_t* node_ptr,/* in: node pointer */
dict_index_t* index, /* in: index */
const ulint* offsets,/* in: array returned by rec_get_offsets() */
mtr_t* mtr) /* in: mtr */
{
ulint page_no;
ulint space;
ut_ad(rec_offs_validate(node_ptr, NULL, offsets));
ut_ad(rec_offs_validate(node_ptr, index, offsets));
space = page_get_space_id(page_align((rec_t*) node_ptr));
page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets);
return(btr_block_get(space, page_no, RW_X_LATCH, mtr));
return(btr_block_get(space, dict_table_zip_size(index->table),
page_no, RW_X_LATCH, mtr));
}
/****************************************************************
......@@ -674,6 +686,8 @@ btr_create(
FIL_NULL if did not succeed */
ulint type, /* in: type of the index */
ulint space, /* in: space where created */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
dulint index_id,/* in: index id */
dict_index_t* index, /* in: index */
mtr_t* mtr) /* in: mini-transaction handle */
......@@ -692,7 +706,8 @@ btr_create(
if (type & DICT_IBUF) {
/* Allocate first the ibuf header page */
buf_block_t* ibuf_hdr_block = fseg_create(
space, 0, IBUF_HEADER + IBUF_TREE_SEG_HEADER, mtr);
space, 0,
IBUF_HEADER + IBUF_TREE_SEG_HEADER, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(ibuf_hdr_block, SYNC_TREE_NODE_NEW);
......@@ -710,10 +725,11 @@ btr_create(
FSP_UP, mtr);
ut_ad(page_no == IBUF_TREE_ROOT_PAGE_NO);
block = buf_page_get(space, page_no, RW_X_LATCH, mtr);
block = buf_page_get(space, zip_size, page_no,
RW_X_LATCH, mtr);
} else {
block = fseg_create(space, 0, PAGE_HEADER + PAGE_BTR_SEG_TOP,
mtr);
block = fseg_create(space, 0,
PAGE_HEADER + PAGE_BTR_SEG_TOP, mtr);
}
if (block == NULL) {
......@@ -737,8 +753,8 @@ btr_create(
} else {
/* It is a non-ibuf tree: create a file segment for leaf
pages */
fseg_create(space, page_no, PAGE_HEADER + PAGE_BTR_SEG_LEAF,
mtr);
fseg_create(space, page_no,
PAGE_HEADER + PAGE_BTR_SEG_LEAF, mtr);
/* The fseg create acquires a second latch on the page,
therefore we must declare it: */
#ifdef UNIV_SYNC_DEBUG
......@@ -790,6 +806,8 @@ void
btr_free_but_not_root(
/*==================*/
ulint space, /* in: space where created */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint root_page_no) /* in: root page number */
{
ibool finished;
......@@ -799,7 +817,7 @@ btr_free_but_not_root(
leaf_loop:
mtr_start(&mtr);
root = btr_page_get(space, root_page_no, RW_X_LATCH, &mtr);
root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH, &mtr);
/* NOTE: page hash indexes are dropped when a page is freed inside
fsp0fsp. */
......@@ -815,7 +833,7 @@ leaf_loop:
top_loop:
mtr_start(&mtr);
root = btr_page_get(space, root_page_no, RW_X_LATCH, &mtr);
root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH, &mtr);
finished = fseg_free_step_not_header(
root + PAGE_HEADER + PAGE_BTR_SEG_TOP, &mtr);
......@@ -834,6 +852,8 @@ void
btr_free_root(
/*==========*/
ulint space, /* in: space where created */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint root_page_no, /* in: root page number */
mtr_t* mtr) /* in: a mini-transaction which has already
been started */
......@@ -841,7 +861,7 @@ btr_free_root(
buf_block_t* block;
fseg_header_t* header;
block = btr_block_get(space, root_page_no, RW_X_LATCH, mtr);
block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, mtr);
btr_search_drop_page_hash_index(block);
......@@ -1565,6 +1585,7 @@ btr_attach_half_pages(
mtr_t* mtr) /* in: mtr */
{
ulint space;
ulint zip_size;
ulint prev_page_no;
ulint next_page_no;
ulint level;
......@@ -1640,11 +1661,13 @@ btr_attach_half_pages(
prev_page_no = btr_page_get_prev(page, mtr);
next_page_no = btr_page_get_next(page, mtr);
space = buf_block_get_space(block);
zip_size = buf_block_get_zip_size(block);
/* Update page links of the level */
if (prev_page_no != FIL_NULL) {
buf_block_t* prev_block = btr_block_get(space, prev_page_no,
buf_block_t* prev_block = btr_block_get(space, zip_size,
prev_page_no,
RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(prev_block->frame) == page_is_comp(page));
......@@ -1658,7 +1681,8 @@ btr_attach_half_pages(
}
if (next_page_no != FIL_NULL) {
buf_block_t* next_block = btr_block_get(space, next_page_no,
buf_block_t* next_block = btr_block_get(space, zip_size,
next_page_no,
RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(next_block->frame) == page_is_comp(page));
......@@ -1993,26 +2017,29 @@ static
void
btr_level_list_remove(
/*==================*/
ulint space, /* in: space where removed */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
page_t* page, /* in: page to remove */
mtr_t* mtr) /* in: mtr */
{
ulint space;
ulint prev_page_no;
ulint next_page_no;
ut_ad(page && mtr);
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
ut_ad(space == page_get_space_id(page));
/* Get the previous and next page numbers of page */
prev_page_no = btr_page_get_prev(page, mtr);
next_page_no = btr_page_get_next(page, mtr);
space = page_get_space_id(page);
/* Update page links of the level */
if (prev_page_no != FIL_NULL) {
buf_block_t* prev_block
= btr_block_get(space, prev_page_no, RW_X_LATCH, mtr);
= btr_block_get(space, zip_size, prev_page_no,
RW_X_LATCH, mtr);
page_t* prev_page
= buf_block_get_frame(prev_block);
#ifdef UNIV_BTR_DEBUG
......@@ -2028,7 +2055,8 @@ btr_level_list_remove(
if (next_page_no != FIL_NULL) {
buf_block_t* next_block
= btr_block_get(space, next_page_no, RW_X_LATCH, mtr);
= btr_block_get(space, zip_size, next_page_no,
RW_X_LATCH, mtr);
page_t* next_page
= buf_block_get_frame(next_block);
#ifdef UNIV_BTR_DEBUG
......@@ -2275,6 +2303,7 @@ btr_compress(
{
dict_index_t* index;
ulint space;
ulint zip_size;
ulint left_page_no;
ulint right_page_no;
buf_block_t* merge_block;
......@@ -2302,6 +2331,7 @@ btr_compress(
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
level = btr_page_get_level(page, mtr);
space = dict_index_get_space(index);
zip_size = dict_table_zip_size(index->table);
left_page_no = btr_page_get_prev(page, mtr);
right_page_no = btr_page_get_next(page, mtr);
......@@ -2322,8 +2352,8 @@ btr_compress(
if (is_left) {
merge_block = btr_block_get(space, left_page_no, RW_X_LATCH,
mtr);
merge_block = btr_block_get(space, zip_size, left_page_no,
RW_X_LATCH, mtr);
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(merge_page, mtr)
......@@ -2331,8 +2361,8 @@ btr_compress(
#endif /* UNIV_BTR_DEBUG */
} else if (right_page_no != FIL_NULL) {
merge_block = btr_block_get(space, right_page_no, RW_X_LATCH,
mtr);
merge_block = btr_block_get(space, zip_size, right_page_no,
RW_X_LATCH, mtr);
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(merge_page, mtr)
......@@ -2411,7 +2441,7 @@ err_exit:
btr_search_drop_page_hash_index(block);
/* Remove the page from the level list */
btr_level_list_remove(page, mtr);
btr_level_list_remove(space, zip_size, page, mtr);
btr_node_ptr_delete(index, block, mtr);
lock_update_merge_left(merge_block, orig_pred, block);
......@@ -2464,7 +2494,7 @@ err_exit:
#endif /* UNIV_BTR_DEBUG */
/* Remove the page from the level list */
btr_level_list_remove(page, mtr);
btr_level_list_remove(space, zip_size, page, mtr);
/* Replace the address of the old child node (= page) with the
address of the merge page to the right */
......@@ -2558,6 +2588,7 @@ btr_discard_page(
{
dict_index_t* index;
ulint space;
ulint zip_size;
ulint left_page_no;
ulint right_page_no;
buf_block_t* merge_block;
......@@ -2574,6 +2605,7 @@ btr_discard_page(
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
space = dict_index_get_space(index);
zip_size = dict_table_zip_size(index->table);
/* Decide the page which will inherit the locks */
......@@ -2581,16 +2613,16 @@ btr_discard_page(
right_page_no = btr_page_get_next(buf_block_get_frame(block), mtr);
if (left_page_no != FIL_NULL) {
merge_block = btr_block_get(space, left_page_no, RW_X_LATCH,
mtr);
merge_block = btr_block_get(space, zip_size, left_page_no,
RW_X_LATCH, mtr);
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(merge_page, mtr)
== buf_block_get_page_no(block));
#endif /* UNIV_BTR_DEBUG */
} else if (right_page_no != FIL_NULL) {
merge_block = btr_block_get(space, right_page_no, RW_X_LATCH,
mtr);
merge_block = btr_block_get(space, zip_size, right_page_no,
RW_X_LATCH, mtr);
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(merge_page, mtr)
......@@ -2625,7 +2657,7 @@ btr_discard_page(
btr_node_ptr_delete(index, block, mtr);
/* Remove the page from the level list */
btr_level_list_remove(page, mtr);
btr_level_list_remove(space, zip_size, page, mtr);
#ifdef UNIV_ZIP_DEBUG
{
page_zip_des_t* merge_page_zip
......@@ -2740,6 +2772,7 @@ btr_print_recursive(
ULINT_UNDEFINED, heap);
btr_print_recursive(index,
btr_node_ptr_get_child(node_ptr,
index,
*offsets,
&mtr2),
width, heap, offsets, &mtr2);
......@@ -3041,6 +3074,7 @@ btr_validate_level(
ulint level) /* in: level number */
{
ulint space;
ulint zip_size;
buf_block_t* block;
page_t* page;
buf_block_t* right_block = 0; /* remove warning */
......@@ -3069,11 +3103,14 @@ btr_validate_level(
block = btr_root_block_get(index, &mtr);
page = buf_block_get_frame(block);
space = page_get_space_id(page);
space = dict_index_get_space(index);
zip_size = dict_table_zip_size(index->table);
while (level != btr_page_get_level(page, &mtr)) {
const rec_t* node_ptr;
ut_a(space == buf_block_get_space(block));
ut_a(space == page_get_space_id(page));
#ifdef UNIV_ZIP_DEBUG
page_zip = buf_block_get_page_zip(block);
ut_a(!page_zip || page_zip_validate(page_zip, page));
......@@ -3086,7 +3123,7 @@ btr_validate_level(
node_ptr = page_cur_get_rec(&cursor);
offsets = rec_get_offsets(node_ptr, index, offsets,
ULINT_UNDEFINED, &heap);
block = btr_node_ptr_get_child(node_ptr, offsets, &mtr);
block = btr_node_ptr_get_child(node_ptr, index, offsets, &mtr);
page = buf_block_get_frame(block);
}
......@@ -3134,8 +3171,8 @@ loop:
if (right_page_no != FIL_NULL) {
const rec_t* right_rec;
right_block = btr_block_get(space, right_page_no, RW_X_LATCH,
&mtr);
right_block = btr_block_get(space, zip_size, right_page_no,
RW_X_LATCH, &mtr);
right_page = buf_block_get_frame(right_block);
if (UNIV_UNLIKELY(btr_page_get_prev(right_page, &mtr)
!= page_get_page_no(page))) {
......@@ -3357,7 +3394,8 @@ node_ptr_fails:
if (right_page_no != FIL_NULL) {
mtr_start(&mtr);
block = btr_block_get(space, right_page_no, RW_X_LATCH, &mtr);
block = btr_block_get(space, zip_size, right_page_no,
RW_X_LATCH, &mtr);
page = buf_block_get_frame(block);
goto loop;
......
......@@ -172,6 +172,8 @@ btr_cur_latch_leaves(
page_t* page, /* in: leaf page where the search
converged */
ulint space, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no, /* in: page number of the leaf */
ulint latch_mode, /* in: BTR_SEARCH_LEAF, ... */
btr_cur_t* cursor, /* in: cursor */
......@@ -188,7 +190,7 @@ btr_cur_latch_leaves(
case BTR_SEARCH_LEAF:
case BTR_MODIFY_LEAF:
mode = latch_mode == BTR_SEARCH_LEAF ? RW_S_LATCH : RW_X_LATCH;
get_block = btr_block_get(space, page_no, mode, mtr);
get_block = btr_block_get(space, zip_size, page_no, mode, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
#endif /* UNIV_BTR_DEBUG */
......@@ -199,7 +201,8 @@ btr_cur_latch_leaves(
left_page_no = btr_page_get_prev(page, mtr);
if (left_page_no != FIL_NULL) {
get_block = btr_block_get(space, left_page_no,
get_block = btr_block_get(space, zip_size,
left_page_no,
RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame)
......@@ -210,7 +213,8 @@ btr_cur_latch_leaves(
get_block->check_index_page_at_flush = TRUE;
}
get_block = btr_block_get(space, page_no, RW_X_LATCH, mtr);
get_block = btr_block_get(space, zip_size, page_no,
RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
#endif /* UNIV_BTR_DEBUG */
......@@ -219,7 +223,8 @@ btr_cur_latch_leaves(
right_page_no = btr_page_get_next(page, mtr);
if (right_page_no != FIL_NULL) {
get_block = btr_block_get(space, right_page_no,
get_block = btr_block_get(space, zip_size,
right_page_no,
RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame)
......@@ -239,8 +244,8 @@ btr_cur_latch_leaves(
left_page_no = btr_page_get_prev(page, mtr);
if (left_page_no != FIL_NULL) {
get_block = btr_block_get(space, left_page_no,
mode, mtr);
get_block = btr_block_get(space, zip_size,
left_page_no, mode, mtr);
cursor->left_block = get_block;
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame)
......@@ -251,7 +256,7 @@ btr_cur_latch_leaves(
get_block->check_index_page_at_flush = TRUE;
}
get_block = btr_block_get(space, page_no, mode, mtr);
get_block = btr_block_get(space, zip_size, page_no, mode, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
#endif /* UNIV_BTR_DEBUG */
......@@ -454,10 +459,13 @@ btr_cur_search_to_nth_level(
/* Loop and search until we arrive at the desired level */
for (;;) {
ulint zip_size;
buf_block_t* block;
retry_page_get:
block = buf_page_get_gen(space, page_no, rw_latch, guess,
buf_mode,
zip_size = dict_table_zip_size(index->table);
block = buf_page_get_gen(space, zip_size, page_no,
rw_latch, guess, buf_mode,
__FILE__, __LINE__,
mtr);
if (block == NULL) {
......@@ -469,8 +477,7 @@ retry_page_get:
ut_ad(cursor->thr);
if (ibuf_should_try(index, ignore_sec_unique)
&& ibuf_insert(tuple, index, space,
dict_table_zip_size(index->table),
&& ibuf_insert(tuple, index, space, zip_size,
page_no, cursor->thr)) {
/* Insertion to the insert buffer succeeded */
cursor->flag = BTR_CUR_INSERT_TO_IBUF;
......@@ -522,7 +529,7 @@ retry_page_get:
if (height == 0) {
if (rw_latch == RW_NO_LATCH) {
btr_cur_latch_leaves(page, space,
btr_cur_latch_leaves(page, space, zip_size,
page_no, latch_mode,
cursor, mtr);
}
......@@ -558,7 +565,7 @@ retry_page_get:
if (level > 0) {
/* x-latch the page */
page = btr_page_get(space,
page = btr_page_get(space, zip_size,
page_no, RW_X_LATCH, mtr);
ut_a((ibool)!!page_is_comp(page)
== dict_table_is_comp(index->table));
......@@ -641,6 +648,7 @@ btr_cur_open_at_index_side(
page_cur_t* page_cursor;
ulint page_no;
ulint space;
ulint zip_size;
ulint height;
ulint root_height = 0; /* remove warning */
rec_t* node_ptr;
......@@ -669,6 +677,7 @@ btr_cur_open_at_index_side(
cursor->index = index;
space = dict_index_get_space(index);
zip_size = dict_table_zip_size(index->table);
page_no = dict_index_get_page(index);
height = ULINT_UNDEFINED;
......@@ -676,8 +685,8 @@ btr_cur_open_at_index_side(
for (;;) {
buf_block_t* block;
page_t* page;
block = buf_page_get_gen(space, page_no, RW_NO_LATCH, NULL,
BUF_GET,
block = buf_page_get_gen(space, zip_size, page_no,
RW_NO_LATCH, NULL, BUF_GET,
__FILE__, __LINE__,
mtr);
page = buf_block_get_frame(block);
......@@ -694,7 +703,7 @@ btr_cur_open_at_index_side(
}
if (height == 0) {
btr_cur_latch_leaves(page, space, page_no,
btr_cur_latch_leaves(page, space, zip_size, page_no,
latch_mode, cursor, mtr);
/* In versions <= 3.23.52 we had forgotten to
......@@ -769,6 +778,7 @@ btr_cur_open_at_rnd_pos(
page_cur_t* page_cursor;
ulint page_no;
ulint space;
ulint zip_size;
ulint height;
rec_t* node_ptr;
mem_heap_t* heap = NULL;
......@@ -786,6 +796,7 @@ btr_cur_open_at_rnd_pos(
cursor->index = index;
space = dict_index_get_space(index);
zip_size = dict_table_zip_size(index->table);
page_no = dict_index_get_page(index);
height = ULINT_UNDEFINED;
......@@ -794,8 +805,8 @@ btr_cur_open_at_rnd_pos(
buf_block_t* block;
page_t* page;
block = buf_page_get_gen(space, page_no, RW_NO_LATCH, NULL,
BUF_GET,
block = buf_page_get_gen(space, zip_size, page_no,
RW_NO_LATCH, NULL, BUF_GET,
__FILE__, __LINE__,
mtr);
page = buf_block_get_frame(block);
......@@ -809,7 +820,7 @@ btr_cur_open_at_rnd_pos(
}
if (height == 0) {
btr_cur_latch_leaves(page, space, page_no,
btr_cur_latch_leaves(page, space, zip_size, page_no,
latch_mode, cursor, mtr);
}
......@@ -1932,6 +1943,7 @@ btr_cur_pess_upd_restore_supremum(
page_t* page;
buf_block_t* prev_block;
ulint space;
ulint zip_size;
ulint prev_page_no;
page = buf_block_get_frame(block);
......@@ -1943,10 +1955,12 @@ btr_cur_pess_upd_restore_supremum(
}
space = buf_block_get_space(block);
zip_size = buf_block_get_zip_size(block);
prev_page_no = btr_page_get_prev(page, mtr);
ut_ad(prev_page_no != FIL_NULL);
prev_block = buf_page_get_with_no_latch(space, prev_page_no, mtr);
prev_block = buf_page_get_with_no_latch(space, zip_size,
prev_page_no, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(prev_block->frame, mtr)
== page_get_page_no(page));
......@@ -3597,6 +3611,7 @@ btr_store_big_rec_extern_fields(
ulint store_len;
ulint page_no;
ulint space_id;
ulint zip_size;
ulint prev_page_no;
ulint hint_page_no;
ulint i;
......@@ -3616,6 +3631,7 @@ btr_store_big_rec_extern_fields(
== buf_block_get_zip_size(rec_block));
space_id = buf_block_get_space(rec_block);
zip_size = buf_block_get_zip_size(rec_block);
rec_page_no = buf_block_get_page_no(rec_block);
if (UNIV_LIKELY_NULL(page_zip)) {
......@@ -3690,7 +3706,7 @@ btr_store_big_rec_extern_fields(
buf_block_t* prev_block;
page_t* prev_page;
prev_block = buf_page_get(space_id,
prev_block = buf_page_get(space_id, zip_size,
prev_page_no,
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
......@@ -3783,7 +3799,8 @@ btr_store_big_rec_extern_fields(
goto next_zip_page;
}
rec_block = buf_page_get(space_id, rec_page_no,
rec_block = buf_page_get(space_id, zip_size,
rec_page_no,
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(rec_block,
......@@ -3866,7 +3883,8 @@ next_zip_page:
extern_len -= store_len;
rec_block = buf_page_get(space_id, rec_page_no,
rec_block = buf_page_get(space_id, zip_size,
rec_page_no,
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(rec_block,
......@@ -3951,6 +3969,8 @@ btr_free_externally_stored_field(
{
page_t* page;
ulint space_id;
ulint rec_zip_size = dict_table_zip_size(index->table);
ulint ext_zip_size;
ulint page_no;
ulint next_page_no;
mtr_t mtr;
......@@ -3972,6 +3992,14 @@ btr_free_externally_stored_field(
}
#endif /* UNIV_DEBUG */
space_id = mach_read_from_4(field_ref + BTR_EXTERN_SPACE_ID);
if (UNIV_UNLIKELY(space_id != dict_index_get_space(index))) {
ext_zip_size = fil_space_get_zip_size(space_id);
} else {
ext_zip_size = rec_zip_size;
}
for (;;) {
buf_block_t* rec_block;
buf_block_t* ext_block;
......@@ -3980,14 +4008,13 @@ btr_free_externally_stored_field(
rec_block = buf_page_get(page_get_space_id(
page_align(field_ref)),
rec_zip_size,
page_get_page_no(
page_align(field_ref)),
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(rec_block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
space_id = mach_read_from_4(field_ref + BTR_EXTERN_SPACE_ID);
page_no = mach_read_from_4(field_ref + BTR_EXTERN_PAGE_NO);
if (/* There is no external storage data */
......@@ -4006,13 +4033,14 @@ btr_free_externally_stored_field(
return;
}
ext_block = buf_page_get(space_id, page_no, RW_X_LATCH, &mtr);
ext_block = buf_page_get(space_id, ext_zip_size, page_no,
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(ext_block, SYNC_EXTERN_STORAGE);
#endif /* UNIV_SYNC_DEBUG */
page = buf_block_get_frame(ext_block);
if (dict_table_zip_size(index->table)) {
if (ext_zip_size) {
/* Note that page_zip will be NULL
in row_purge_upd_exist_or_extern(). */
next_page_no = mach_read_from_4(page + FIL_PAGE_NEXT);
......@@ -4179,7 +4207,7 @@ btr_copy_blob_prefix(
byte* buf, /* out: the externally stored part of
the field, or a prefix of it */
ulint len, /* in: length of buf, in bytes */
ulint space_id,/* in: space id of the first BLOB page */
ulint space_id,/* in: space id of the BLOB pages */
ulint page_no,/* in: page number of the first BLOB page */
ulint offset) /* in: offset on the first BLOB page */
{
......@@ -4195,7 +4223,7 @@ btr_copy_blob_prefix(
mtr_start(&mtr);
block = buf_page_get(space_id, page_no, RW_S_LATCH, &mtr);
block = buf_page_get(space_id, 0, page_no, RW_S_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_EXTERN_STORAGE);
#endif /* UNIV_SYNC_DEBUG */
......@@ -4237,7 +4265,7 @@ btr_copy_zblob_prefix(
/*==================*/
z_stream* d_stream,/* in/out: the decompressing stream */
ulint zip_size,/* in: compressed BLOB page size */
ulint space_id,/* in: space id of the first BLOB page */
ulint space_id,/* in: space id of the BLOB pages */
ulint page_no,/* in: page number of the first BLOB page */
ulint offset) /* in: offset on the first BLOB page */
{
......@@ -4255,7 +4283,8 @@ btr_copy_zblob_prefix(
mtr_start(&mtr);
block = buf_page_get(space_id, page_no, RW_S_LATCH, &mtr);
block = buf_page_get(space_id, zip_size, page_no,
RW_S_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_EXTERN_STORAGE);
#endif /* UNIV_SYNC_DEBUG */
......
......@@ -376,6 +376,7 @@ btr_pcur_move_to_next_page(
{
ulint next_page_no;
ulint space;
ulint zip_size;
page_t* page;
buf_block_t* next_block;
page_t* next_page;
......@@ -389,10 +390,11 @@ btr_pcur_move_to_next_page(
page = btr_pcur_get_page(cursor);
next_page_no = btr_page_get_next(page, mtr);
space = buf_block_get_space(btr_pcur_get_block(cursor));
zip_size = buf_block_get_zip_size(btr_pcur_get_block(cursor));
ut_ad(next_page_no != FIL_NULL);
next_block = btr_block_get(space, next_page_no,
next_block = btr_block_get(space, zip_size, next_page_no,
cursor->latch_mode, mtr);
next_page = buf_block_get_frame(next_block);
#ifdef UNIV_BTR_DEBUG
......
......@@ -1107,6 +1107,8 @@ void
btr_search_drop_page_hash_when_freed(
/*=================================*/
ulint space, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no) /* in: page number */
{
buf_block_t* block;
......@@ -1124,7 +1126,7 @@ btr_search_drop_page_hash_when_freed(
get here. Therefore we can acquire the s-latch to the page without
having to fear a deadlock. */
block = buf_page_get_gen(space, page_no, RW_S_LATCH, NULL,
block = buf_page_get_gen(space, zip_size, page_no, RW_S_LATCH, NULL,
BUF_GET_IF_IN_POOL, __FILE__, __LINE__,
&mtr);
......
......@@ -1479,6 +1479,8 @@ buf_page_get_gen(
/*=============*/
/* out: pointer to the block or NULL */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint offset, /* in: page number */
ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
buf_block_t* guess, /* in: guessed block or NULL */
......@@ -1493,7 +1495,6 @@ buf_page_get_gen(
ulint fix_type;
ibool success;
ibool must_read;
const ulint zip_size = fil_space_get_zip_size(space);
ut_ad(mtr);
ut_ad((rw_latch == RW_S_LATCH)
......@@ -1502,6 +1503,7 @@ buf_page_get_gen(
ut_ad((mode != BUF_GET_NO_LATCH) || (rw_latch == RW_NO_LATCH));
ut_ad((mode == BUF_GET) || (mode == BUF_GET_IF_IN_POOL)
|| (mode == BUF_GET_NO_LATCH) || (mode == BUF_GET_NOWAIT));
ut_ad(zip_size == fil_space_get_zip_size(space));
#ifndef UNIV_LOG_DEBUG
ut_ad(!ibuf_inside() || ibuf_page(space, zip_size, offset));
#endif
......@@ -2322,7 +2324,8 @@ buf_page_create(
buf_block_free(free_block);
return(buf_page_get_with_no_latch(space, offset, mtr));
return(buf_page_get_with_no_latch(space, zip_size,
offset, mtr));
}
/* If we get here, the page was not in buf_pool: init it there */
......
......@@ -139,8 +139,10 @@ scan_again:
/* Note that the following call will acquire
an S-latch on the page */
btr_search_drop_page_hash_when_freed(id,
page_no);
btr_search_drop_page_hash_when_freed(
id,
buf_page_get_zip_size(bpage),
page_no);
goto scan_again;
}
......
......@@ -36,7 +36,7 @@ dict_hdr_get(
buf_block_t* block;
dict_hdr_t* header;
block = buf_page_get(DICT_HDR_SPACE, DICT_HDR_PAGE_NO,
block = buf_page_get(DICT_HDR_SPACE, 0, DICT_HDR_PAGE_NO,
RW_X_LATCH, mtr);
header = DICT_HDR + buf_block_get_frame(block);
#ifdef UNIV_SYNC_DEBUG
......@@ -146,7 +146,7 @@ dict_hdr_create(
/*--------------------------*/
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
DICT_HDR_SPACE, DICT_TABLES_ID,
DICT_HDR_SPACE, 0, DICT_TABLES_ID,
srv_sys->dummy_ind1, mtr);
if (root_page_no == FIL_NULL) {
......@@ -156,7 +156,7 @@ dict_hdr_create(
mlog_write_ulint(dict_header + DICT_HDR_TABLES, root_page_no,
MLOG_4BYTES, mtr);
/*--------------------------*/
root_page_no = btr_create(DICT_UNIQUE, DICT_HDR_SPACE,
root_page_no = btr_create(DICT_UNIQUE, DICT_HDR_SPACE, 0,
DICT_TABLE_IDS_ID,
srv_sys->dummy_ind1, mtr);
if (root_page_no == FIL_NULL) {
......@@ -168,7 +168,7 @@ dict_hdr_create(
MLOG_4BYTES, mtr);
/*--------------------------*/
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
DICT_HDR_SPACE, DICT_COLUMNS_ID,
DICT_HDR_SPACE, 0, DICT_COLUMNS_ID,
srv_sys->dummy_ind1, mtr);
if (root_page_no == FIL_NULL) {
......@@ -179,7 +179,7 @@ dict_hdr_create(
MLOG_4BYTES, mtr);
/*--------------------------*/
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
DICT_HDR_SPACE, DICT_INDEXES_ID,
DICT_HDR_SPACE, 0, DICT_INDEXES_ID,
srv_sys->dummy_ind1, mtr);
if (root_page_no == FIL_NULL) {
......@@ -190,7 +190,7 @@ dict_hdr_create(
MLOG_4BYTES, mtr);
/*--------------------------*/
root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
DICT_HDR_SPACE, DICT_FIELDS_ID,
DICT_HDR_SPACE, 0, DICT_FIELDS_ID,
srv_sys->dummy_ind1, mtr);
if (root_page_no == FIL_NULL) {
......
......@@ -272,8 +272,7 @@ dict_build_table_def_step(
mtr_start(&mtr);
fsp_header_init(table->space, FIL_IBD_FILE_INITIAL_SIZE,
dict_table_zip_size(table), &mtr);
fsp_header_init(table->space, FIL_IBD_FILE_INITIAL_SIZE, &mtr);
mtr_commit(&mtr);
} else {
......@@ -622,8 +621,9 @@ dict_create_index_tree_step(
btr_pcur_move_to_next_user_rec(&pcur, &mtr);
node->page_no = btr_create(index->type, index->space, index->id,
index, &mtr);
node->page_no = btr_create(index->type, index->space,
dict_table_zip_size(index->table),
index->id, index, &mtr);
/* printf("Created a new index tree in space %lu root page %lu\n",
index->space, index->page_no); */
......@@ -653,6 +653,7 @@ dict_drop_index_tree(
{
ulint root_page_no;
ulint space;
ulint zip_size;
const byte* ptr;
ulint len;
......@@ -679,8 +680,9 @@ dict_drop_index_tree(
ut_ad(len == 4);
space = mtr_read_ulint(ptr, MLOG_4BYTES, mtr);
zip_size = fil_space_get_zip_size(space);
if (!fil_tablespace_exists_in_mem(space)) {
if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) {
/* It is a single table tablespace and the .ibd file is
missing: do nothing */
......@@ -690,7 +692,7 @@ dict_drop_index_tree(
/* We free all the pages but the root page first; this operation
may span several mini-transactions */
btr_free_but_not_root(space, root_page_no);
btr_free_but_not_root(space, zip_size, root_page_no);
/* Then we free the root page in the same mini-transaction where
we write FIL_NULL to the appropriate field in the SYS_INDEXES
......@@ -698,7 +700,7 @@ dict_drop_index_tree(
/* printf("Dropping index tree in space %lu root page %lu\n", space,
root_page_no); */
btr_free_root(space, root_page_no, mtr);
btr_free_root(space, zip_size, root_page_no, mtr);
page_rec_write_index_page_no(rec,
DICT_SYS_INDEXES_PAGE_NO_FIELD,
......@@ -724,6 +726,7 @@ dict_truncate_index_tree(
{
ulint root_page_no;
ulint space;
ulint zip_size;
ulint type;
dulint index_id;
rec_t* rec;
......@@ -759,8 +762,9 @@ dict_truncate_index_tree(
ut_ad(len == 4);
space = mtr_read_ulint(ptr, MLOG_4BYTES, mtr);
zip_size = fil_space_get_zip_size(space);
if (!fil_tablespace_exists_in_mem(space)) {
if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) {
/* It is a single table tablespace and the .ibd file is
missing: do nothing */
......@@ -782,17 +786,17 @@ dict_truncate_index_tree(
/* We free all the pages but the root page first; this operation
may span several mini-transactions */
btr_free_but_not_root(space, root_page_no);
btr_free_but_not_root(space, zip_size, root_page_no);
/* Then we free the root page in the same mini-transaction where
we create the b-tree and write its new root page number to the
appropriate field in the SYS_INDEXES record: this mini-transaction
marks the B-tree totally truncated */
comp = page_is_comp(btr_page_get(space, root_page_no, RW_X_LATCH,
mtr));
comp = page_is_comp(btr_page_get(space, zip_size, root_page_no,
RW_X_LATCH, mtr));
btr_free_root(space, root_page_no, mtr);
btr_free_root(space, zip_size, root_page_no, mtr);
/* We will temporarily write FIL_NULL to the PAGE_NO field
in SYS_INDEXES, so that the database will not get into an
inconsistent state in case it crashes between the mtr_commit()
......@@ -818,7 +822,7 @@ dict_truncate_index_tree(
}
}
root_page_no = btr_create(type, space, index_id, index, mtr);
root_page_no = btr_create(type, space, zip_size, index_id, index, mtr);
if (index) {
index->page = root_page_no;
} else {
......
......@@ -389,7 +389,9 @@ rw_lock_t*
fil_space_get_latch(
/*================*/
/* out: latch protecting storage allocation */
ulint id) /* in: space id */
ulint id, /* in: space id */
ulint* zip_size)/* out: compressed page size, or
0 for uncompressed tablespaces */
{
fil_system_t* system = fil_system;
fil_space_t* space;
......@@ -402,6 +404,10 @@ fil_space_get_latch(
ut_a(space);
if (zip_size) {
*zip_size = space->zip_size;
}
mutex_exit(&(system->mutex));
return(&(space->latch));
......@@ -1385,6 +1391,10 @@ fil_space_get_zip_size(
ut_ad(system);
if (UNIV_UNLIKELY(!id)) {
return(0);
}
fil_mutex_enter_and_prepare_for_io(id);
HASH_SEARCH(hash, system->spaces, id, space, space->id == id);
......
......@@ -219,6 +219,8 @@ void
fsp_free_extent(
/*============*/
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page, /* in: page offset in the extent */
mtr_t* mtr); /* in: mtr */
/**************************************************************************
......@@ -229,6 +231,8 @@ fseg_free_extent(
/*=============*/
fseg_inode_t* seg_inode, /* in: segment inode */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page, /* in: page offset in the extent */
mtr_t* mtr); /* in: mtr handle */
/**************************************************************************
......@@ -251,6 +255,8 @@ fseg_mark_page_used(
/*================*/
fseg_inode_t* seg_inode,/* in: segment inode */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page, /* in: page offset */
mtr_t* mtr); /* in: mtr */
/**************************************************************************
......@@ -264,6 +270,9 @@ fseg_get_first_extent(
/* out: the first extent descriptor, or NULL if
none */
fseg_inode_t* inode, /* in: segment inode */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
mtr_t* mtr); /* in: mtr */
/**************************************************************************
Puts new extents to the free list if
......@@ -293,6 +302,8 @@ fseg_alloc_free_page_low(
/* out: the allocated page number, FIL_NULL
if no page could be allocated */
ulint space, /* in: space */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
fseg_inode_t* seg_inode, /* in: segment inode */
ulint hint, /* in: hint of which page would be desirable */
byte direction, /* in: if the new page is needed because
......@@ -323,17 +334,25 @@ fsp_get_space_header(
/*=================*/
/* out: pointer to the space header, page x-locked */
ulint id, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
mtr_t* mtr) /* in: mtr */
{
buf_block_t* block;
fsp_header_t* header;
block = buf_page_get(id, 0, RW_X_LATCH, mtr);
ut_ad(ut_is_2pow(zip_size));
ut_ad(zip_size <= UNIV_PAGE_SIZE);
ut_ad(!zip_size || zip_size >= PAGE_ZIP_MIN_SIZE);
ut_ad(id || !zip_size);
block = buf_page_get(id, zip_size, 0, RW_X_LATCH, mtr);
header = FSP_HEADER_OFFSET + buf_block_get_frame(block);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
#endif /* UNIV_SYNC_DEBUG */
ut_ad(id == mach_read_from_4(FSP_SPACE_ID + header));
ut_ad(zip_size == mach_read_from_4(FSP_PAGE_ZIP_SIZE + header));
return(header);
}
......@@ -675,7 +694,7 @@ xdes_get_descriptor_with_space_hdr(
page_t* descr_page;
ut_ad(mtr);
ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space),
ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space, NULL),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains_page(mtr, sp_header, MTR_MEMO_PAGE_S_FIX)
|| mtr_memo_contains_page(mtr, sp_header, MTR_MEMO_PAGE_X_FIX));
......@@ -706,7 +725,8 @@ xdes_get_descriptor_with_space_hdr(
} else {
buf_block_t* block;
block = buf_page_get(space, descr_page_no, RW_X_LATCH, mtr);
block = buf_page_get(space, zip_size, descr_page_no,
RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
#endif /* UNIV_SYNC_DEBUG */
......@@ -732,6 +752,8 @@ xdes_get_descriptor(
page does not exist in the space or if offset > free
limit */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint offset, /* in: page offset; if equal to the free limit,
we try to add new extents to the space free list */
mtr_t* mtr) /* in: mtr handle */
......@@ -739,7 +761,7 @@ xdes_get_descriptor(
buf_block_t* block;
fsp_header_t* sp_header;
block = buf_page_get(space, 0, RW_X_LATCH, mtr);
block = buf_page_get(space, zip_size, 0, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
#endif /* UNIV_SYNC_DEBUG */
......@@ -758,6 +780,8 @@ xdes_lst_get_descriptor(
/*====================*/
/* out: pointer to the extent descriptor */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
fil_addr_t lst_node,/* in: file address of the list node
contained in the descriptor */
mtr_t* mtr) /* in: mtr handle */
......@@ -765,34 +789,14 @@ xdes_lst_get_descriptor(
xdes_t* descr;
ut_ad(mtr);
ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space),
ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space, NULL),
MTR_MEMO_X_LOCK));
descr = fut_get_ptr(space, lst_node, RW_X_LATCH, mtr) - XDES_FLST_NODE;
descr = fut_get_ptr(space, zip_size, lst_node, RW_X_LATCH, mtr)
- XDES_FLST_NODE;
return(descr);
}
/************************************************************************
Gets pointer to the next descriptor in a descriptor list and x-locks its
page. */
UNIV_INLINE
xdes_t*
xdes_lst_get_next(
/*==============*/
xdes_t* descr, /* in: pointer to a descriptor */
mtr_t* mtr) /* in: mtr handle */
{
ulint space;
ut_ad(mtr && descr);
space = page_get_space_id(page_align(descr));
return(xdes_lst_get_descriptor(
space,
flst_get_next_addr(descr + XDES_FLST_NODE, mtr), mtr));
}
/************************************************************************
Returns page offset of the first page in extent described by a descriptor. */
UNIV_INLINE
......@@ -920,19 +924,19 @@ fsp_header_init(
/*============*/
ulint space, /* in: space id */
ulint size, /* in: current size in blocks */
ulint zip_size, /* in: compressed page size, or 0 */
mtr_t* mtr) /* in: mini-transaction handle */
{
fsp_header_t* header;
buf_block_t* block;
page_t* page;
ulint zip_size;
ut_ad(mtr);
mtr_x_lock(fil_space_get_latch(space), mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), mtr);
block = buf_page_create(space, 0, zip_size, mtr);
buf_page_get(space, 0, RW_X_LATCH, mtr);
buf_page_get(space, zip_size, 0, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
#endif /* UNIV_SYNC_DEBUG */
......@@ -965,8 +969,8 @@ fsp_header_init(
mlog_write_dulint(header + FSP_SEG_ID, ut_dulint_create(0, 1), mtr);
if (space == 0) {
fsp_fill_free_list(FALSE, space, header, mtr);
btr_create(DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF, space,
ut_dulint_add(DICT_IBUF_ID_MIN, space),
btr_create(DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF,
0, 0, ut_dulint_add(DICT_IBUF_ID_MIN, space),
srv_sys->dummy_ind1, mtr);
} else {
fsp_fill_free_list(TRUE, space, header, mtr);
......@@ -1006,7 +1010,7 @@ Reads the compressed page size from the first page of a tablespace. */
ulint
fsp_header_get_zip_size(
/*=====================*/
/*====================*/
/* out: compressed page size in bytes,
or 0 if uncompressed */
const page_t* page) /* in: first page of a tablespace */
......@@ -1026,12 +1030,13 @@ fsp_header_inc_size(
{
fsp_header_t* header;
ulint size;
ulint zip_size;
ut_ad(mtr);
mtr_x_lock(fil_space_get_latch(space), mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), mtr);
header = fsp_get_space_header(space, mtr);
header = fsp_get_space_header(space, zip_size, mtr);
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
......@@ -1060,12 +1065,11 @@ fsp_header_get_free_limit(
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), &mtr);
header = fsp_get_space_header(space, &mtr);
header = fsp_get_space_header(space, zip_size, &mtr);
limit = mtr_read_ulint(header + FSP_FREE_LIMIT, MLOG_4BYTES, &mtr);
zip_size = mach_read_from_4(header + FSP_PAGE_ZIP_SIZE);
if (!zip_size) {
limit /= ((1024 * 1024) / UNIV_PAGE_SIZE);
......@@ -1093,15 +1097,16 @@ fsp_header_get_tablespace_size(
{
fsp_header_t* header;
ulint size;
ulint zip_size;
mtr_t mtr;
ut_a(space == 0); /* We have only one log_fsp_current_... variable */
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), &mtr);
header = fsp_get_space_header(space, &mtr);
header = fsp_get_space_header(space, zip_size, &mtr);
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, &mtr);
......@@ -1353,7 +1358,8 @@ fsp_fill_free_list(
if (i > 0) {
block = buf_page_create(
space, i, zip_size, mtr);
buf_page_get(space, i, RW_X_LATCH, mtr);
buf_page_get(space, zip_size, i,
RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block,
SYNC_FSP_PAGE);
......@@ -1375,7 +1381,8 @@ fsp_fill_free_list(
block = buf_page_create(space,
i + FSP_IBUF_BITMAP_OFFSET,
zip_size, &ibuf_mtr);
buf_page_get(space, i + FSP_IBUF_BITMAP_OFFSET,
buf_page_get(space, zip_size,
i + FSP_IBUF_BITMAP_OFFSET,
RW_X_LATCH, &ibuf_mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
......@@ -1434,6 +1441,8 @@ fsp_alloc_free_extent(
/* out: extent descriptor, NULL if cannot be
allocated */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint hint, /* in: hint of which extent would be desirable: any
page offset in the extent goes; the hint must not
be > FSP_FREE_LIMIT */
......@@ -1445,7 +1454,7 @@ fsp_alloc_free_extent(
ut_ad(mtr);
header = fsp_get_space_header(space, mtr);
header = fsp_get_space_header(space, zip_size, mtr);
descr = xdes_get_descriptor_with_space_hdr(header, space, hint, mtr);
......@@ -1466,7 +1475,7 @@ fsp_alloc_free_extent(
return(NULL); /* No free extents left */
}
descr = xdes_lst_get_descriptor(space, first, mtr);
descr = xdes_lst_get_descriptor(space, zip_size, first, mtr);
}
flst_remove(header + FSP_FREE, descr + XDES_FLST_NODE, mtr);
......@@ -1483,6 +1492,8 @@ fsp_alloc_free_page(
/* out: the page offset, FIL_NULL if no page could
be allocated */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint hint, /* in: hint of which page would be desirable */
mtr_t* mtr) /* in: mtr handle */
{
......@@ -1498,7 +1509,7 @@ fsp_alloc_free_page(
ut_ad(mtr);
header = fsp_get_space_header(space, mtr);
header = fsp_get_space_header(space, zip_size, mtr);
/* Get the hinted descriptor */
descr = xdes_get_descriptor_with_space_hdr(header, space, hint, mtr);
......@@ -1517,7 +1528,8 @@ fsp_alloc_free_page(
FREE_FRAG list. But we will allocate our page from the
the free extent anyway. */
descr = fsp_alloc_free_extent(space, hint, mtr);
descr = fsp_alloc_free_extent(space, zip_size,
hint, mtr);
if (descr == NULL) {
/* No free space left */
......@@ -1529,7 +1541,8 @@ fsp_alloc_free_page(
flst_add_last(header + FSP_FREE_FRAG,
descr + XDES_FLST_NODE, mtr);
} else {
descr = xdes_lst_get_descriptor(space, first, mtr);
descr = xdes_lst_get_descriptor(space, zip_size,
first, mtr);
}
/* Reset the hint */
......@@ -1600,10 +1613,9 @@ fsp_alloc_free_page(
be obtained immediately with buf_page_get without need for a disk
read. */
buf_page_create(space, page_no,
mach_read_from_4(FSP_PAGE_ZIP_SIZE + header), mtr);
buf_page_create(space, page_no, zip_size, mtr);
block = buf_page_get(space, page_no, RW_X_LATCH, mtr);
block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
#endif /* UNIV_SYNC_DEBUG */
......@@ -1621,6 +1633,8 @@ void
fsp_free_page(
/*==========*/
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page, /* in: page offset */
mtr_t* mtr) /* in: mtr handle */
{
......@@ -1633,7 +1647,7 @@ fsp_free_page(
/* fprintf(stderr, "Freeing page %lu in space %lu\n", page, space); */
header = fsp_get_space_header(space, mtr);
header = fsp_get_space_header(space, zip_size, mtr);
descr = xdes_get_descriptor_with_space_hdr(header, space, page, mtr);
......@@ -1698,7 +1712,7 @@ fsp_free_page(
/* The extent has become free: move it to another list */
flst_remove(header + FSP_FREE_FRAG, descr + XDES_FLST_NODE,
mtr);
fsp_free_extent(space, page, mtr);
fsp_free_extent(space, zip_size, page, mtr);
}
}
......@@ -1709,6 +1723,8 @@ void
fsp_free_extent(
/*============*/
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page, /* in: page offset in the extent */
mtr_t* mtr) /* in: mtr */
{
......@@ -1717,7 +1733,7 @@ fsp_free_extent(
ut_ad(mtr);
header = fsp_get_space_header(space, mtr);
header = fsp_get_space_header(space, zip_size, mtr);
descr = xdes_get_descriptor_with_space_hdr(header, space, page, mtr);
......@@ -1834,15 +1850,17 @@ fsp_alloc_seg_inode_page(
ulint i;
space = page_get_space_id(page_align(space_header));
zip_size = mtr_read_ulint(space_header + FSP_PAGE_ZIP_SIZE,
MLOG_4BYTES, mtr);
page_no = fsp_alloc_free_page(space, 0, mtr);
page_no = fsp_alloc_free_page(space, zip_size, 0, mtr);
if (page_no == FIL_NULL) {
return(FALSE);
}
block = buf_page_get(space, page_no, RW_X_LATCH, mtr);
block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
#endif /* UNIV_SYNC_DEBUG */
......@@ -1854,9 +1872,6 @@ fsp_alloc_seg_inode_page(
mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_INODE,
MLOG_2BYTES, mtr);
zip_size = mtr_read_ulint(space_header + FSP_PAGE_ZIP_SIZE,
MLOG_4BYTES, mtr);
for (i = 0; i < FSP_SEG_INODES_PER_PAGE(zip_size); i++) {
inode = fsp_seg_inode_page_get_nth_inode(page, i,
......@@ -1904,7 +1919,7 @@ fsp_alloc_seg_inode(
zip_size = mach_read_from_4(space_header + FSP_PAGE_ZIP_SIZE);
block = buf_page_get(page_get_space_id(page_align(space_header)),
page_no, RW_X_LATCH, mtr);
zip_size, page_no, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
#endif /* UNIV_SYNC_DEBUG */
......@@ -1938,17 +1953,17 @@ void
fsp_free_seg_inode(
/*===============*/
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
fseg_inode_t* inode, /* in: segment inode */
mtr_t* mtr) /* in: mini-transaction handle */
{
page_t* page;
fsp_header_t* space_header;
ulint zip_size;
page = page_align(inode);
space_header = fsp_get_space_header(space, mtr);
zip_size = mach_read_from_4(space_header + FSP_PAGE_ZIP_SIZE);
space_header = fsp_get_space_header(space, zip_size, mtr);
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
......@@ -1975,7 +1990,7 @@ fsp_free_seg_inode(
flst_remove(space_header + FSP_SEG_INODES_FREE,
page + FSEG_INODE_PAGE_NODE, mtr);
fsp_free_page(space, page_get_page_no(page), mtr);
fsp_free_page(space, zip_size, page_get_page_no(page), mtr);
}
}
......@@ -1987,6 +2002,9 @@ fseg_inode_get(
/*===========*/
/* out: segment inode, page x-latched */
fseg_header_t* header, /* in: segment header */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
mtr_t* mtr) /* in: mtr handle */
{
fil_addr_t inode_addr;
......@@ -1994,9 +2012,9 @@ fseg_inode_get(
inode_addr.page = mach_read_from_4(header + FSEG_HDR_PAGE_NO);
inode_addr.boffset = mach_read_from_2(header + FSEG_HDR_OFFSET);
ut_ad(space == mach_read_from_4(header + FSEG_HDR_SPACE));
inode = fut_get_ptr(mach_read_from_4(header + FSEG_HDR_SPACE),
inode_addr, RW_X_LATCH, mtr);
inode = fut_get_ptr(space, zip_size, inode_addr, RW_X_LATCH, mtr);
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
......@@ -2145,6 +2163,7 @@ fseg_create_general(
operation */
mtr_t* mtr) /* in: mtr */
{
ulint zip_size;
fsp_header_t* space_header;
fseg_inode_t* inode;
dulint seg_id;
......@@ -2157,17 +2176,17 @@ fseg_create_general(
ut_ad(mtr);
latch = fil_space_get_latch(space, &zip_size);
if (page != 0) {
block = buf_page_get(space, page, RW_X_LATCH, mtr);
block = buf_page_get(space, zip_size, page, RW_X_LATCH, mtr);
header = byte_offset + buf_block_get_frame(block);
}
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex)
|| mtr_memo_contains(mtr, fil_space_get_latch(space),
MTR_MEMO_X_LOCK));
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
#endif /* UNIV_SYNC_DEBUG */
latch = fil_space_get_latch(space);
mtr_x_lock(latch, mtr);
......@@ -2176,7 +2195,7 @@ fseg_create_general(
excess pages from the insert buffer free list */
if (space == 0) {
ibuf_free_excess_pages(0, 0);
ibuf_free_excess_pages(0);
}
}
......@@ -2188,7 +2207,7 @@ fseg_create_general(
}
}
space_header = fsp_get_space_header(space, mtr);
space_header = fsp_get_space_header(space, zip_size, mtr);
inode = fsp_alloc_seg_inode(space_header, mtr);
......@@ -2219,16 +2238,17 @@ fseg_create_general(
}
if (page == 0) {
page = fseg_alloc_free_page_low(space, inode, 0, FSP_UP, mtr);
page = fseg_alloc_free_page_low(space, zip_size,
inode, 0, FSP_UP, mtr);
if (page == FIL_NULL) {
fsp_free_seg_inode(space, inode, mtr);
fsp_free_seg_inode(space, zip_size, inode, mtr);
goto funct_exit;
}
block = buf_page_get(space, page, RW_X_LATCH, mtr);
block = buf_page_get(space, zip_size, page, RW_X_LATCH, mtr);
header = byte_offset + buf_block_get_frame(block);
mlog_write_ulint(header - byte_offset + FIL_PAGE_TYPE,
FIL_PAGE_TYPE_SYS, MLOG_2BYTES, mtr);
......@@ -2317,17 +2337,18 @@ fseg_n_reserved_pages(
ulint ret;
fseg_inode_t* inode;
ulint space;
ulint zip_size;
space = page_get_space_id(page_align(header));
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex)
|| mtr_memo_contains(mtr, fil_space_get_latch(space),
|| mtr_memo_contains(mtr, fil_space_get_latch(space, NULL),
MTR_MEMO_X_LOCK));
#endif /* UNIV_SYNC_DEBUG */
mtr_x_lock(fil_space_get_latch(space), mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), mtr);
inode = fseg_inode_get(header, mtr);
inode = fseg_inode_get(header, space, zip_size, mtr);
ret = fseg_n_reserved_pages_low(inode, used, mtr);
......@@ -2345,6 +2366,8 @@ fseg_fill_free_list(
/*================*/
fseg_inode_t* inode, /* in: segment inode */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint hint, /* in: hint which extent would be good as
the first extent */
mtr_t* mtr) /* in: mtr */
......@@ -2373,7 +2396,7 @@ fseg_fill_free_list(
}
for (i = 0; i < FSEG_FREE_LIST_MAX_LEN; i++) {
descr = xdes_get_descriptor(space, hint, mtr);
descr = xdes_get_descriptor(space, zip_size, hint, mtr);
if ((descr == NULL)
|| (XDES_FREE != xdes_get_state(descr, mtr))) {
......@@ -2383,7 +2406,7 @@ fseg_fill_free_list(
return;
}
descr = fsp_alloc_free_extent(space, hint, mtr);
descr = fsp_alloc_free_extent(space, zip_size, hint, mtr);
xdes_set_state(descr, XDES_FSEG, mtr);
......@@ -2408,6 +2431,8 @@ fseg_alloc_free_extent(
not be allocated */
fseg_inode_t* inode, /* in: segment inode */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
mtr_t* mtr) /* in: mtr */
{
xdes_t* descr;
......@@ -2419,10 +2444,10 @@ fseg_alloc_free_extent(
first = flst_get_first(inode + FSEG_FREE, mtr);
descr = xdes_lst_get_descriptor(space, first, mtr);
descr = xdes_lst_get_descriptor(space, zip_size, first, mtr);
} else {
/* Segment free list was empty, allocate from space */
descr = fsp_alloc_free_extent(space, 0, mtr);
descr = fsp_alloc_free_extent(space, zip_size, 0, mtr);
if (descr == NULL) {
......@@ -2436,7 +2461,7 @@ fseg_alloc_free_extent(
flst_add_last(inode + FSEG_FREE, descr + XDES_FLST_NODE, mtr);
/* Try to fill the segment free list */
fseg_fill_free_list(inode, space,
fseg_fill_free_list(inode, space, zip_size,
xdes_get_offset(descr) + FSP_EXTENT_SIZE,
mtr);
}
......@@ -2455,6 +2480,8 @@ fseg_alloc_free_page_low(
/* out: the allocated page number, FIL_NULL
if no page could be allocated */
ulint space, /* in: space */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
fseg_inode_t* seg_inode, /* in: segment inode */
ulint hint, /* in: hint of which page would be desirable */
byte direction, /* in: if the new page is needed because
......@@ -2487,7 +2514,7 @@ fseg_alloc_free_page_low(
reserved = fseg_n_reserved_pages_low(seg_inode, &used, mtr);
space_header = fsp_get_space_header(space, mtr);
space_header = fsp_get_space_header(space, zip_size, mtr);
descr = xdes_get_descriptor_with_space_hdr(space_header, space,
hint, mtr);
......@@ -2495,7 +2522,7 @@ fseg_alloc_free_page_low(
/* Hint outside space or too high above free limit: reset
hint */
hint = 0;
descr = xdes_get_descriptor(space, hint, mtr);
descr = xdes_get_descriptor(space, zip_size, hint, mtr);
}
/* In the big if-else below we look for ret_page and ret_descr */
......@@ -2519,7 +2546,7 @@ fseg_alloc_free_page_low(
=========================================================
the hinted page
===============*/
ret_descr = fsp_alloc_free_extent(space, hint, mtr);
ret_descr = fsp_alloc_free_extent(space, zip_size, hint, mtr);
ut_a(ret_descr == descr);
......@@ -2529,7 +2556,7 @@ fseg_alloc_free_page_low(
ret_descr + XDES_FLST_NODE, mtr);
/* Try to fill the segment free list */
fseg_fill_free_list(seg_inode, space,
fseg_fill_free_list(seg_inode, space, zip_size,
hint + FSP_EXTENT_SIZE, mtr);
ret_page = hint;
/*-----------------------------------------------------------*/
......@@ -2537,7 +2564,8 @@ fseg_alloc_free_page_low(
&& ((reserved - used) < reserved / FSEG_FILLFACTOR)
&& (used >= FSEG_FRAG_LIMIT)
&& (!!(ret_descr
= fseg_alloc_free_extent(seg_inode, space, mtr)))) {
= fseg_alloc_free_extent(seg_inode,
space, zip_size, mtr)))) {
/* 3. We take any free extent (which was already assigned above
===============================================================
......@@ -2582,7 +2610,8 @@ fseg_alloc_free_page_low(
return(FIL_NULL);
}
ret_descr = xdes_lst_get_descriptor(space, first, mtr);
ret_descr = xdes_lst_get_descriptor(space, zip_size,
first, mtr);
ret_page = xdes_get_offset(ret_descr)
+ xdes_find_bit(ret_descr, XDES_FREE_BIT, TRUE,
0, mtr);
......@@ -2590,7 +2619,7 @@ fseg_alloc_free_page_low(
} else if (used < FSEG_FRAG_LIMIT) {
/* 6. We allocate an individual page from the space
===================================================*/
ret_page = fsp_alloc_free_page(space, hint, mtr);
ret_page = fsp_alloc_free_page(space, zip_size, hint, mtr);
ret_descr = NULL;
frag_page_allocated = TRUE;
......@@ -2608,7 +2637,8 @@ fseg_alloc_free_page_low(
} else {
/* 7. We allocate a new extent and take its first page
======================================================*/
ret_descr = fseg_alloc_free_extent(seg_inode, space, mtr);
ret_descr = fseg_alloc_free_extent(seg_inode,
space, zip_size, mtr);
if (ret_descr == NULL) {
ret_page = FIL_NULL;
......@@ -2655,14 +2685,18 @@ fseg_alloc_free_page_low(
can be obtained immediately with buf_page_get without need
for a disk read */
buf_block_t* block;
ulint zip_size = mach_read_from_4(FSP_PAGE_ZIP_SIZE
+ space_header);
block = buf_page_create(space, ret_page,
mach_read_from_4(FSP_PAGE_ZIP_SIZE
+ space_header), mtr);
block = buf_page_create(space, ret_page, zip_size, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
#endif /* UNIV_SYNC_DEBUG */
ut_a(block == buf_page_get(space, ret_page, RW_X_LATCH, mtr));
if (UNIV_UNLIKELY(block != buf_page_get(space, zip_size,
ret_page, RW_X_LATCH,
mtr))) {
ut_error;
}
/* The prior contents of the page should be ignored */
fsp_init_file_page(block, mtr);
......@@ -2671,11 +2705,12 @@ fseg_alloc_free_page_low(
The extent is still in the appropriate list (FSEG_NOT_FULL
or FSEG_FREE), and the page is not yet marked as used. */
ut_ad(xdes_get_descriptor(space, ret_page, mtr) == ret_descr);
ut_ad(xdes_get_descriptor(space, zip_size, ret_page, mtr)
== ret_descr);
ut_ad(xdes_get_bit(ret_descr, XDES_FREE_BIT,
ret_page % FSP_EXTENT_SIZE, mtr) == TRUE);
fseg_mark_page_used(seg_inode, space, ret_page, mtr);
fseg_mark_page_used(seg_inode, space, zip_size, ret_page, mtr);
}
buf_reset_check_index_page_at_flush(space, ret_page);
......@@ -2709,6 +2744,7 @@ fseg_alloc_free_page_general(
{
fseg_inode_t* inode;
ulint space;
ulint zip_size;
rw_lock_t* latch;
ibool success;
ulint page_no;
......@@ -2716,12 +2752,12 @@ fseg_alloc_free_page_general(
space = page_get_space_id(page_align(seg_header));
latch = fil_space_get_latch(space, &zip_size);
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex)
|| mtr_memo_contains(mtr, fil_space_get_latch(space),
MTR_MEMO_X_LOCK));
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
#endif /* UNIV_SYNC_DEBUG */
latch = fil_space_get_latch(space);
mtr_x_lock(latch, mtr);
......@@ -2730,11 +2766,11 @@ fseg_alloc_free_page_general(
excess pages from the insert buffer free list */
if (space == 0) {
ibuf_free_excess_pages(0, 0);
ibuf_free_excess_pages(0);
}
}
inode = fseg_inode_get(seg_header, mtr);
inode = fseg_inode_get(seg_header, space, zip_size, mtr);
if (!has_done_reservation) {
success = fsp_reserve_free_extents(&n_reserved, space, 2,
......@@ -2744,8 +2780,7 @@ fseg_alloc_free_page_general(
}
}
page_no = fseg_alloc_free_page_low(page_get_space_id(
page_align(inode)),
page_no = fseg_alloc_free_page_low(space, zip_size,
inode, hint, direction, mtr);
if (!has_done_reservation) {
fil_space_release_free_extents(space, n_reserved);
......@@ -2868,22 +2903,17 @@ fsp_reserve_free_extents(
ulint n_pages_added;
ut_ad(mtr);
*n_reserved = n_ext;
latch = fil_space_get_latch(space, &zip_size);
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex)
|| mtr_memo_contains(mtr, fil_space_get_latch(space),
MTR_MEMO_X_LOCK));
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
#endif /* UNIV_SYNC_DEBUG */
*n_reserved = n_ext;
latch = fil_space_get_latch(space);
mtr_x_lock(latch, mtr);
space_header = fsp_get_space_header(space, mtr);
zip_size = mach_read_from_4(FSP_PAGE_ZIP_SIZE + space_header);
ut_a(ut_is_2pow(zip_size));
ut_a(zip_size <= UNIV_PAGE_SIZE);
ut_a(!zip_size || zip_size >= PAGE_ZIP_MIN_SIZE);
space_header = fsp_get_space_header(space, zip_size, mtr);
try_again:
size = mtr_read_ulint(space_header + FSP_SIZE, MLOG_4BYTES, mtr);
......@@ -2985,13 +3015,11 @@ fsp_get_available_space_in_free_extents(
#endif /* UNIV_SYNC_DEBUG */
mtr_start(&mtr);
latch = fil_space_get_latch(space);
latch = fil_space_get_latch(space, &zip_size);
mtr_x_lock(latch, &mtr);
space_header = fsp_get_space_header(space, &mtr);
zip_size = mach_read_from_4(FSP_PAGE_ZIP_SIZE + space_header);
space_header = fsp_get_space_header(space, zip_size, &mtr);
size = mtr_read_ulint(space_header + FSP_SIZE, MLOG_4BYTES, &mtr);
......@@ -3056,6 +3084,8 @@ fseg_mark_page_used(
/*================*/
fseg_inode_t* seg_inode,/* in: segment inode */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page, /* in: page offset */
mtr_t* mtr) /* in: mtr */
{
......@@ -3064,7 +3094,7 @@ fseg_mark_page_used(
ut_ad(seg_inode && mtr);
descr = xdes_get_descriptor(space, page, mtr);
descr = xdes_get_descriptor(space, zip_size, page, mtr);
ut_ad(mtr_read_ulint(seg_inode + FSEG_ID, MLOG_4BYTES, mtr)
== mtr_read_ulint(descr + XDES_ID, MLOG_4BYTES, mtr));
......@@ -3110,6 +3140,8 @@ fseg_free_page_low(
/*===============*/
fseg_inode_t* seg_inode, /* in: segment inode */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page, /* in: page offset */
mtr_t* mtr) /* in: mtr handle */
{
......@@ -3127,9 +3159,9 @@ fseg_free_page_low(
/* Drop search system page hash index if the page is found in
the pool and is hashed */
btr_search_drop_page_hash_when_freed(space, page);
btr_search_drop_page_hash_when_freed(space, zip_size, page);
descr = xdes_get_descriptor(space, page, mtr);
descr = xdes_get_descriptor(space, zip_size, page, mtr);
ut_a(descr);
if (xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)) {
......@@ -3169,7 +3201,7 @@ crash:
}
}
fsp_free_page(space, page, mtr);
fsp_free_page(space, zip_size, page, mtr);
return;
}
......@@ -3235,7 +3267,7 @@ crash:
/* The extent has become free: free it to space */
flst_remove(seg_inode + FSEG_NOT_FULL,
descr + XDES_FLST_NODE, mtr);
fsp_free_extent(space, page, mtr);
fsp_free_extent(space, zip_size, page, mtr);
}
}
......@@ -3250,18 +3282,19 @@ fseg_free_page(
ulint page, /* in: page offset */
mtr_t* mtr) /* in: mtr handle */
{
ulint zip_size;
fseg_inode_t* seg_inode;
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex)
|| mtr_memo_contains(mtr, fil_space_get_latch(space),
|| mtr_memo_contains(mtr, fil_space_get_latch(space, NULL),
MTR_MEMO_X_LOCK));
#endif /* UNIV_SYNC_DEBUG */
mtr_x_lock(fil_space_get_latch(space), mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), mtr);
seg_inode = fseg_inode_get(seg_header, mtr);
seg_inode = fseg_inode_get(seg_header, space, zip_size, mtr);
fseg_free_page_low(seg_inode, space, page, mtr);
fseg_free_page_low(seg_inode, space, zip_size, page, mtr);
#ifdef UNIV_DEBUG_FILE_ACCESSES
buf_page_set_file_page_was_freed(space, page);
......@@ -3276,6 +3309,8 @@ fseg_free_extent(
/*=============*/
fseg_inode_t* seg_inode, /* in: segment inode */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page, /* in: a page in the extent */
mtr_t* mtr) /* in: mtr handle */
{
......@@ -3287,7 +3322,7 @@ fseg_free_extent(
ut_ad(seg_inode && mtr);
descr = xdes_get_descriptor(space, page, mtr);
descr = xdes_get_descriptor(space, zip_size, page, mtr);
ut_a(xdes_get_state(descr, mtr) == XDES_FSEG);
ut_a(0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, mtr),
......@@ -3302,7 +3337,7 @@ fseg_free_extent(
found in the pool and is hashed */
btr_search_drop_page_hash_when_freed(
space, first_page_in_extent + i);
space, zip_size, first_page_in_extent + i);
}
}
......@@ -3326,7 +3361,7 @@ fseg_free_extent(
MLOG_4BYTES, mtr);
}
fsp_free_extent(space, page, mtr);
fsp_free_extent(space, zip_size, page, mtr);
#ifdef UNIV_DEBUG_FILE_ACCESSES
for (i = 0; i < FSP_EXTENT_SIZE; i++) {
......@@ -3358,6 +3393,7 @@ fseg_free_step(
xdes_t* descr;
fseg_inode_t* inode;
ulint space;
ulint zip_size;
ulint header_page;
space = page_get_space_id(page_align(header));
......@@ -3365,12 +3401,12 @@ fseg_free_step(
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex)
|| mtr_memo_contains(mtr, fil_space_get_latch(space),
|| mtr_memo_contains(mtr, fil_space_get_latch(space, NULL),
MTR_MEMO_X_LOCK));
#endif /* UNIV_SYNC_DEBUG */
mtr_x_lock(fil_space_get_latch(space), mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), mtr);
descr = xdes_get_descriptor(space, header_page, mtr);
descr = xdes_get_descriptor(space, zip_size, header_page, mtr);
/* Check that the header resides on a page which has not been
freed yet */
......@@ -3378,15 +3414,15 @@ fseg_free_step(
ut_a(descr);
ut_a(xdes_get_bit(descr, XDES_FREE_BIT,
header_page % FSP_EXTENT_SIZE, mtr) == FALSE);
inode = fseg_inode_get(header, mtr);
inode = fseg_inode_get(header, space, zip_size, mtr);
descr = fseg_get_first_extent(inode, mtr);
descr = fseg_get_first_extent(inode, space, zip_size, mtr);
if (descr != NULL) {
/* Free the extent held by the segment */
page = xdes_get_offset(descr);
fseg_free_extent(inode, space, page, mtr);
fseg_free_extent(inode, space, zip_size, page, mtr);
return(FALSE);
}
......@@ -3396,19 +3432,19 @@ fseg_free_step(
if (n == ULINT_UNDEFINED) {
/* Freeing completed: free the segment inode */
fsp_free_seg_inode(space, inode, mtr);
fsp_free_seg_inode(space, zip_size, inode, mtr);
return(TRUE);
}
fseg_free_page_low(inode, space,
fseg_free_page_low(inode, space, zip_size,
fseg_get_nth_frag_page_no(inode, n, mtr), mtr);
n = fseg_find_last_used_frag_page_slot(inode, mtr);
if (n == ULINT_UNDEFINED) {
/* Freeing completed: free the segment inode */
fsp_free_seg_inode(space, inode, mtr);
fsp_free_seg_inode(space, zip_size, inode, mtr);
return(TRUE);
}
......@@ -3434,26 +3470,27 @@ fseg_free_step_not_header(
xdes_t* descr;
fseg_inode_t* inode;
ulint space;
ulint zip_size;
ulint page_no;
space = page_get_space_id(page_align(header));
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex)
|| mtr_memo_contains(mtr, fil_space_get_latch(space),
|| mtr_memo_contains(mtr, fil_space_get_latch(space, NULL),
MTR_MEMO_X_LOCK));
#endif /* UNIV_SYNC_DEBUG */
mtr_x_lock(fil_space_get_latch(space), mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), mtr);
inode = fseg_inode_get(header, mtr);
inode = fseg_inode_get(header, space, zip_size, mtr);
descr = fseg_get_first_extent(inode, mtr);
descr = fseg_get_first_extent(inode, space, zip_size, mtr);
if (descr != NULL) {
/* Free the extent held by the segment */
page = xdes_get_offset(descr);
fseg_free_extent(inode, space, page, mtr);
fseg_free_extent(inode, space, zip_size, page, mtr);
return(FALSE);
}
......@@ -3473,7 +3510,7 @@ fseg_free_step_not_header(
return(TRUE);
}
fseg_free_page_low(inode, space, page_no, mtr);
fseg_free_page_low(inode, space, zip_size, page_no, mtr);
return(FALSE);
}
......@@ -3486,6 +3523,8 @@ void
fseg_free(
/*======*/
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no,/* in: page number where the segment header is
placed */
ulint offset) /* in: byte offset of the segment header on that
......@@ -3502,7 +3541,7 @@ fseg_free(
for (;;) {
mtr_start(&mtr);
header = fut_get_ptr(space, addr, RW_X_LATCH, &mtr);
header = fut_get_ptr(space, zip_size, addr, RW_X_LATCH, &mtr);
finished = fseg_free_step(header, &mtr);
......@@ -3526,15 +3565,17 @@ fseg_get_first_extent(
/* out: the first extent descriptor, or NULL if
none */
fseg_inode_t* inode, /* in: segment inode */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
mtr_t* mtr) /* in: mtr */
{
fil_addr_t first;
ulint space;
xdes_t* descr;
ut_ad(inode && mtr);
space = page_get_space_id(page_align(inode));
ut_ad(space == page_get_space_id(page_align(inode)));
first = fil_addr_null;
......@@ -3555,7 +3596,7 @@ fseg_get_first_extent(
return(NULL);
}
descr = xdes_lst_get_descriptor(space, first, mtr);
descr = xdes_lst_get_descriptor(space, zip_size, first, mtr);
return(descr);
}
......@@ -3594,10 +3635,13 @@ fseg_validate_low(
node_addr = flst_get_first(inode + FSEG_FREE, mtr2);
while (!fil_addr_is_null(node_addr)) {
ulint zip_size;
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), &mtr);
descr = xdes_lst_get_descriptor(space, node_addr, &mtr);
descr = xdes_lst_get_descriptor(space, zip_size,
node_addr, &mtr);
ut_a(xdes_get_n_used(descr, &mtr) == 0);
ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG);
......@@ -3613,10 +3657,13 @@ fseg_validate_low(
node_addr = flst_get_first(inode + FSEG_NOT_FULL, mtr2);
while (!fil_addr_is_null(node_addr)) {
ulint zip_size;
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), &mtr);
descr = xdes_lst_get_descriptor(space, node_addr, &mtr);
descr = xdes_lst_get_descriptor(space, zip_size,
node_addr, &mtr);
ut_a(xdes_get_n_used(descr, &mtr) > 0);
ut_a(xdes_get_n_used(descr, &mtr) < FSP_EXTENT_SIZE);
......@@ -3635,10 +3682,13 @@ fseg_validate_low(
node_addr = flst_get_first(inode + FSEG_FULL, mtr2);
while (!fil_addr_is_null(node_addr)) {
ulint zip_size;
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), &mtr);
descr = xdes_lst_get_descriptor(space, node_addr, &mtr);
descr = xdes_lst_get_descriptor(space, zip_size,
node_addr, &mtr);
ut_a(xdes_get_n_used(descr, &mtr) == FSP_EXTENT_SIZE);
ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG);
......@@ -3667,12 +3717,13 @@ fseg_validate(
fseg_inode_t* inode;
ibool ret;
ulint space;
ulint zip_size;
space = page_get_space_id(page_align(header));
mtr_x_lock(fil_space_get_latch(space), mtr2);
mtr_x_lock(fil_space_get_latch(space, &zip_size), mtr2);
inode = fseg_inode_get(header, mtr2);
inode = fseg_inode_get(header, space, zip_size, mtr2);
ret = fseg_validate_low(inode, mtr2);
......@@ -3742,12 +3793,13 @@ fseg_print(
{
fseg_inode_t* inode;
ulint space;
ulint zip_size;
space = page_get_space_id(page_align(header));
mtr_x_lock(fil_space_get_latch(space), mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), mtr);
inode = fseg_inode_get(header, mtr);
inode = fseg_inode_get(header, space, zip_size, mtr);
fseg_print_low(inode, mtr);
}
......@@ -3764,6 +3816,7 @@ fsp_validate(
fsp_header_t* header;
fseg_inode_t* seg_inode;
page_t* seg_inode_page;
rw_lock_t* latch;
ulint size;
ulint zip_size;
ulint free_limit;
......@@ -3781,20 +3834,20 @@ fsp_validate(
ulint seg_inode_len_free;
ulint seg_inode_len_full;
latch = fil_space_get_latch(space, &zip_size);
ut_a(ut_is_2pow(zip_size));
ut_a(zip_size <= UNIV_PAGE_SIZE);
ut_a(!zip_size || zip_size >= PAGE_ZIP_MIN_SIZE);
/* Start first a mini-transaction mtr2 to lock out all other threads
from the fsp system */
mtr_start(&mtr2);
mtr_x_lock(fil_space_get_latch(space), &mtr2);
mtr_x_lock(latch, &mtr2);
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
header = fsp_get_space_header(space, &mtr);
mtr_x_lock(latch, &mtr);
zip_size = mach_read_from_4(FSP_PAGE_ZIP_SIZE + header);
ut_a(ut_is_2pow(zip_size));
ut_a(zip_size <= UNIV_PAGE_SIZE);
ut_a(!zip_size || zip_size >= PAGE_ZIP_MIN_SIZE);
header = fsp_get_space_header(space, zip_size, &mtr);
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, &mtr);
free_limit = mtr_read_ulint(header + FSP_FREE_LIMIT,
......@@ -3815,19 +3868,20 @@ fsp_validate(
/* Validate FSP_FREE list */
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
header = fsp_get_space_header(space, &mtr);
header = fsp_get_space_header(space, zip_size, &mtr);
node_addr = flst_get_first(header + FSP_FREE, &mtr);
mtr_commit(&mtr);
while (!fil_addr_is_null(node_addr)) {
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
descr_count++;
descr = xdes_lst_get_descriptor(space, node_addr, &mtr);
descr = xdes_lst_get_descriptor(space, zip_size,
node_addr, &mtr);
ut_a(xdes_get_n_used(descr, &mtr) == 0);
ut_a(xdes_get_state(descr, &mtr) == XDES_FREE);
......@@ -3838,19 +3892,20 @@ fsp_validate(
/* Validate FSP_FREE_FRAG list */
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
header = fsp_get_space_header(space, &mtr);
header = fsp_get_space_header(space, zip_size, &mtr);
node_addr = flst_get_first(header + FSP_FREE_FRAG, &mtr);
mtr_commit(&mtr);
while (!fil_addr_is_null(node_addr)) {
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
descr_count++;
descr = xdes_lst_get_descriptor(space, node_addr, &mtr);
descr = xdes_lst_get_descriptor(space, zip_size,
node_addr, &mtr);
ut_a(xdes_get_n_used(descr, &mtr) > 0);
ut_a(xdes_get_n_used(descr, &mtr) < FSP_EXTENT_SIZE);
......@@ -3864,19 +3919,20 @@ fsp_validate(
/* Validate FSP_FULL_FRAG list */
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
header = fsp_get_space_header(space, &mtr);
header = fsp_get_space_header(space, zip_size, &mtr);
node_addr = flst_get_first(header + FSP_FULL_FRAG, &mtr);
mtr_commit(&mtr);
while (!fil_addr_is_null(node_addr)) {
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
descr_count++;
descr = xdes_lst_get_descriptor(space, node_addr, &mtr);
descr = xdes_lst_get_descriptor(space, zip_size,
node_addr, &mtr);
ut_a(xdes_get_n_used(descr, &mtr) == FSP_EXTENT_SIZE);
ut_a(xdes_get_state(descr, &mtr) == XDES_FULL_FRAG);
......@@ -3887,9 +3943,9 @@ fsp_validate(
/* Validate segments */
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
header = fsp_get_space_header(space, &mtr);
header = fsp_get_space_header(space, zip_size, &mtr);
node_addr = flst_get_first(header + FSP_SEG_INODES_FULL, &mtr);
......@@ -3902,10 +3958,10 @@ fsp_validate(
n = 0;
do {
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
seg_inode_page = fut_get_ptr(
space, node_addr, RW_X_LATCH, &mtr)
space, zip_size, node_addr, RW_X_LATCH, &mtr)
- FSEG_INODE_PAGE_NODE;
seg_inode = fsp_seg_inode_page_get_nth_inode(
......@@ -3933,9 +3989,9 @@ fsp_validate(
}
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
header = fsp_get_space_header(space, &mtr);
header = fsp_get_space_header(space, zip_size, &mtr);
node_addr = flst_get_first(header + FSP_SEG_INODES_FREE, &mtr);
......@@ -3949,10 +4005,10 @@ fsp_validate(
do {
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
seg_inode_page = fut_get_ptr(
space, node_addr, RW_X_LATCH, &mtr)
space, zip_size, node_addr, RW_X_LATCH, &mtr)
- FSEG_INODE_PAGE_NODE;
seg_inode = fsp_seg_inode_page_get_nth_inode(
......@@ -4010,6 +4066,7 @@ fsp_print(
fsp_header_t* header;
fseg_inode_t* seg_inode;
page_t* seg_inode_page;
rw_lock_t* latch;
ulint zip_size;
ulint size;
ulint free_limit;
......@@ -4027,18 +4084,20 @@ fsp_print(
mtr_t mtr;
mtr_t mtr2;
latch = fil_space_get_latch(space, &zip_size);
/* Start first a mini-transaction mtr2 to lock out all other threads
from the fsp system */
mtr_start(&mtr2);
mtr_x_lock(fil_space_get_latch(space), &mtr2);
mtr_x_lock(latch, &mtr2);
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
header = fsp_get_space_header(space, &mtr);
header = fsp_get_space_header(space, zip_size, &mtr);
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, &mtr);
......@@ -4061,7 +4120,7 @@ fsp_print(
"not full frag extents %lu: used pages %lu,"
" full frag extents %lu\n"
"first seg id not used %lu %lu\n",
(long) space,
(ulong) space,
(ulong) size, (ulong) free_limit, (ulong) n_free,
(ulong) n_free_frag, (ulong) frag_n_used, (ulong) n_full_frag,
(ulong) seg_id_high, (ulong) seg_id_low);
......@@ -4071,10 +4130,9 @@ fsp_print(
/* Print segments */
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
header = fsp_get_space_header(space, &mtr);
zip_size = mach_read_from_4(header + FSP_PAGE_ZIP_SIZE);
header = fsp_get_space_header(space, zip_size, &mtr);
node_addr = flst_get_first(header + FSP_SEG_INODES_FULL, &mtr);
......@@ -4087,10 +4145,10 @@ fsp_print(
do {
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
seg_inode_page = fut_get_ptr(
space, node_addr, RW_X_LATCH, &mtr)
space, zip_size, node_addr, RW_X_LATCH, &mtr)
- FSEG_INODE_PAGE_NODE;
seg_inode = fsp_seg_inode_page_get_nth_inode(
......@@ -4111,9 +4169,9 @@ fsp_print(
}
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
header = fsp_get_space_header(space, &mtr);
header = fsp_get_space_header(space, zip_size, &mtr);
node_addr = flst_get_first(header + FSP_SEG_INODES_FREE, &mtr);
......@@ -4126,10 +4184,10 @@ fsp_print(
do {
mtr_start(&mtr);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(latch, &mtr);
seg_inode_page = fut_get_ptr(
space, node_addr, RW_X_LATCH, &mtr)
space, zip_size, node_addr, RW_X_LATCH, &mtr)
- FSEG_INODE_PAGE_NODE;
seg_inode = fsp_seg_inode_page_get_nth_inode(
......
......@@ -81,8 +81,10 @@ flst_add_last(
if (last_addr.page == node_addr.page) {
last_node = page_align(node) + last_addr.boffset;
} else {
last_node = fut_get_ptr(space, last_addr, RW_X_LATCH,
mtr);
ulint zip_size = fil_space_get_zip_size(space);
last_node = fut_get_ptr(space, zip_size, last_addr,
RW_X_LATCH, mtr);
}
flst_insert_after(base, last_node, node, mtr);
......@@ -122,7 +124,9 @@ flst_add_first(
if (first_addr.page == node_addr.page) {
first_node = page_align(node) + first_addr.boffset;
} else {
first_node = fut_get_ptr(space, first_addr,
ulint zip_size = fil_space_get_zip_size(space);
first_node = fut_get_ptr(space, zip_size, first_addr,
RW_X_LATCH, mtr);
}
......@@ -170,7 +174,10 @@ flst_insert_after(
if (!fil_addr_is_null(node3_addr)) {
/* Update prev field of node3 */
node3 = fut_get_ptr(space, node3_addr, RW_X_LATCH, mtr);
ulint zip_size = fil_space_get_zip_size(space);
node3 = fut_get_ptr(space, zip_size,
node3_addr, RW_X_LATCH, mtr);
flst_write_addr(node3 + FLST_PREV, node2_addr, mtr);
} else {
/* node1 was last in list: update last field in base */
......@@ -221,8 +228,10 @@ flst_insert_before(
flst_write_addr(node2 + FLST_NEXT, node3_addr, mtr);
if (!fil_addr_is_null(node1_addr)) {
ulint zip_size = fil_space_get_zip_size(space);
/* Update next field of node1 */
node1 = fut_get_ptr(space, node1_addr, RW_X_LATCH, mtr);
node1 = fut_get_ptr(space, zip_size, node1_addr,
RW_X_LATCH, mtr);
flst_write_addr(node1 + FLST_NEXT, node2_addr, mtr);
} else {
/* node3 was first in list: update first field in base */
......@@ -248,6 +257,7 @@ flst_remove(
mtr_t* mtr) /* in: mini-transaction handle */
{
ulint space;
ulint zip_size;
flst_node_t* node1;
fil_addr_t node1_addr;
fil_addr_t node2_addr;
......@@ -260,6 +270,7 @@ flst_remove(
ut_ad(mtr_memo_contains_page(mtr, node2, MTR_MEMO_PAGE_X_FIX));
buf_ptr_get_fsp_addr(node2, &space, &node2_addr);
zip_size = fil_space_get_zip_size(space);
node1_addr = flst_get_prev_addr(node2, mtr);
node3_addr = flst_get_next_addr(node2, mtr);
......@@ -272,8 +283,8 @@ flst_remove(
node1 = page_align(node2) + node1_addr.boffset;
} else {
node1 = fut_get_ptr(space, node1_addr, RW_X_LATCH,
mtr);
node1 = fut_get_ptr(space, zip_size,
node1_addr, RW_X_LATCH, mtr);
}
ut_ad(node1 != node2);
......@@ -291,8 +302,8 @@ flst_remove(
node3 = page_align(node2) + node3_addr.boffset;
} else {
node3 = fut_get_ptr(space, node3_addr, RW_X_LATCH,
mtr);
node3 = fut_get_ptr(space, zip_size,
node3_addr, RW_X_LATCH, mtr);
}
ut_ad(node2 != node3);
......@@ -347,8 +358,9 @@ flst_cut_end(
node1 = page_align(node2) + node1_addr.boffset;
} else {
node1 = fut_get_ptr(space, node1_addr, RW_X_LATCH,
mtr);
node1 = fut_get_ptr(space,
fil_space_get_zip_size(space),
node1_addr, RW_X_LATCH, mtr);
}
flst_write_addr(node1 + FLST_NEXT, fil_addr_null, mtr);
......@@ -418,6 +430,7 @@ flst_validate(
mtr_t* mtr1) /* in: mtr */
{
ulint space;
ulint zip_size;
const flst_node_t* node;
fil_addr_t node_addr;
fil_addr_t base_addr;
......@@ -437,6 +450,7 @@ flst_validate(
/* Find out the space id */
buf_ptr_get_fsp_addr(base, &space, &base_addr);
zip_size = fil_space_get_zip_size(space);
len = flst_get_len(base, mtr1);
node_addr = flst_get_first(base, mtr1);
......@@ -444,7 +458,8 @@ flst_validate(
for (i = 0; i < len; i++) {
mtr_start(&mtr2);
node = fut_get_ptr(space, node_addr, RW_X_LATCH, &mtr2);
node = fut_get_ptr(space, zip_size,
node_addr, RW_X_LATCH, &mtr2);
node_addr = flst_get_next_addr(node, &mtr2);
mtr_commit(&mtr2); /* Commit mtr2 each round to prevent buffer
......@@ -458,7 +473,8 @@ flst_validate(
for (i = 0; i < len; i++) {
mtr_start(&mtr2);
node = fut_get_ptr(space, node_addr, RW_X_LATCH, &mtr2);
node = fut_get_ptr(space, zip_size,
node_addr, RW_X_LATCH, &mtr2);
node_addr = flst_get_prev_addr(node, &mtr2);
mtr_commit(&mtr2); /* Commit mtr2 each round to prevent buffer
......
......@@ -281,7 +281,8 @@ ibuf_header_page_get(
ut_ad(!ibuf_inside());
block = buf_page_get(space, FSP_IBUF_HEADER_PAGE_NO, RW_X_LATCH, mtr);
block = buf_page_get(space, 0, FSP_IBUF_HEADER_PAGE_NO,
RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_IBUF_HEADER);
......@@ -308,7 +309,7 @@ ibuf_tree_root_get(
mtr_x_lock(dict_index_get_lock(data->index), mtr);
block = buf_page_get(space, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH,
block = buf_page_get(space, 0, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH,
mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
......@@ -482,7 +483,7 @@ ibuf_data_init_for_space(
mutex_enter(&ibuf_mutex);
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(fil_space_get_latch(space, NULL), &mtr);
header_page = ibuf_header_page_get(space, &mtr);
......@@ -496,7 +497,8 @@ ibuf_data_init_for_space(
{
buf_block_t* block = buf_page_get(
space, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH, &mtr);
space, 0, FSP_IBUF_TREE_ROOT_PAGE_NO,
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */
......@@ -767,7 +769,7 @@ ibuf_bitmap_get_map_page(
{
buf_block_t* block;
block = buf_page_get(space,
block = buf_page_get(space, zip_size,
ibuf_bitmap_page_no_calc(zip_size, page_no),
RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
......@@ -1661,12 +1663,11 @@ ibuf_add_free_page(
/* out: DB_SUCCESS, or DB_STRONG_FAIL
if no space left */
ulint space, /* in: space id */
ulint zip_size, /* in: compressed page size in
bytes, or 0 */
ibuf_data_t* ibuf_data) /* in: ibuf data for the space */
{
mtr_t mtr;
page_t* header_page;
ulint zip_size;
ulint page_no;
page_t* page;
page_t* root;
......@@ -1678,7 +1679,7 @@ ibuf_add_free_page(
/* Acquire the fsp latch before the ibuf header, obeying the latching
order */
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), &mtr);
header_page = ibuf_header_page_get(space, &mtr);
......@@ -1703,7 +1704,7 @@ ibuf_add_free_page(
{
buf_block_t* block = buf_page_get(
space, page_no, RW_X_LATCH, &mtr);
space, 0, page_no, RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_TREE_NODE_NEW);
#endif /* UNIV_SYNC_DEBUG */
......@@ -1750,13 +1751,12 @@ void
ibuf_remove_free_page(
/*==================*/
ulint space, /* in: space id */
ulint zip_size, /* in: compressed page size in
bytes, or 0 */
ibuf_data_t* ibuf_data) /* in: ibuf data for the space */
{
mtr_t mtr;
mtr_t mtr2;
page_t* header_page;
ulint zip_size;
ulint page_no;
page_t* page;
page_t* root;
......@@ -1768,7 +1768,7 @@ ibuf_remove_free_page(
/* Acquire the fsp latch before the ibuf header, obeying the latching
order */
mtr_x_lock(fil_space_get_latch(space), &mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), &mtr);
header_page = ibuf_header_page_get(space, &mtr);
......@@ -1832,7 +1832,7 @@ ibuf_remove_free_page(
{
buf_block_t* block = buf_page_get(
space, page_no, RW_X_LATCH, &mtr);
space, 0, page_no, RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */
......@@ -1874,8 +1874,7 @@ file segment, and the thread did not own the fsp latch before this call. */
void
ibuf_free_excess_pages(
/*===================*/
ulint space, /* in: space id */
ulint zip_size) /* in: compressed page size in bytes, or 0 */
ulint space) /* in: compressed page size in bytes, or 0 */
{
ibuf_data_t* ibuf_data;
ulint i;
......@@ -1888,9 +1887,9 @@ ibuf_free_excess_pages(
}
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(fil_space_get_latch(space), RW_LOCK_EX));
ut_ad(rw_lock_own(fil_space_get_latch(space, NULL), RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */
ut_ad(rw_lock_get_x_lock_count(fil_space_get_latch(space)) == 1);
ut_ad(rw_lock_get_x_lock_count(fil_space_get_latch(space, NULL)) == 1);
ut_ad(!ibuf_inside());
/* NOTE: We require that the thread did not own the latch before,
......@@ -1926,7 +1925,7 @@ ibuf_free_excess_pages(
mutex_exit(&ibuf_mutex);
ibuf_remove_free_page(space, zip_size, ibuf_data);
ibuf_remove_free_page(space, ibuf_data);
}
}
......@@ -2392,7 +2391,7 @@ ibuf_get_volume_buffered(
{
buf_block_t* block = buf_page_get(
0, prev_page_no, RW_X_LATCH, mtr);
0, 0, prev_page_no, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */
......@@ -2462,7 +2461,7 @@ count_later:
{
buf_block_t* block = buf_page_get(
0, next_page_no, RW_X_LATCH, mtr);
0, 0, next_page_no, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */
......@@ -2636,7 +2635,7 @@ ibuf_insert_low(
mutex_exit(&ibuf_pessimistic_insert_mutex);
err = ibuf_add_free_page(0, zip_size, ibuf_data);
err = ibuf_add_free_page(0, ibuf_data);
if (err == DB_STRONG_FAIL) {
......
......@@ -71,6 +71,8 @@ buf_block_t*
btr_block_get(
/*==========*/
ulint space, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no, /* in: page number */
ulint mode, /* in: latch mode */
mtr_t* mtr); /* in: mtr */
......@@ -81,6 +83,8 @@ page_t*
btr_page_get(
/*=========*/
ulint space, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no, /* in: page number */
ulint mode, /* in: latch mode */
mtr_t* mtr); /* in: mtr */
......@@ -178,6 +182,8 @@ btr_create(
FIL_NULL if did not succeed */
ulint type, /* in: type of the index */
ulint space, /* in: space where created */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
dulint index_id,/* in: index id */
dict_index_t* index, /* in: index */
mtr_t* mtr); /* in: mini-transaction handle */
......@@ -189,6 +195,8 @@ void
btr_free_but_not_root(
/*==================*/
ulint space, /* in: space where created */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint root_page_no); /* in: root page number */
/****************************************************************
Frees the B-tree root page. Other tree MUST already have been freed. */
......@@ -197,6 +205,8 @@ void
btr_free_root(
/*==========*/
ulint space, /* in: space where created */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint root_page_no, /* in: root page number */
mtr_t* mtr); /* in: a mini-transaction which has already
been started */
......
......@@ -20,13 +20,15 @@ buf_block_t*
btr_block_get(
/*==========*/
ulint space, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no, /* in: page number */
ulint mode, /* in: latch mode */
mtr_t* mtr) /* in: mtr */
{
buf_block_t* block;
block = buf_page_get(space, page_no, mode, mtr);
block = buf_page_get(space, zip_size, page_no, mode, mtr);
#ifdef UNIV_SYNC_DEBUG
if (mode != RW_NO_LATCH) {
......@@ -43,11 +45,14 @@ page_t*
btr_page_get(
/*=========*/
ulint space, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no, /* in: page number */
ulint mode, /* in: latch mode */
mtr_t* mtr) /* in: mtr */
{
return(buf_block_get_frame(btr_block_get(space, page_no, mode, mtr)));
return(buf_block_get_frame(btr_block_get(space, zip_size, page_no,
mode, mtr)));
}
/******************************************************************
......
......@@ -116,6 +116,8 @@ void
btr_search_drop_page_hash_when_freed(
/*=================================*/
ulint space, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no); /* in: page number */
/************************************************************************
Updates the page hash index when a single record is inserted on a page. */
......
......@@ -148,8 +148,8 @@ buf_frame_copy(
NOTE! The following macros should be used instead of buf_page_get_gen,
to improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed
in LA! */
#define buf_page_get(SP, OF, LA, MTR) buf_page_get_gen(\
SP, OF, LA, NULL,\
#define buf_page_get(SP, ZS, OF, LA, MTR) buf_page_get_gen(\
SP, ZS, OF, LA, NULL,\
BUF_GET, __FILE__, __LINE__, MTR)
/******************************************************************
Use these macros to bufferfix a page with no latching. Remember not to
......@@ -157,14 +157,14 @@ read the contents of the page unless you know it is safe. Do not modify
the contents of the page! We have separated this case, because it is
error-prone programming not to set a latch, and it should be used
with care. */
#define buf_page_get_with_no_latch(SP, OF, MTR) buf_page_get_gen(\
SP, OF, RW_NO_LATCH, NULL,\
#define buf_page_get_with_no_latch(SP, ZS, OF, MTR) buf_page_get_gen(\
SP, ZS, OF, RW_NO_LATCH, NULL,\
BUF_GET_NO_LATCH, __FILE__, __LINE__, MTR)
/******************************************************************
NOTE! The following macros should be used instead of buf_page_get_gen, to
improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed as LA! */
#define buf_page_get_nowait(SP, OF, LA, MTR) buf_page_get_gen(\
SP, OF, LA, NULL,\
#define buf_page_get_nowait(SP, ZS, OF, LA, MTR) buf_page_get_gen(\
SP, ZS, OF, LA, NULL,\
BUF_GET_NOWAIT, __FILE__, __LINE__, MTR)
/******************************************************************
NOTE! The following macros should be used instead of
......@@ -199,6 +199,8 @@ buf_page_get_release_on_io(
/* out: pointer to the block, or NULL
if not in buffer buf_pool */
ulint space, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint offset, /* in: offset of the page within space
in units of a page */
buf_block_t* guess, /* in: guessed frame or NULL */
......@@ -228,6 +230,8 @@ buf_page_get_gen(
/*=============*/
/* out: pointer to the block or NULL */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint offset, /* in: page number */
ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
buf_block_t* guess, /* in: guessed block or NULL */
......
......@@ -928,6 +928,8 @@ buf_page_get_release_on_io(
/* out: pointer to the block, or NULL
if not in buffer buf_pool */
ulint space, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint offset, /* in: offset of the page within space
in units of a page */
buf_block_t* guess, /* in: guessed block or NULL */
......@@ -938,7 +940,7 @@ buf_page_get_release_on_io(
{
buf_block_t* block;
block = buf_page_get_gen(space, offset, rw_latch, guess,
block = buf_page_get_gen(space, zip_size, offset, rw_latch, guess,
BUF_GET_IF_IN_POOL,
__FILE__, __LINE__,
mtr);
......@@ -952,7 +954,7 @@ buf_page_get_release_on_io(
mtr_rollback_to_savepoint(mtr, savepoint);
buf_page_get(space, offset, RW_S_LATCH, mtr);
buf_page_get(space, zip_size, offset, RW_S_LATCH, mtr);
/* When we get here, the page is in buffer, but we release
the latches again down to the savepoint, before returning */
......
......@@ -145,7 +145,9 @@ rw_lock_t*
fil_space_get_latch(
/*================*/
/* out: latch protecting storage allocation */
ulint id); /* in: space id */
ulint id, /* in: space id */
ulint* zip_size);/* out: compressed page size, or
0 for uncompressed tablespaces */
/***********************************************************************
Returns the type of a file space. */
......
......@@ -87,7 +87,7 @@ Reads the compressed page size from the first page of a tablespace. */
ulint
fsp_header_get_zip_size(
/*=====================*/
/*====================*/
/* out: compressed page size in bytes,
or 0 if uncompressed */
const page_t* page); /* in: first page of a tablespace */
......@@ -112,7 +112,6 @@ fsp_header_init(
/*============*/
ulint space, /* in: space id */
ulint size, /* in: current size in blocks */
ulint zip_size, /* in: compressed page size, or 0 */
mtr_t* mtr); /* in: mini-transaction handle */
/**************************************************************************
Increases the space size field of a space. */
......@@ -281,6 +280,8 @@ void
fseg_free(
/*======*/
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no,/* in: page number where the segment header is
placed */
ulint offset);/* in: byte offset of the segment header on that
......
......@@ -24,6 +24,8 @@ fut_get_ptr(
/* out: pointer to a byte in a frame; the file
page in the frame is bufferfixed and latched */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
fil_addr_t addr, /* in: file address */
ulint rw_latch, /* in: RW_S_LATCH, RW_X_LATCH */
mtr_t* mtr); /* in: mtr handle */
......
......@@ -18,6 +18,8 @@ fut_get_ptr(
/* out: pointer to a byte in a frame; the file
page in the frame is bufferfixed and latched */
ulint space, /* in: space id */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
fil_addr_t addr, /* in: file address */
ulint rw_latch, /* in: RW_S_LATCH, RW_X_LATCH */
mtr_t* mtr) /* in: mtr handle */
......@@ -28,7 +30,7 @@ fut_get_ptr(
ut_ad(addr.boffset < UNIV_PAGE_SIZE);
ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
block = buf_page_get(space, addr.page, rw_latch, mtr);
block = buf_page_get(space, zip_size, addr.page, rw_latch, mtr);
ptr = buf_block_get_frame(block) + addr.boffset;
#ifdef UNIV_SYNC_DEBUG
......
......@@ -176,8 +176,7 @@ file segment, and the thread did not own the fsp latch before this call. */
void
ibuf_free_excess_pages(
/*===================*/
ulint space, /* in: space id */
ulint zip_size); /* in: compressed page size in bytes, or 0 */
ulint space); /* in: space id */
/*************************************************************************
Makes an index insert to the insert buffer, instead of directly to the disk
page, if this is possible. Does not do insert if the index is clustered
......
......@@ -22,6 +22,8 @@ trx_rsegf_get(
/* out: rollback segment header, page
x-latched */
ulint space, /* in: space where placed */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no, /* in: page number of the header */
mtr_t* mtr); /* in: mtr */
/**********************************************************************
......@@ -33,6 +35,8 @@ trx_rsegf_get_new(
/* out: rollback segment header, page
x-latched */
ulint space, /* in: space where placed */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no, /* in: page number of the header */
mtr_t* mtr); /* in: mtr */
/*******************************************************************
......@@ -83,6 +87,8 @@ trx_rseg_header_create(
/* out: page number of the created segment,
FIL_NULL if fail */
ulint space, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint max_size, /* in: max size in pages */
ulint* slot_no, /* out: rseg id == slot number in trx sys */
mtr_t* mtr); /* in: mtr */
......@@ -126,6 +132,8 @@ struct trx_rseg_struct{
rseg mutex */
ulint space; /* space where the rollback segment is
header is placed */
ulint zip_size;/* in: compressed page size of space
in bytes, or 0 for uncompressed spaces */
ulint page_no;/* page number of the rollback segment
header */
ulint max_size;/* maximum allowed size in pages */
......
......@@ -17,13 +17,15 @@ trx_rsegf_get(
/* out: rollback segment header, page
x-latched */
ulint space, /* in: space where placed */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no, /* in: page number of the header */
mtr_t* mtr) /* in: mtr */
{
buf_block_t* block;
trx_rsegf_t* header;
block = buf_page_get(space, page_no, RW_X_LATCH, mtr);
block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_RSEG_HEADER);
#endif /* UNIV_SYNC_DEBUG */
......@@ -41,13 +43,15 @@ trx_rsegf_get_new(
/* out: rollback segment header, page
x-latched */
ulint space, /* in: space where placed */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no, /* in: page number of the header */
mtr_t* mtr) /* in: mtr */
{
buf_block_t* block;
trx_rsegf_t* header;
block = buf_page_get(space, page_no, RW_X_LATCH, mtr);
block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_RSEG_HEADER_NEW);
#endif /* UNIV_SYNC_DEBUG */
......
......@@ -100,7 +100,8 @@ trx_sysf_get(
ut_ad(mtr);
block = buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, RW_X_LATCH, mtr);
block = buf_page_get(TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO,
RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_TRX_SYS_HEADER);
#endif /* UNIV_SYNC_DEBUG */
......
......@@ -74,6 +74,8 @@ trx_undo_page_get(
/*==============*/
/* out: pointer to page x-latched */
ulint space, /* in: space where placed */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no, /* in: page number */
mtr_t* mtr); /* in: mtr */
/**********************************************************************
......@@ -84,6 +86,8 @@ trx_undo_page_get_s_latched(
/*========================*/
/* out: pointer to page s-latched */
ulint space, /* in: space where placed */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no, /* in: page number */
mtr_t* mtr); /* in: mtr */
/**********************************************************************
......@@ -163,6 +167,8 @@ trx_undo_get_first_rec(
/* out: undo log record, the page latched, NULL if
none */
ulint space, /* in: undo log header space */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no,/* in: undo log header page number */
ulint offset, /* in: undo log header offset on page */
ulint mode, /* in: latching mode: RW_S_LATCH or RW_X_LATCH */
......@@ -355,6 +361,8 @@ struct trx_undo_struct{
/*-----------------------------*/
ulint space; /* space id where the undo log
placed */
ulint zip_size; /* in: compressed page size of space
in bytes, or 0 for uncompressed */
ulint hdr_page_no; /* page number of the header page in
the undo log */
ulint hdr_offset; /* header offset of the undo log on the
......
......@@ -128,10 +128,13 @@ trx_undo_page_get(
/*==============*/
/* out: pointer to page x-latched */
ulint space, /* in: space where placed */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no, /* in: page number */
mtr_t* mtr) /* in: mtr */
{
buf_block_t* block = buf_page_get(space, page_no, RW_X_LATCH, mtr);
buf_block_t* block = buf_page_get(space, zip_size, page_no,
RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_TRX_UNDO_PAGE);
#endif /* UNIV_SYNC_DEBUG */
......@@ -147,10 +150,13 @@ trx_undo_page_get_s_latched(
/*========================*/
/* out: pointer to page s-latched */
ulint space, /* in: space where placed */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no, /* in: page number */
mtr_t* mtr) /* in: mtr */
{
buf_block_t* block = buf_page_get(space, page_no, RW_S_LATCH, mtr);
buf_block_t* block = buf_page_get(space, zip_size, page_no,
RW_S_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_TRX_UNDO_PAGE);
#endif /* UNIV_SYNC_DEBUG */
......
......@@ -4292,6 +4292,7 @@ lock_rec_print(
{
buf_block_t* block;
ulint space;
ulint zip_size;
ulint page_no;
ulint i;
mtr_t mtr;
......@@ -4306,6 +4307,7 @@ lock_rec_print(
ut_a(lock_get_type(lock) == LOCK_REC);
space = lock->un_member.rec_lock.space;
zip_size = fil_space_get_zip_size(space);
page_no = lock->un_member.rec_lock.page_no;
fprintf(file, "RECORD LOCKS space id %lu page no %lu n bits %lu ",
......@@ -4348,27 +4350,28 @@ lock_rec_print(
because we have the kernel mutex and ibuf operations would
break the latching order */
block = buf_page_get_gen(space, page_no, RW_NO_LATCH,
block = buf_page_get_gen(space, zip_size, page_no, RW_NO_LATCH,
NULL, BUF_GET_IF_IN_POOL,
__FILE__, __LINE__, &mtr);
if (block) {
block = buf_page_get_nowait(space, page_no, RW_S_LATCH, &mtr);
block = buf_page_get_nowait(space, zip_size,
page_no, RW_S_LATCH, &mtr);
if (!block) {
/* Let us try to get an X-latch. If the current thread
is holding an X-latch on the page, we cannot get an
S-latch. */
block = buf_page_get_nowait(space, page_no, RW_X_LATCH,
&mtr);
block = buf_page_get_nowait(space, zip_size, page_no,
RW_X_LATCH, &mtr);
}
}
if (block) {
#ifdef UNIV_SYNC_DEBUG
if (block) {
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
}
#endif /* UNIV_SYNC_DEBUG */
for (i = 0; i < lock_rec_get_n_bits(lock); i++) {
......@@ -4482,8 +4485,6 @@ lock_print_info_all_transactions(
FILE* file) /* in: file where to print */
{
lock_t* lock;
ulint space;
ulint page_no;
ibool load_page_first = TRUE;
ulint nth_trx = 0;
ulint nth_lock = 0;
......@@ -4590,16 +4591,18 @@ loop:
}
if (lock_get_type(lock) == LOCK_REC) {
space = lock->un_member.rec_lock.space;
page_no = lock->un_member.rec_lock.page_no;
if (load_page_first) {
ulint space = lock->un_member.rec_lock.space;
ulint zip_size= fil_space_get_zip_size(space);
ulint page_no = lock->un_member.rec_lock.page_no;
lock_mutex_exit_kernel();
innobase_mysql_end_print_arbitrary_thd();
mtr_start(&mtr);
buf_page_get_with_no_latch(space, page_no, &mtr);
buf_page_get_with_no_latch(space, zip_size,
page_no, &mtr);
mtr_commit(&mtr);
......@@ -4835,7 +4838,8 @@ lock_rec_validate_page(
mtr_start(&mtr);
block = buf_page_get(space, page_no, RW_X_LATCH, &mtr);
block = buf_page_get(space, fil_space_get_zip_size(space),
page_no, RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
......
......@@ -1469,8 +1469,9 @@ loop:
mtr_start(&mtr);
block = buf_page_get(space, page_no,
RW_X_LATCH, &mtr);
block = buf_page_get(
space, zip_size, page_no,
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(
block, SYNC_NO_ORDER_CHECK);
......
......@@ -445,7 +445,7 @@ skip_secondaries:
/* We assume in purge of externally stored fields
that the space id of the undo log record is 0! */
block = buf_page_get(0, page_no, RW_X_LATCH, &mtr);
block = buf_page_get(0, 0, page_no, RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_TRX_UNDO_PAGE);
#endif /* UNIV_SYNC_DEBUG */
......
......@@ -1415,7 +1415,7 @@ innobase_start_or_create_for_mysql(void)
if (create_new_db) {
mtr_start(&mtr);
fsp_header_init(0, sum_of_new_sizes, 0, &mtr);
fsp_header_init(0, sum_of_new_sizes, &mtr);
mtr_commit(&mtr);
......
......@@ -264,7 +264,8 @@ trx_purge_add_update_undo_to_history(
ut_ad(mutex_own(&(rseg->mutex)));
#endif /* UNIV_SYNC_DEBUG */
rseg_header = trx_rsegf_get(rseg->space, rseg->page_no, mtr);
rseg_header = trx_rsegf_get(rseg->space, rseg->zip_size,
rseg->page_no, mtr);
undo_header = undo_page + undo->hdr_offset;
seg_header = undo_page + TRX_UNDO_SEG_HDR;
......@@ -348,9 +349,11 @@ loop:
mtr_start(&mtr);
mutex_enter(&(rseg->mutex));
rseg_hdr = trx_rsegf_get(rseg->space, rseg->page_no, &mtr);
rseg_hdr = trx_rsegf_get(rseg->space, rseg->zip_size,
rseg->page_no, &mtr);
undo_page = trx_undo_page_get(rseg->space, hdr_addr.page, &mtr);
undo_page = trx_undo_page_get(rseg->space, rseg->zip_size,
hdr_addr.page, &mtr);
seg_hdr = undo_page + TRX_UNDO_SEG_HDR;
log_hdr = undo_page + hdr_addr.boffset;
......@@ -452,7 +455,8 @@ trx_purge_truncate_rseg_history(
mtr_start(&mtr);
mutex_enter(&(rseg->mutex));
rseg_hdr = trx_rsegf_get(rseg->space, rseg->page_no, &mtr);
rseg_hdr = trx_rsegf_get(rseg->space, rseg->zip_size,
rseg->page_no, &mtr);
hdr_addr = trx_purge_get_log_from_hist(
flst_get_last(rseg_hdr + TRX_RSEG_HISTORY, &mtr));
......@@ -466,7 +470,8 @@ loop:
return;
}
undo_page = trx_undo_page_get(rseg->space, hdr_addr.page, &mtr);
undo_page = trx_undo_page_get(rseg->space, rseg->zip_size,
hdr_addr.page, &mtr);
log_hdr = undo_page + hdr_addr.boffset;
......@@ -518,7 +523,8 @@ loop:
mtr_start(&mtr);
mutex_enter(&(rseg->mutex));
rseg_hdr = trx_rsegf_get(rseg->space, rseg->page_no, &mtr);
rseg_hdr = trx_rsegf_get(rseg->space, rseg->zip_size,
rseg->page_no, &mtr);
hdr_addr = prev_hdr_addr;
......@@ -624,7 +630,7 @@ trx_purge_rseg_get_next_history_log(
mtr_start(&mtr);
undo_page = trx_undo_page_get_s_latched(rseg->space,
undo_page = trx_undo_page_get_s_latched(rseg->space, rseg->zip_size,
rseg->last_page_no, &mtr);
log_hdr = undo_page + rseg->last_offset;
seg_hdr = undo_page + TRX_UNDO_SEG_HDR;
......@@ -676,7 +682,7 @@ trx_purge_rseg_get_next_history_log(
/* Read the trx number and del marks from the previous log header */
mtr_start(&mtr);
log_hdr = trx_undo_page_get_s_latched(rseg->space,
log_hdr = trx_undo_page_get_s_latched(rseg->space, rseg->zip_size,
prev_log_addr.page, &mtr)
+ prev_log_addr.boffset;
......@@ -711,6 +717,7 @@ trx_purge_choose_next_log(void)
trx_rseg_t* min_rseg;
dulint min_trx_no;
ulint space = 0; /* remove warning (??? bug ???) */
ulint zip_size = 0;
ulint page_no = 0; /* remove warning (??? bug ???) */
ulint offset = 0; /* remove warning (??? bug ???) */
mtr_t mtr;
......@@ -738,6 +745,7 @@ trx_purge_choose_next_log(void)
min_rseg = rseg;
min_trx_no = rseg->last_trx_no;
space = rseg->space;
zip_size = rseg->zip_size;
ut_a(space == 0); /* We assume in purge of
externally stored fields
that space id == 0 */
......@@ -763,7 +771,7 @@ trx_purge_choose_next_log(void)
rec = &trx_purge_dummy_rec;
} else {
rec = trx_undo_get_first_rec(space, page_no, offset,
rec = trx_undo_get_first_rec(space, zip_size, page_no, offset,
RW_S_LATCH, &mtr);
if (rec == NULL) {
/* Undo log empty */
......@@ -814,6 +822,7 @@ trx_purge_get_next_rec(
ulint offset;
ulint page_no;
ulint space;
ulint zip_size;
ulint type;
ulint cmpl_info;
mtr_t mtr;
......@@ -824,6 +833,7 @@ trx_purge_get_next_rec(
ut_ad(purge_sys->next_stored);
space = purge_sys->rseg->space;
zip_size = purge_sys->rseg->zip_size;
page_no = purge_sys->page_no;
offset = purge_sys->offset;
......@@ -842,7 +852,8 @@ trx_purge_get_next_rec(
mtr_start(&mtr);
undo_page = trx_undo_page_get_s_latched(space, page_no, &mtr);
undo_page = trx_undo_page_get_s_latched(space, zip_size,
page_no, &mtr);
rec = undo_page + offset;
rec2 = rec;
......@@ -893,7 +904,8 @@ trx_purge_get_next_rec(
mtr_start(&mtr);
undo_page = trx_undo_page_get_s_latched(space, page_no, &mtr);
undo_page = trx_undo_page_get_s_latched(space, zip_size,
page_no, &mtr);
rec = undo_page + offset;
} else {
......
......@@ -1094,7 +1094,8 @@ trx_undo_report_row_operation(
mtr_start(&mtr);
for (;;) {
undo_block = buf_page_get_gen(undo->space, page_no, RW_X_LATCH,
undo_block = buf_page_get_gen(undo->space, undo->zip_size,
page_no, RW_X_LATCH,
undo->guess_block, BUF_GET,
__FILE__, __LINE__, &mtr);
#ifdef UNIV_SYNC_DEBUG
......@@ -1203,7 +1204,8 @@ trx_undo_get_undo_rec_low(
mtr_start(&mtr);
undo_page = trx_undo_page_get_s_latched(rseg->space, page_no, &mtr);
undo_page = trx_undo_page_get_s_latched(rseg->space, rseg->zip_size,
page_no, &mtr);
undo_rec = trx_undo_rec_copy(undo_page + offset, heap);
......
......@@ -835,7 +835,7 @@ trx_roll_pop_top_rec(
ut_ad(mutex_own(&(trx->undo_mutex)));
#endif /* UNIV_SYNC_DEBUG */
undo_page = trx_undo_page_get_s_latched(undo->space,
undo_page = trx_undo_page_get_s_latched(undo->space, undo->zip_size,
undo->top_page_no, mtr);
offset = undo->top_offset;
......
......@@ -49,6 +49,8 @@ trx_rseg_header_create(
/* out: page number of the created segment,
FIL_NULL if fail */
ulint space, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint max_size, /* in: max size in pages */
ulint* slot_no, /* out: rseg id == slot number in trx sys */
mtr_t* mtr) /* in: mtr */
......@@ -63,7 +65,7 @@ trx_rseg_header_create(
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&kernel_mutex));
#endif /* UNIV_SYNC_DEBUG */
ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space),
ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space, NULL),
MTR_MEMO_X_LOCK));
sys_header = trx_sysf_get(mtr);
......@@ -75,7 +77,8 @@ trx_rseg_header_create(
}
/* Allocate a new file segment for the rollback segment */
block = fseg_create(space, 0, TRX_RSEG + TRX_RSEG_FSEG_HEADER, mtr);
block = fseg_create(space, 0,
TRX_RSEG + TRX_RSEG_FSEG_HEADER, mtr);
if (block == NULL) {
/* No space left */
......@@ -90,7 +93,7 @@ trx_rseg_header_create(
page_no = buf_block_get_page_no(block);
/* Get the rollback segment file page */
rsegf = trx_rsegf_get_new(space, page_no, mtr);
rsegf = trx_rsegf_get_new(space, zip_size, page_no, mtr);
/* Initialize max size field */
mlog_write_ulint(rsegf + TRX_RSEG_MAX_SIZE, max_size,
......@@ -128,6 +131,8 @@ trx_rseg_mem_create(
/* out, own: rollback segment object */
ulint id, /* in: rollback segment id */
ulint space, /* in: space where the segment placed */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no, /* in: page number of the segment header */
mtr_t* mtr) /* in: mtr */
{
......@@ -146,6 +151,7 @@ trx_rseg_mem_create(
rseg->id = id;
rseg->space = space;
rseg->zip_size = zip_size;
rseg->page_no = page_no;
mutex_create(&rseg->mutex, SYNC_RSEG);
......@@ -154,7 +160,7 @@ trx_rseg_mem_create(
trx_sys_set_nth_rseg(trx_sys, id, rseg);
rseg_header = trx_rsegf_get_new(space, page_no, mtr);
rseg_header = trx_rsegf_get_new(space, zip_size, page_no, mtr);
rseg->max_size = mtr_read_ulint(rseg_header + TRX_RSEG_MAX_SIZE,
MLOG_4BYTES, mtr);
......@@ -176,7 +182,8 @@ trx_rseg_mem_create(
rseg->last_page_no = node_addr.page;
rseg->last_offset = node_addr.boffset;
undo_log_hdr = trx_undo_page_get(rseg->space, node_addr.page,
undo_log_hdr = trx_undo_page_get(rseg->space, rseg->zip_size,
node_addr.page,
mtr) + node_addr.boffset;
rseg->last_trx_no = mtr_read_dulint(
......@@ -216,9 +223,13 @@ trx_rseg_list_and_array_init(
trx_sys_set_nth_rseg(trx_sys, i, NULL);
} else {
ulint zip_size;
space = trx_sysf_rseg_get_space(sys_header, i, mtr);
trx_rseg_mem_create(i, space, page_no, mtr);
zip_size = space ? fil_space_get_zip_size(space) : 0;
trx_rseg_mem_create(i, space, zip_size, page_no, mtr);
}
}
}
......@@ -236,13 +247,14 @@ trx_rseg_create(
ulint* id, /* out: rseg id */
mtr_t* mtr) /* in: mtr */
{
ulint zip_size;
ulint page_no;
trx_rseg_t* rseg;
mtr_x_lock(fil_space_get_latch(space), mtr);
mtr_x_lock(fil_space_get_latch(space, &zip_size), mtr);
mutex_enter(&kernel_mutex);
page_no = trx_rseg_header_create(space, max_size, id, mtr);
page_no = trx_rseg_header_create(space, zip_size, max_size, id, mtr);
if (page_no == FIL_NULL) {
......@@ -250,7 +262,7 @@ trx_rseg_create(
return(NULL);
}
rseg = trx_rseg_mem_create(*id, space, page_no, mtr);
rseg = trx_rseg_mem_create(*id, space, zip_size, page_no, mtr);
mutex_exit(&kernel_mutex);
......
......@@ -136,7 +136,8 @@ trx_sys_mark_upgraded_to_multiple_tablespaces(void)
mtr_start(&mtr);
block = buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, RW_X_LATCH, &mtr);
block = buf_page_get(TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO,
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
......@@ -181,7 +182,8 @@ trx_sys_create_doublewrite_buf(void)
start_again:
mtr_start(&mtr);
block = buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, RW_X_LATCH, &mtr);
block = buf_page_get(TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO,
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
......@@ -268,7 +270,7 @@ start_again:
the page position in the tablespace, then the page
has not been written to in doublewrite. */
new_block = buf_page_get(TRX_SYS_SPACE, page_no,
new_block = buf_page_get(TRX_SYS_SPACE, 0, page_no,
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(new_block,
......@@ -849,7 +851,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(fil_space_get_latch(TRX_SYS_SPACE), mtr);
mtr_x_lock(fil_space_get_latch(TRX_SYS_SPACE, NULL), mtr);
mutex_enter(&kernel_mutex);
/* Create the trx sys file block in a new allocated file segment */
......@@ -897,7 +899,7 @@ trx_sysf_create(
+ page - sys_header);
/* Create the first rollback segment in the SYSTEM tablespace */
page_no = trx_rseg_header_create(TRX_SYS_SPACE, ULINT_MAX, &slot_no,
page_no = trx_rseg_header_create(TRX_SYS_SPACE, 0, ULINT_MAX, &slot_no,
mtr);
ut_a(slot_no == TRX_SYS_SYSTEM_RSEG_ID);
ut_a(page_no != FIL_NULL);
......
......@@ -138,6 +138,8 @@ trx_undo_get_prev_rec_from_prev_page(
ulint offset, /* in: undo log header offset on page */
mtr_t* mtr) /* in: mtr */
{
ulint space;
ulint zip_size;
ulint prev_page_no;
page_t* prev_page;
page_t* undo_page;
......@@ -153,8 +155,11 @@ trx_undo_get_prev_rec_from_prev_page(
return(NULL);
}
prev_page = trx_undo_page_get_s_latched(
page_get_space_id(undo_page), prev_page_no, mtr);
space = page_get_space_id(undo_page);
zip_size = fil_space_get_zip_size(space);
prev_page = trx_undo_page_get_s_latched(space, zip_size,
prev_page_no, mtr);
return(trx_undo_page_get_last_rec(prev_page, page_no, offset));
}
......@@ -196,6 +201,9 @@ trx_undo_get_next_rec_from_next_page(
/*=================================*/
/* out: undo log record, the page latched, NULL if
none */
ulint space, /* in: undo log header space */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
page_t* undo_page, /* in: undo log page */
ulint page_no,/* in: undo log header page number */
ulint offset, /* in: undo log header offset on page */
......@@ -205,7 +213,6 @@ trx_undo_get_next_rec_from_next_page(
trx_ulogf_t* log_hdr;
ulint next_page_no;
page_t* next_page;
ulint space;
ulint next;
if (page_no == page_get_page_no(undo_page)) {
......@@ -219,8 +226,6 @@ trx_undo_get_next_rec_from_next_page(
}
}
space = page_get_space_id(undo_page);
next_page_no = flst_get_next_addr(undo_page + TRX_UNDO_PAGE_HDR
+ TRX_UNDO_PAGE_NODE, mtr)
.page;
......@@ -230,11 +235,12 @@ trx_undo_get_next_rec_from_next_page(
}
if (mode == RW_S_LATCH) {
next_page = trx_undo_page_get_s_latched(space, next_page_no,
mtr);
next_page = trx_undo_page_get_s_latched(space, zip_size,
next_page_no, mtr);
} else {
ut_ad(mode == RW_X_LATCH);
next_page = trx_undo_page_get(space, next_page_no, mtr);
next_page = trx_undo_page_get(space, zip_size,
next_page_no, mtr);
}
return(trx_undo_page_get_first_rec(next_page, page_no, offset));
......@@ -253,6 +259,8 @@ trx_undo_get_next_rec(
ulint offset, /* in: undo log header offset on page */
mtr_t* mtr) /* in: mtr */
{
ulint space;
ulint zip_size;
trx_undo_rec_t* next_rec;
next_rec = trx_undo_page_get_next_rec(rec, page_no, offset);
......@@ -261,7 +269,11 @@ trx_undo_get_next_rec(
return(next_rec);
}
return(trx_undo_get_next_rec_from_next_page(page_align(rec),
space = page_get_space_id(page_align(rec));
zip_size = fil_space_get_zip_size(space);
return(trx_undo_get_next_rec_from_next_page(space, zip_size,
page_align(rec),
page_no, offset,
RW_S_LATCH, mtr));
}
......@@ -275,6 +287,8 @@ trx_undo_get_first_rec(
/* out: undo log record, the page latched, NULL if
none */
ulint space, /* in: undo log header space */
ulint zip_size,/* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint page_no,/* in: undo log header page number */
ulint offset, /* in: undo log header offset on page */
ulint mode, /* in: latching mode: RW_S_LATCH or RW_X_LATCH */
......@@ -284,9 +298,10 @@ trx_undo_get_first_rec(
trx_undo_rec_t* rec;
if (mode == RW_S_LATCH) {
undo_page = trx_undo_page_get_s_latched(space, page_no, mtr);
undo_page = trx_undo_page_get_s_latched(space, zip_size,
page_no, mtr);
} else {
undo_page = trx_undo_page_get(space, page_no, mtr);
undo_page = trx_undo_page_get(space, zip_size, page_no, mtr);
}
rec = trx_undo_page_get_first_rec(undo_page, page_no, offset);
......@@ -295,7 +310,8 @@ trx_undo_get_first_rec(
return(rec);
}
return(trx_undo_get_next_rec_from_next_page(undo_page, page_no, offset,
return(trx_undo_get_next_rec_from_next_page(space, zip_size,
undo_page, page_no, offset,
mode, mtr));
}
......@@ -851,7 +867,8 @@ trx_undo_add_page(
return(FIL_NULL);
}
header_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr);
header_page = trx_undo_page_get(undo->space, undo->zip_size,
undo->hdr_page_no, mtr);
success = fsp_reserve_free_extents(&n_reserved, undo->space, 1,
FSP_UNDO, mtr);
......@@ -876,7 +893,8 @@ trx_undo_add_page(
undo->last_page_no = page_no;
new_page = trx_undo_page_get(undo->space, page_no, mtr);
new_page = trx_undo_page_get(undo->space, undo->zip_size,
page_no, mtr);
trx_undo_page_init(new_page, undo->type, mtr);
......@@ -911,6 +929,7 @@ trx_undo_free_page(
fil_addr_t last_addr;
trx_rsegf_t* rseg_header;
ulint hist_size;
ulint zip_size;
ut_a(hdr_page_no != page_no);
#ifdef UNIV_SYNC_DEBUG
......@@ -918,9 +937,11 @@ trx_undo_free_page(
ut_ad(mutex_own(&(rseg->mutex)));
#endif /* UNIV_SYNC_DEBUG */
undo_page = trx_undo_page_get(space, page_no, mtr);
zip_size = rseg->zip_size;
header_page = trx_undo_page_get(space, hdr_page_no, mtr);
undo_page = trx_undo_page_get(space, zip_size, page_no, mtr);
header_page = trx_undo_page_get(space, zip_size, 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);
......@@ -933,7 +954,8 @@ trx_undo_free_page(
rseg->curr_size--;
if (in_history) {
rseg_header = trx_rsegf_get(space, rseg->page_no, mtr);
rseg_header = trx_rsegf_get(space, zip_size,
rseg->page_no, mtr);
hist_size = mtr_read_ulint(rseg_header + TRX_RSEG_HISTORY_SIZE,
MLOG_4BYTES, mtr);
......@@ -982,6 +1004,8 @@ void
trx_undo_empty_header_page(
/*=======================*/
ulint space, /* in: space */
ulint zip_size, /* in: compressed page size in bytes
or 0 for uncompressed pages */
ulint hdr_page_no, /* in: header page number */
ulint hdr_offset, /* in: header offset */
mtr_t* mtr) /* in: mtr */
......@@ -990,7 +1014,7 @@ trx_undo_empty_header_page(
trx_ulogf_t* log_hdr;
ulint end;
header_page = trx_undo_page_get(space, hdr_page_no, mtr);
header_page = trx_undo_page_get(space, zip_size, hdr_page_no, mtr);
log_hdr = header_page + hdr_offset;
......@@ -1032,7 +1056,8 @@ trx_undo_truncate_end(
last_page_no = undo->last_page_no;
undo_page = trx_undo_page_get(undo->space, last_page_no, &mtr);
undo_page = trx_undo_page_get(undo->space, undo->zip_size,
last_page_no, &mtr);
rec = trx_undo_page_get_last_rec(undo_page, undo->hdr_page_no,
undo->hdr_offset);
......@@ -1109,7 +1134,8 @@ trx_undo_truncate_start(
loop:
mtr_start(&mtr);
rec = trx_undo_get_first_rec(space, hdr_page_no, hdr_offset,
rec = trx_undo_get_first_rec(space, rseg->zip_size,
hdr_page_no, hdr_offset,
RW_X_LATCH, &mtr);
if (rec == NULL) {
/* Already empty */
......@@ -1133,7 +1159,8 @@ loop:
page_no = page_get_page_no(undo_page);
if (page_no == hdr_page_no) {
trx_undo_empty_header_page(space, hdr_page_no, hdr_offset,
trx_undo_empty_header_page(space, rseg->zip_size,
hdr_page_no, hdr_offset,
&mtr);
} else {
trx_undo_free_page(rseg, TRUE, space, hdr_page_no,
......@@ -1160,10 +1187,9 @@ trx_undo_seg_free(
ibool finished;
mtr_t mtr;
finished = FALSE;
rseg = undo->rseg;
while (!finished) {
do {
mtr_start(&mtr);
#ifdef UNIV_SYNC_DEBUG
......@@ -1171,7 +1197,8 @@ trx_undo_seg_free(
#endif /* UNIV_SYNC_DEBUG */
mutex_enter(&(rseg->mutex));
seg_header = trx_undo_page_get(undo->space, undo->hdr_page_no,
seg_header = trx_undo_page_get(undo->space, undo->zip_size,
undo->hdr_page_no,
&mtr) + TRX_UNDO_SEG_HDR;
file_seg = seg_header + TRX_UNDO_FSEG_HEADER;
......@@ -1180,15 +1207,16 @@ trx_undo_seg_free(
if (finished) {
/* Update the rseg header */
rseg_header = trx_rsegf_get(rseg->space, rseg->page_no,
&mtr);
rseg_header = trx_rsegf_get(
rseg->space, rseg->zip_size, rseg->page_no,
&mtr);
trx_rsegf_set_nth_undo(rseg_header, undo->id, FIL_NULL,
&mtr);
}
mutex_exit(&(rseg->mutex));
mtr_commit(&mtr);
}
} while (!finished);
}
/*========== UNDO LOG MEMORY COPY INITIALIZATION =====================*/
......@@ -1228,7 +1256,8 @@ trx_undo_mem_create_at_db_start(
ut_error;
}
undo_page = trx_undo_page_get(rseg->space, page_no, mtr);
undo_page = trx_undo_page_get(rseg->space, rseg->zip_size,
page_no, mtr);
page_header = undo_page + TRX_UNDO_PAGE_HDR;
......@@ -1281,7 +1310,8 @@ trx_undo_mem_create_at_db_start(
undo->last_page_no = last_addr.page;
undo->top_page_no = last_addr.page;
last_page = trx_undo_page_get(rseg->space, undo->last_page_no, mtr);
last_page = trx_undo_page_get(rseg->space, rseg->zip_size,
undo->last_page_no, mtr);
rec = trx_undo_page_get_last_rec(last_page, page_no, offset);
......@@ -1341,7 +1371,8 @@ trx_undo_lists_init(
mtr_start(&mtr);
rseg_header = trx_rsegf_get_new(rseg->space, rseg->page_no, &mtr);
rseg_header = trx_rsegf_get_new(rseg->space, rseg->zip_size,
rseg->page_no, &mtr);
for (i = 0; i < TRX_RSEG_N_SLOTS; i++) {
page_no = trx_rsegf_get_nth_undo(rseg_header, i, &mtr);
......@@ -1362,8 +1393,9 @@ trx_undo_lists_init(
mtr_start(&mtr);
rseg_header = trx_rsegf_get(rseg->space,
rseg->page_no, &mtr);
rseg_header = trx_rsegf_get(
rseg->space, rseg->zip_size, rseg->page_no,
&mtr);
}
}
......@@ -1415,6 +1447,7 @@ trx_undo_mem_create(
undo->rseg = rseg;
undo->space = rseg->space;
undo->zip_size = rseg->zip_size;
undo->hdr_page_no = page_no;
undo->hdr_offset = offset;
undo->last_page_no = page_no;
......@@ -1514,7 +1547,8 @@ trx_undo_create(
rseg->curr_size++;
rseg_header = trx_rsegf_get(rseg->space, rseg->page_no, mtr);
rseg_header = trx_rsegf_get(rseg->space, rseg->zip_size, rseg->page_no,
mtr);
undo_page = trx_undo_seg_create(rseg, rseg_header, type, &id, mtr);
......@@ -1597,7 +1631,8 @@ trx_undo_reuse_cached(
ut_error;
}
undo_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr);
undo_page = trx_undo_page_get(undo->space, undo->zip_size,
undo->hdr_page_no, mtr);
if (type == TRX_UNDO_INSERT) {
offset = trx_undo_insert_header_reuse(undo_page, trx_id, mtr);
......@@ -1639,7 +1674,8 @@ trx_undo_mark_as_dict_operation(
ut_a(trx->dict_operation);
hdr_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr);
hdr_page = trx_undo_page_get(undo->space, undo->zip_size,
undo->hdr_page_no, mtr);
mlog_write_ulint(hdr_page + undo->hdr_offset
+ TRX_UNDO_DICT_TRANS,
......@@ -1745,7 +1781,8 @@ trx_undo_set_state_at_finish(
ut_error;
}
undo_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr);
undo_page = trx_undo_page_get(undo->space, undo->zip_size,
undo->hdr_page_no, mtr);
seg_hdr = undo_page + TRX_UNDO_SEG_HDR;
page_hdr = undo_page + TRX_UNDO_PAGE_HDR;
......@@ -1795,7 +1832,8 @@ trx_undo_set_state_at_prepare(
ut_error;
}
undo_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr);
undo_page = trx_undo_page_get(undo->space, undo->zip_size,
undo->hdr_page_no, mtr);
seg_hdr = undo_page + TRX_UNDO_SEG_HDR;
page_hdr = undo_page + TRX_UNDO_PAGE_HDR;
......
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