Skip to content

Commit 2e64513

Browse files
committed
MDEV-20612 preparation: Fewer calls to buf_page_t::id()
1 parent b19ec88 commit 2e64513

File tree

14 files changed

+598
-767
lines changed

14 files changed

+598
-767
lines changed

storage/innobase/btr/btr0btr.cc

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,8 @@ btr_root_raise_and_insert(
18731873
ut_a(!root_page_zip || page_zip_validate(root_page_zip, root->frame,
18741874
index));
18751875
#endif /* UNIV_ZIP_DEBUG */
1876+
const page_id_t root_id{root->page.id()};
1877+
18761878
#ifdef UNIV_BTR_DEBUG
18771879
if (!dict_index_is_ibuf(index)) {
18781880
ulint space = index->table->space_id;
@@ -1883,7 +1885,7 @@ btr_root_raise_and_insert(
18831885
+ root->frame, space));
18841886
}
18851887

1886-
ut_a(dict_index_get_page(index) == root->page.id().page_no());
1888+
ut_a(dict_index_get_page(index) == root_id.page_no());
18871889
#endif /* UNIV_BTR_DEBUG */
18881890
ut_ad(mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK
18891891
| MTR_MEMO_SX_LOCK));
@@ -1941,7 +1943,7 @@ btr_root_raise_and_insert(
19411943

19421944
/* Move any existing predicate locks */
19431945
if (dict_index_is_spatial(index)) {
1944-
lock_prdt_rec_move(new_block, root);
1946+
lock_prdt_rec_move(new_block, root_id);
19451947
} else {
19461948
btr_search_move_or_delete_hash_entries(
19471949
new_block, root);
@@ -1986,7 +1988,7 @@ btr_root_raise_and_insert(
19861988
root page: we cannot discard the lock structs on the root page */
19871989

19881990
if (!dict_table_is_locking_disabled(index->table)) {
1989-
lock_update_root_raise(new_block, root);
1991+
lock_update_root_raise(*new_block, root_id);
19901992
}
19911993

19921994
/* Create a memory heap where the node pointer is stored */
@@ -3342,22 +3344,22 @@ btr_lift_page_up(
33423344

33433345
/* Also update the predicate locks */
33443346
if (dict_index_is_spatial(index)) {
3345-
lock_prdt_rec_move(father_block, block);
3347+
lock_prdt_rec_move(father_block, block->page.id());
33463348
} else {
33473349
btr_search_move_or_delete_hash_entries(
33483350
father_block, block);
33493351
}
33503352
}
33513353

33523354
if (!dict_table_is_locking_disabled(index->table)) {
3355+
const page_id_t id{block->page.id()};
33533356
/* Free predicate page locks on the block */
3354-
if (dict_index_is_spatial(index)) {
3355-
lock_sys.mutex_lock();
3357+
if (index->is_spatial()) {
3358+
LockMutexGuard g;
33563359
lock_prdt_page_free_from_discard(
3357-
block, &lock_sys.prdt_page_hash);
3358-
lock_sys.mutex_unlock();
3360+
id, &lock_sys.prdt_page_hash);
33593361
}
3360-
lock_update_copy_and_discard(father_block, block);
3362+
lock_update_copy_and_discard(*father_block, id);
33613363
}
33623364

33633365
/* Go upward to root page, decrementing levels by one. */
@@ -3576,6 +3578,8 @@ btr_compress(
35763578
/* Remove the page from the level list */
35773579
btr_level_list_remove(*block, *index, mtr);
35783580

3581+
const page_id_t id{block->page.id()};
3582+
35793583
if (dict_index_is_spatial(index)) {
35803584
rec_t* my_rec = father_cursor.page_cur.rec;
35813585

@@ -3605,16 +3609,15 @@ btr_compress(
36053609
}
36063610

36073611
/* No GAP lock needs to be worrying about */
3608-
lock_sys.mutex_lock();
3612+
LockMutexGuard g;
36093613
lock_prdt_page_free_from_discard(
3610-
block, &lock_sys.prdt_page_hash);
3611-
lock_rec_free_all_from_discard_page(block);
3612-
lock_sys.mutex_unlock();
3614+
id, &lock_sys.prdt_page_hash);
3615+
lock_rec_free_all_from_discard_page(id);
36133616
} else {
36143617
btr_cur_node_ptr_delete(&father_cursor, mtr);
36153618
if (!dict_table_is_locking_disabled(index->table)) {
36163619
lock_update_merge_left(
3617-
merge_block, orig_pred, block);
3620+
*merge_block, orig_pred, id);
36183621
}
36193622
}
36203623

@@ -3758,11 +3761,11 @@ btr_compress(
37583761
offsets2, offsets,
37593762
merge_page, mtr);
37603763
}
3761-
lock_sys.mutex_lock();
3764+
const page_id_t id{block->page.id()};
3765+
LockMutexGuard g;
37623766
lock_prdt_page_free_from_discard(
3763-
block, &lock_sys.prdt_page_hash);
3764-
lock_rec_free_all_from_discard_page(block);
3765-
lock_sys.mutex_unlock();
3767+
id, &lock_sys.prdt_page_hash);
3768+
lock_rec_free_all_from_discard_page(id);
37663769
} else {
37673770

37683771
compressed = btr_cur_pessimistic_delete(&err, TRUE,

storage/innobase/btr/btr0cur.cc

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3311,15 +3311,15 @@ static void btr_cur_prefetch_siblings(const buf_block_t *block,
33113311
uint32_t prev= mach_read_from_4(my_assume_aligned<4>(page + FIL_PAGE_PREV));
33123312
uint32_t next= mach_read_from_4(my_assume_aligned<4>(page + FIL_PAGE_NEXT));
33133313

3314+
fil_space_t *space= index->table->space;
3315+
33143316
if (prev == FIL_NULL);
3315-
else if (index->table->space->acquire())
3316-
buf_read_page_background(index->table->space,
3317-
page_id_t(block->page.id().space(), prev),
3317+
else if (space->acquire())
3318+
buf_read_page_background(space, page_id_t(space->id, prev),
33183319
block->zip_size(), false);
33193320
if (next == FIL_NULL);
3320-
else if (index->table->space->acquire())
3321-
buf_read_page_background(index->table->space,
3322-
page_id_t(block->page.id().space(), next),
3321+
else if (space->acquire())
3322+
buf_read_page_background(space, page_id_t(space->id, next),
33233323
block->zip_size(), false);
33243324
}
33253325

@@ -3859,7 +3859,7 @@ btr_cur_upd_lock_and_undo(
38593859

38603860
if (!(flags & BTR_NO_LOCKING_FLAG)) {
38613861
err = lock_clust_rec_modify_check_and_lock(
3862-
flags, btr_cur_get_block(cursor), rec, index,
3862+
btr_cur_get_block(cursor), rec, index,
38633863
offsets, thr);
38643864
if (err != DB_SUCCESS) {
38653865
return(err);
@@ -4751,7 +4751,8 @@ btr_cur_optimistic_update(
47514751
btr_page_reorganize(page_cursor, index, mtr);
47524752
} else if (!dict_table_is_locking_disabled(index->table)) {
47534753
/* Restore the old explicit lock state on the record */
4754-
lock_rec_restore_from_page_infimum(block, rec, block);
4754+
lock_rec_restore_from_page_infimum(*block, rec,
4755+
block->page.id());
47554756
}
47564757

47574758
page_cur_move_to_next(page_cursor);
@@ -4805,10 +4806,11 @@ btr_cur_pess_upd_restore_supremum(
48054806

48064807
const uint32_t prev_page_no = btr_page_get_prev(page);
48074808

4808-
const page_id_t page_id(block->page.id().space(), prev_page_no);
4809+
const page_id_t block_id{block->page.id()};
4810+
const page_id_t prev_id(block_id.space(), prev_page_no);
48094811

48104812
ut_ad(prev_page_no != FIL_NULL);
4811-
prev_block = buf_page_get_with_no_latch(page_id, block->zip_size(),
4813+
prev_block = buf_page_get_with_no_latch(prev_id, block->zip_size(),
48124814
mtr);
48134815
#ifdef UNIV_BTR_DEBUG
48144816
ut_a(btr_page_get_next(prev_block->frame)
@@ -4818,7 +4820,7 @@ btr_cur_pess_upd_restore_supremum(
48184820
/* We must already have an x-latch on prev_block! */
48194821
ut_ad(mtr->memo_contains_flagged(prev_block, MTR_MEMO_PAGE_X_FIX));
48204822

4821-
lock_rec_reset_and_inherit_gap_locks(prev_block, block,
4823+
lock_rec_reset_and_inherit_gap_locks(*prev_block, block_id,
48224824
PAGE_HEAP_NO_SUPREMUM,
48234825
page_rec_get_heap_no(rec));
48244826
}
@@ -5106,7 +5108,8 @@ btr_cur_pessimistic_update(
51065108
}
51075109
} else if (!dict_table_is_locking_disabled(index->table)) {
51085110
lock_rec_restore_from_page_infimum(
5109-
btr_cur_get_block(cursor), rec, block);
5111+
*btr_cur_get_block(cursor), rec,
5112+
block->page.id());
51105113
}
51115114

51125115
if (!rec_get_deleted_flag(rec, rec_offs_comp(*offsets))
@@ -5251,7 +5254,7 @@ btr_cur_pessimistic_update(
52515254
rec = page_cursor->rec;
52525255
} else if (!dict_table_is_locking_disabled(index->table)) {
52535256
lock_rec_restore_from_page_infimum(
5254-
btr_cur_get_block(cursor), rec, block);
5257+
*btr_cur_get_block(cursor), rec, block->page.id());
52555258
}
52565259

52575260
/* If necessary, restore also the correct lock state for a new,
@@ -5351,14 +5354,6 @@ btr_cur_del_mark_set_clust_rec(
53515354
return(DB_SUCCESS);
53525355
}
53535356

5354-
err = lock_clust_rec_modify_check_and_lock(BTR_NO_LOCKING_FLAG, block,
5355-
rec, index, offsets, thr);
5356-
5357-
if (err != DB_SUCCESS) {
5358-
5359-
return(err);
5360-
}
5361-
53625357
err = trx_undo_report_row_operation(thr, index,
53635358
entry, NULL, 0, rec, offsets,
53645359
&roll_ptr);

storage/innobase/btr/btr0defragment.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ btr_defragment_merge_pages(
397397
if (n_recs_to_move == n_recs) {
398398
/* The whole page is merged with the previous page,
399399
free it. */
400-
lock_update_merge_left(to_block, orig_pred,
401-
from_block);
400+
const page_id_t from{from_block->page.id()};
401+
lock_update_merge_left(*to_block, orig_pred, from);
402402
btr_search_drop_page_hash_index(from_block);
403403
btr_level_list_remove(*from_block, *index, mtr);
404404
btr_page_get_father(index, from_block, mtr, &parent);

storage/innobase/gis/gis0rtree.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2018, 2020, MariaDB Corporation.
4+
Copyright (c) 2018, 2021, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -769,7 +769,7 @@ rtr_split_page_move_rec_list(
769769
ut_a(rec);
770770

771771
lock_rec_restore_from_page_infimum(
772-
new_block, rec, block);
772+
*new_block, rec, block->page.id());
773773

774774
page_cur_move_to_next(&new_page_cursor);
775775

storage/innobase/gis/gis0sea.cc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2016, 2018, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2017, 2020, MariaDB Corporation.
4+
Copyright (c) 2017, 2021, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -1164,7 +1164,7 @@ rtr_check_discard_page(
11641164
the root page */
11651165
buf_block_t* block) /*!< in: block of page to be discarded */
11661166
{
1167-
const ulint pageno = block->page.id().page_no();
1167+
const page_id_t id{block->page.id()};
11681168

11691169
mysql_mutex_lock(&index->rtr_track->rtr_active_mutex);
11701170

@@ -1175,8 +1175,8 @@ rtr_check_discard_page(
11751175

11761176
mysql_mutex_lock(&rtr_info->rtr_path_mutex);
11771177
for (const node_visit_t& node : *rtr_info->path) {
1178-
if (node.page_no == pageno) {
1179-
rtr_rebuild_path(rtr_info, pageno);
1178+
if (node.page_no == id.page_no()) {
1179+
rtr_rebuild_path(rtr_info, node.page_no);
11801180
break;
11811181
}
11821182
}
@@ -1185,8 +1185,7 @@ rtr_check_discard_page(
11851185
if (rtr_info->matches) {
11861186
mysql_mutex_lock(&rtr_info->matches->rtr_match_mutex);
11871187

1188-
if ((&rtr_info->matches->block)->page.id().page_no()
1189-
== pageno) {
1188+
if ((&rtr_info->matches->block)->page.id() == id) {
11901189
if (!rtr_info->matches->matched_recs->empty()) {
11911190
rtr_info->matches->matched_recs->clear();
11921191
}
@@ -1200,10 +1199,9 @@ rtr_check_discard_page(
12001199

12011200
mysql_mutex_unlock(&index->rtr_track->rtr_active_mutex);
12021201

1203-
lock_sys.mutex_lock();
1204-
lock_prdt_page_free_from_discard(block, &lock_sys.prdt_hash);
1205-
lock_prdt_page_free_from_discard(block, &lock_sys.prdt_page_hash);
1206-
lock_sys.mutex_unlock();
1202+
LockMutexGuard g;
1203+
lock_prdt_page_free_from_discard(id, &lock_sys.prdt_hash);
1204+
lock_prdt_page_free_from_discard(id, &lock_sys.prdt_page_hash);
12071205
}
12081206

12091207
/** Structure acts as functor to get the optimistic access of the page.

storage/innobase/ibuf/ibuf0ibuf.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3790,7 +3790,8 @@ ibuf_insert_to_index_page(
37903790
&page_cur);
37913791

37923792
ut_ad(!cmp_dtuple_rec(entry, rec, offsets));
3793-
lock_rec_restore_from_page_infimum(block, rec, block);
3793+
lock_rec_restore_from_page_infimum(*block, rec,
3794+
block->page.id());
37943795
} else {
37953796
offsets = NULL;
37963797
ibuf_insert_to_index_page_low(entry, block, index,

0 commit comments

Comments
 (0)