Commit 24d0bbf8 authored by marko's avatar marko

branches/zip: Remove some more buf_block_align() calls.

btr_search_build_page_hash_index(), fsp_parse_init_file_page(),
ibuf_parse_bitmap_init(): Replace page_t* with buf_block_t*.

buf_read_ibuf_merge_pages(): Add const qualifiers.  Retrieve zip_size.

ibuf_merge_or_delete_for_page(): Replace page_t* with buf_block_t*.
Add parameter zip_size.
parent 8919884f
......@@ -70,7 +70,7 @@ btr_search_build_page_hash_index(
/*=============================*/
dict_index_t* index, /* in: index for which to build, or NULL if
not known */
page_t* page, /* in: index page, s- or x-latched */
buf_block_t* block, /* in: index page, s- or x-latched */
ulint n_fields,/* in: hash this many full fields */
ulint n_bytes,/* in: hash this many bytes from the next
field */
......@@ -514,7 +514,7 @@ btr_search_info_update_slow(
params2 = params + btr_search_this_is_zero;
btr_search_build_page_hash_index(cursor->index,
block->frame,
block,
params2[0],
params2[1],
params2[2]);
......@@ -1096,14 +1096,14 @@ void
btr_search_build_page_hash_index(
/*=============================*/
dict_index_t* index, /* in: index for which to build */
page_t* page, /* in: index page, s- or x-latched */
buf_block_t* block, /* in: index page, s- or x-latched */
ulint n_fields,/* in: hash this many full fields */
ulint n_bytes,/* in: hash this many bytes from the next
field */
ibool left_side)/* in: hash for searches from left side? */
{
hash_table_t* table;
buf_block_t* block;
page_t* page;
rec_t* rec;
rec_t* next_rec;
ulint fold;
......@@ -1121,8 +1121,8 @@ btr_search_build_page_hash_index(
ut_ad(index);
block = buf_block_align(page);
table = btr_search_sys->hash_index;
page = buf_block_get_frame(block);
#ifdef UNIV_SYNC_DEBUG
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
......@@ -1173,8 +1173,7 @@ btr_search_build_page_hash_index(
index_id = btr_page_get_index_id(page);
rec = page_get_infimum_rec(page);
rec = page_rec_get_next(rec);
rec = page_rec_get_next(page_get_infimum_rec(page));
offsets = rec_get_offsets(rec, index, offsets,
n_fields + (n_bytes > 0), &heap);
......@@ -1327,7 +1326,7 @@ btr_search_move_or_delete_hash_entries(
ut_a(n_fields + n_bytes > 0);
btr_search_build_page_hash_index(index, new_page, n_fields,
btr_search_build_page_hash_index(index, new_block, n_fields,
n_bytes, left_side);
#if 1 /* TODO: safe to remove? */
ut_a(n_fields == block->curr_n_fields);
......@@ -1362,7 +1361,7 @@ btr_search_update_hash_on_delete(
rec = btr_cur_get_rec(cursor);
block = buf_block_align(rec);
block = btr_cur_get_block(cursor);
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
......@@ -1409,7 +1408,7 @@ btr_search_update_hash_node_on_insert(
rec = btr_cur_get_rec(cursor);
block = buf_block_align(rec);
block = btr_cur_get_block(cursor);
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
......@@ -1477,7 +1476,7 @@ btr_search_update_hash_on_insert(
rec = btr_cur_get_rec(cursor);
block = buf_block_align(rec);
block = btr_cur_get_block(cursor);
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
......
......@@ -1884,7 +1884,7 @@ buf_page_create(
/* Delete possible entries for the page from the insert buffer:
such can exist if the page belonged to an index which was dropped */
ibuf_merge_or_delete_for_page(NULL, space, offset, TRUE);
ibuf_merge_or_delete_for_page(NULL, space, offset, zip_size, TRUE);
/* Flush pages from the end of the LRU list if necessary */
buf_flush_free_margin();
......@@ -2065,8 +2065,8 @@ buf_page_io_complete(
if (!recv_no_ibuf_operations) {
ibuf_merge_or_delete_for_page(
block->frame, block->space, block->offset,
TRUE);
block, block->space, block->offset,
buf_block_get_zip_size(block), TRUE);
}
}
......
......@@ -98,7 +98,7 @@ buf_read_page_low(
}
if (ibuf_bitmap_page(zip_size, offset)
|| trx_sys_hdr_page(space, offset)) {
|| trx_sys_hdr_page(space, offset)) {
/* Trx sys header is so low in the latching order that we play
safe and do not leave the i/o-completion to an asynchronous
......@@ -612,20 +612,26 @@ a read-ahead function. */
void
buf_read_ibuf_merge_pages(
/*======================*/
ibool sync, /* in: TRUE if the caller wants this function
to wait for the highest address page to get
read in, before this function returns */
ulint* space_ids, /* in: array of space ids */
ib_longlong* space_versions,/* in: the spaces must have this version
number (timestamp), otherwise we discard the
read; we use this to cancel reads if
DISCARD + IMPORT may have changed the
tablespace size */
ulint* page_nos, /* in: array of page numbers to read, with the
highest page number the last in the array */
ulint n_stored) /* in: number of page numbers in the array */
ibool sync, /* in: TRUE if the caller
wants this function to wait
for the highest address page
to get read in, before this
function returns */
const ulint* space_ids, /* in: array of space ids */
const ib_longlong* space_versions,/* in: the spaces must have
this version number
(timestamp), otherwise we
discard the read; we use this
to cancel reads if DISCARD +
IMPORT may have changed the
tablespace size */
const ulint* page_nos, /* in: array of page numbers
to read, with the highest page
number the last in the
array */
ulint n_stored) /* in: number of elements
in the arrays */
{
ulint err;
ulint i;
ut_ad(!ibuf_inside());
......@@ -638,16 +644,27 @@ buf_read_ibuf_merge_pages(
}
for (i = 0; i < n_stored; i++) {
ulint zip_size = fil_space_get_zip_size(space_ids[i]);
ulint err;
if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) {
goto tablespace_deleted;
}
buf_read_page_low(&err, sync && (i + 1 == n_stored),
BUF_READ_ANY_PAGE, space_ids[i], 0,
space_versions[i], page_nos[i]);
BUF_READ_ANY_PAGE, space_ids[i],
zip_size, space_versions[i],
page_nos[i]);
if (err == DB_TABLESPACE_DELETED) {
if (UNIV_UNLIKELY(err == DB_TABLESPACE_DELETED)) {
tablespace_deleted:
/* We have deleted or are deleting the single-table
tablespace: remove the entries for that page */
ibuf_merge_or_delete_for_page(NULL, space_ids[i],
page_nos[i], FALSE);
page_nos[i],
zip_size, FALSE);
}
}
......
......@@ -869,15 +869,15 @@ Parses a redo log record of a file page init. */
byte*
fsp_parse_init_file_page(
/*=====================*/
/* out: end of log record or NULL */
byte* ptr, /* in: buffer */
byte* end_ptr __attribute__((unused)), /* in: buffer end */
page_t* page) /* in: page or NULL */
/* out: end of log record or NULL */
byte* ptr, /* in: buffer */
byte* end_ptr __attribute__((unused)), /* in: buffer end */
buf_block_t* block) /* in: block or NULL */
{
ut_ad(ptr && end_ptr);
if (page) {
fsp_init_file_page_low(buf_block_align(page));
if (block) {
fsp_init_file_page_low(block);
}
return(ptr);
......
......@@ -595,16 +595,16 @@ Parses a redo log record of an ibuf bitmap page init. */
byte*
ibuf_parse_bitmap_init(
/*===================*/
/* out: end of log record or NULL */
byte* ptr, /* in: buffer */
byte* end_ptr __attribute__((unused)), /* in: buffer end */
page_t* page, /* in: page or NULL */
mtr_t* mtr) /* in: mtr or NULL */
/* out: end of log record or NULL */
byte* ptr, /* in: buffer */
byte* end_ptr __attribute__((unused)), /* in: buffer end */
buf_block_t* block, /* in: block or NULL */
mtr_t* mtr) /* in: mtr or NULL */
{
ut_ad(ptr && end_ptr);
if (page) {
ibuf_bitmap_page_init(buf_block_align(page), mtr);
if (block) {
ibuf_bitmap_page_init(block, mtr);
}
return(ptr);
......@@ -3117,33 +3117,39 @@ belonged to an index which subsequently was dropped. */
void
ibuf_merge_or_delete_for_page(
/*==========================*/
page_t* page, /* in: if page has been read from disk, pointer to
the page x-latched, else NULL */
ulint space, /* in: space id of the index page */
ulint page_no,/* in: page number of the index page */
ibool update_ibuf_bitmap)/* in: normally this is set to TRUE, but if
we have deleted or are deleting the tablespace, then we
naturally do not want to update a non-existent bitmap
page */
buf_block_t* block, /* in: if page has been read from
disk, pointer to the page x-latched,
else NULL */
ulint space, /* in: space id of the index page */
ulint page_no,/* in: page number of the index page */
ulint zip_size,/* in: compressed page size in bytes,
or 0 */
ibool update_ibuf_bitmap)/* in: normally this is set
to TRUE, but if we have deleted or are
deleting the tablespace, then we
naturally do not want to update a
non-existent bitmap page */
{
mem_heap_t* heap;
btr_pcur_t pcur;
dtuple_t* entry;
dtuple_t* search_tuple;
rec_t* ibuf_rec;
buf_block_t* block = NULL;
page_t* bitmap_page;
ibuf_data_t* ibuf_data;
ulint n_inserts;
#ifdef UNIV_IBUF_DEBUG
ulint volume;
#endif
ulint zip_size = 0; /* remove bogus warning */
page_zip_des_t* page_zip = NULL;
ibool tablespace_being_deleted = FALSE;
ibool corruption_noticed = FALSE;
mtr_t mtr;
ut_ad(!block || buf_block_get_space(block) == space);
ut_ad(!block || buf_block_get_page_no(block) == page_no);
ut_ad(!block || buf_block_get_zip_size(block) == zip_size);
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
return;
......@@ -3161,7 +3167,6 @@ ibuf_merge_or_delete_for_page(
}
if (update_ibuf_bitmap) {
zip_size = fil_space_get_zip_size(space);
ut_a(ut_is_2pow(zip_size));
if (ibuf_fixed_addr_page(space, zip_size, page_no)
......@@ -3180,7 +3185,7 @@ ibuf_merge_or_delete_for_page(
/* Do not try to read the bitmap page from space;
just delete the ibuf records for the page */
page = NULL;
block = NULL;
update_ibuf_bitmap = FALSE;
} else {
mtr_start(&mtr);
......@@ -3202,10 +3207,7 @@ ibuf_merge_or_delete_for_page(
}
mtr_commit(&mtr);
}
} else if (page) {
zip_size = fil_space_get_zip_size(space);
ut_a(ut_is_2pow(zip_size));
} else if (block) {
if (ibuf_fixed_addr_page(space, zip_size, page_no)
|| fsp_descr_page(zip_size, page_no)) {
return;
......@@ -3229,17 +3231,17 @@ ibuf_merge_or_delete_for_page(
heap);
}
if (page) {
if (block) {
/* Move the ownership of the x-latch on the page to this OS
thread, so that we can acquire a second x-latch on it. This
is needed for the insert operations to the index page to pass
the debug checks. */
block = buf_block_align(page);
rw_lock_x_lock_move_ownership(&(block->lock));
page_zip = buf_block_get_page_zip(block);
if (UNIV_UNLIKELY(fil_page_get_type(page) != FIL_PAGE_INDEX)) {
if (UNIV_UNLIKELY(fil_page_get_type(buf_block_get_frame(block))
!= FIL_PAGE_INDEX)) {
corruption_noticed = TRUE;
......@@ -3258,7 +3260,7 @@ ibuf_merge_or_delete_for_page(
fputs("\nInnoDB: Dump of the page:\n", stderr);
buf_page_print(page, 0);
buf_page_print(buf_block_get_frame(block), 0);
fprintf(stderr,
"InnoDB: Error: corruption in the tablespace."
......@@ -3276,7 +3278,8 @@ ibuf_merge_or_delete_for_page(
"InnoDB: Please submit a detailed bug report"
" to http://bugs.mysql.com\n\n",
(ulong) page_no,
(ulong) fil_page_get_type(page));
(ulong)
fil_page_get_type(buf_block_get_frame(block)));
}
}
......@@ -3287,7 +3290,7 @@ ibuf_merge_or_delete_for_page(
loop:
mtr_start(&mtr);
if (page) {
if (block) {
ibool success = buf_page_get_known_nowait(RW_X_LATCH, block,
BUF_KEEP_OLD,
__FILE__, __LINE__,
......@@ -3316,9 +3319,10 @@ ibuf_merge_or_delete_for_page(
/* Check if the entry is for this index page */
if (ibuf_rec_get_page_no(ibuf_rec) != page_no
|| ibuf_rec_get_space(ibuf_rec) != space) {
if (page) {
page_header_reset_last_insert(page,
page_zip, &mtr);
if (block) {
page_header_reset_last_insert(
buf_block_get_frame(block),
page_zip, &mtr);
}
goto reset_bit;
}
......@@ -3327,7 +3331,7 @@ ibuf_merge_or_delete_for_page(
fputs("InnoDB: Discarding record\n ", stderr);
rec_print_old(stderr, ibuf_rec);
fputs("\n from the insert buffer!\n\n", stderr);
} else if (page) {
} else if (block) {
/* Now we have at pcur a record which should be
inserted to the index page; NOTE that the call below
copies pointers to fields in ibuf_rec, and we must
......@@ -3336,7 +3340,8 @@ ibuf_merge_or_delete_for_page(
dict_index_t* dummy_index;
dulint max_trx_id = page_get_max_trx_id(
page_align(ibuf_rec));
page_update_max_trx_id(page, page_zip, max_trx_id);
page_update_max_trx_id(buf_block_get_frame(block),
page_zip, max_trx_id);
entry = ibuf_build_entry_from_ibuf_rec(
ibuf_rec, heap, &dummy_index);
......@@ -3383,7 +3388,8 @@ ibuf_merge_or_delete_for_page(
zip_size, &mtr);
ibuf_bitmap_page_set_bits(bitmap_page, page_no, zip_size,
IBUF_BITMAP_BUFFERED, FALSE, &mtr);
if (page) {
if (block) {
page_t* page = buf_block_get_frame(block);
ulint old_bits = ibuf_bitmap_page_get_bits(
bitmap_page, page_no, zip_size,
IBUF_BITMAP_FREE, &mtr);
......
......@@ -65,18 +65,25 @@ a read-ahead function. */
void
buf_read_ibuf_merge_pages(
/*======================*/
ibool sync, /* in: TRUE if the caller wants this function
to wait for the highest address page to get
read in, before this function returns */
ulint* space_ids, /* in: array of space ids */
ib_longlong* space_versions,/* in: the spaces must have this version
number (timestamp), otherwise we discard the
read; we use this to cancel reads if
DISCARD + IMPORT may have changed the
tablespace size */
ulint* page_nos, /* in: array of page numbers to read, with the
highest page number the last in the array */
ulint n_stored); /* in: number of page numbers in the array */
ibool sync, /* in: TRUE if the caller
wants this function to wait
for the highest address page
to get read in, before this
function returns */
const ulint* space_ids, /* in: array of space ids */
const ib_longlong* space_versions,/* in: the spaces must have
this version number
(timestamp), otherwise we
discard the read; we use this
to cancel reads if DISCARD +
IMPORT may have changed the
tablespace size */
const ulint* page_nos, /* in: array of page numbers
to read, with the highest page
number the last in the
array */
ulint n_stored); /* in: number of elements
in the arrays */
/************************************************************************
Issues read requests for pages which recovery wants to read in. */
......
......@@ -327,10 +327,10 @@ Parses a redo log record of a file page init. */
byte*
fsp_parse_init_file_page(
/*=====================*/
/* out: end of log record or NULL */
byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */
page_t* page); /* in: page or NULL */
/* out: end of log record or NULL */
byte* ptr, /* in: buffer */
byte* end_ptr, /* in: buffer end */
buf_block_t* block); /* in: block or NULL */
/***********************************************************************
Validates the file space system and its segments. */
......
......@@ -200,14 +200,18 @@ belonged to an index which subsequently was dropped. */
void
ibuf_merge_or_delete_for_page(
/*==========================*/
page_t* page, /* in: if page has been read from disk, pointer to
the page x-latched, else NULL */
ulint space, /* in: space id of the index page */
ulint page_no,/* in: page number of the index page */
ibool update_ibuf_bitmap);/* in: normally this is set to TRUE, but if
we have deleted or are deleting the tablespace, then we
naturally do not want to update a non-existent bitmap
page */
buf_block_t* block, /* in: if page has been read from
disk, pointer to the page x-latched,
else NULL */
ulint space, /* in: space id of the index page */
ulint page_no,/* in: page number of the index page */
ulint zip_size,/* in: compressed page size in bytes,
or 0 */
ibool update_ibuf_bitmap);/* in: normally this is set
to TRUE, but if we have deleted or are
deleting the tablespace, then we
naturally do not want to update a
non-existent bitmap page */
/*************************************************************************
Deletes all entries in the insert buffer for a given space id. This is used
in DISCARD TABLESPACE and IMPORT TABLESPACE.
......@@ -251,11 +255,11 @@ Parses a redo log record of an ibuf bitmap page init. */
byte*
ibuf_parse_bitmap_init(
/*===================*/
/* out: end of log record or NULL */
byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */
page_t* page, /* in: page or NULL */
mtr_t* mtr); /* in: mtr or NULL */
/* out: end of log record or NULL */
byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */
buf_block_t* block, /* in: block or NULL */
mtr_t* mtr); /* in: mtr or NULL */
#ifdef UNIV_IBUF_DEBUG
/**********************************************************************
Gets the ibuf count for a given page. */
......
......@@ -930,10 +930,10 @@ recv_parse_or_apply_log_rec_body(
}
break;
case MLOG_IBUF_BITMAP_INIT:
ptr = ibuf_parse_bitmap_init(ptr, end_ptr, page, mtr);
ptr = ibuf_parse_bitmap_init(ptr, end_ptr, block, mtr);
break;
case MLOG_INIT_FILE_PAGE:
ptr = fsp_parse_init_file_page(ptr, end_ptr, page);
ptr = fsp_parse_init_file_page(ptr, end_ptr, block);
break;
case MLOG_WRITE_STRING:
ptr = mlog_parse_string(ptr, end_ptr, page, page_zip);
......
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