Commit 7593a465 authored by marko's avatar marko

branches/zip: Introduce the unsigned 64-bit data type ib_ulonglong

for log sequence numbers, to replace dulint.
parent f8da258f
...@@ -294,7 +294,7 @@ buf_page_is_corrupted( ...@@ -294,7 +294,7 @@ buf_page_is_corrupted(
ulint checksum_field; ulint checksum_field;
ulint old_checksum_field; ulint old_checksum_field;
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
dulint current_lsn; ib_ulonglong current_lsn;
#endif #endif
if (UNIV_LIKELY(!zip_size) if (UNIV_LIKELY(!zip_size)
&& memcmp(read_buf + FIL_PAGE_LSN + 4, && memcmp(read_buf + FIL_PAGE_LSN + 4,
...@@ -309,16 +309,14 @@ buf_page_is_corrupted( ...@@ -309,16 +309,14 @@ buf_page_is_corrupted(
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
if (recv_lsn_checks_on && log_peek_lsn(&current_lsn)) { if (recv_lsn_checks_on && log_peek_lsn(&current_lsn)) {
if (ut_dulint_cmp(current_lsn, if (current_lsn < mach_read_ull(read_buf + FIL_PAGE_LSN)) {
mach_read_from_8(read_buf + FIL_PAGE_LSN))
< 0) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Error: page %lu log sequence number" " InnoDB: Error: page %lu log sequence number"
" %lu %lu\n" " %llu\n"
"InnoDB: is in the future! Current system " "InnoDB: is in the future! Current system "
"log sequence number %lu %lu.\n" "log sequence number %llu.\n"
"InnoDB: Your database may be corrupt or " "InnoDB: Your database may be corrupt or "
"you may have copied the InnoDB\n" "you may have copied the InnoDB\n"
"InnoDB: tablespace but not the InnoDB " "InnoDB: tablespace but not the InnoDB "
...@@ -328,14 +326,8 @@ buf_page_is_corrupted( ...@@ -328,14 +326,8 @@ buf_page_is_corrupted(
"InnoDB: for more information.\n", "InnoDB: for more information.\n",
(ulong) mach_read_from_4(read_buf (ulong) mach_read_from_4(read_buf
+ FIL_PAGE_OFFSET), + FIL_PAGE_OFFSET),
(ulong) ut_dulint_get_high( mach_read_ull(read_buf + FIL_PAGE_LSN),
mach_read_from_8(read_buf current_lsn);
+ FIL_PAGE_LSN)),
(ulong) ut_dulint_get_low(
mach_read_from_8(read_buf
+ FIL_PAGE_LSN)),
(ulong) ut_dulint_get_high(current_lsn),
(ulong) ut_dulint_get_low(current_lsn));
} }
} }
#endif #endif
...@@ -608,7 +600,7 @@ buf_block_init( ...@@ -608,7 +600,7 @@ buf_block_init(
block->buf_fix_count = 0; block->buf_fix_count = 0;
block->io_fix = 0; block->io_fix = 0;
block->modify_clock = ut_dulint_zero; block->modify_clock = 0;
#ifdef UNIV_DEBUG_FILE_ACCESSES #ifdef UNIV_DEBUG_FILE_ACCESSES
block->file_page_was_freed = FALSE; block->file_page_was_freed = FALSE;
...@@ -1005,8 +997,7 @@ buf_pool_shrink( ...@@ -1005,8 +997,7 @@ buf_pool_shrink(
/* Avoid busy-waiting. */ /* Avoid busy-waiting. */
os_thread_sleep(100000); os_thread_sleep(100000);
} else if (dirty } else if (dirty
&& buf_flush_batch(BUF_FLUSH_LRU, dirty, && buf_flush_batch(BUF_FLUSH_LRU, dirty, 0)
ut_dulint_zero)
== ULINT_UNDEFINED) { == ULINT_UNDEFINED) {
buf_flush_wait_batch_end(BUF_FLUSH_LRU); buf_flush_wait_batch_end(BUF_FLUSH_LRU);
...@@ -1558,7 +1549,7 @@ buf_page_optimistic_get_func( ...@@ -1558,7 +1549,7 @@ buf_page_optimistic_get_func(
/* out: TRUE if success */ /* out: TRUE if success */
ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH */ ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH */
buf_block_t* block, /* in: guessed buffer block */ buf_block_t* block, /* in: guessed buffer block */
dulint modify_clock,/* in: modify clock value if mode is ib_ulonglong modify_clock,/* in: modify clock value if mode is
..._GUESS_ON_CLOCK */ ..._GUESS_ON_CLOCK */
const char* file, /* in: file name */ const char* file, /* in: file name */
ulint line, /* in: line where called */ ulint line, /* in: line where called */
...@@ -1622,7 +1613,7 @@ buf_page_optimistic_get_func( ...@@ -1622,7 +1613,7 @@ buf_page_optimistic_get_func(
return(FALSE); return(FALSE);
} }
if (UNIV_UNLIKELY(!UT_DULINT_EQ(modify_clock, block->modify_clock))) { if (UNIV_UNLIKELY(modify_clock != block->modify_clock)) {
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
...@@ -1791,8 +1782,8 @@ buf_page_init_for_backup_restore( ...@@ -1791,8 +1782,8 @@ buf_page_init_for_backup_restore(
block->freed_page_clock = 0; block->freed_page_clock = 0;
block->newest_modification = ut_dulint_zero; block->newest_modification = 0;
block->oldest_modification = ut_dulint_zero; block->oldest_modification = 0;
block->accessed = FALSE; block->accessed = FALSE;
block->buf_fix_count = 0; block->buf_fix_count = 0;
...@@ -1864,8 +1855,8 @@ buf_page_init( ...@@ -1864,8 +1855,8 @@ buf_page_init(
block->freed_page_clock = 0; block->freed_page_clock = 0;
block->newest_modification = ut_dulint_zero; block->newest_modification = 0;
block->oldest_modification = ut_dulint_zero; block->oldest_modification = 0;
block->accessed = FALSE; block->accessed = FALSE;
block->buf_fix_count = 0; block->buf_fix_count = 0;
...@@ -2438,8 +2429,7 @@ buf_validate(void) ...@@ -2438,8 +2429,7 @@ buf_validate(void)
n_lru++; n_lru++;
if (ut_dulint_cmp(block->oldest_modification, if (block->oldest_modification > 0) {
ut_dulint_zero) > 0) {
n_flush++; n_flush++;
} }
......
...@@ -58,9 +58,8 @@ buf_flush_insert_into_flush_list( ...@@ -58,9 +58,8 @@ buf_flush_insert_into_flush_list(
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL) ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL)
|| (ut_dulint_cmp((UT_LIST_GET_FIRST(buf_pool->flush_list)) || (UT_LIST_GET_FIRST(buf_pool->flush_list)->oldest_modification
->oldest_modification, <= block->oldest_modification));
block->oldest_modification) <= 0));
UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, block); UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, block);
...@@ -89,8 +88,7 @@ buf_flush_insert_sorted_into_flush_list( ...@@ -89,8 +88,7 @@ buf_flush_insert_sorted_into_flush_list(
prev_b = NULL; prev_b = NULL;
b = UT_LIST_GET_FIRST(buf_pool->flush_list); b = UT_LIST_GET_FIRST(buf_pool->flush_list);
while (b && (ut_dulint_cmp(b->oldest_modification, while (b && b->oldest_modification > block->oldest_modification) {
block->oldest_modification) > 0)) {
prev_b = b; prev_b = b;
b = UT_LIST_GET_NEXT(flush_list, b); b = UT_LIST_GET_NEXT(flush_list, b);
} }
...@@ -133,14 +131,9 @@ buf_flush_ready_for_replace( ...@@ -133,14 +131,9 @@ buf_flush_ready_for_replace(
return(FALSE); return(FALSE);
} }
if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0) return(block->oldest_modification == 0
|| (block->buf_fix_count != 0) && block->buf_fix_count == 0
|| (block->io_fix != 0)) { && block->io_fix == 0);
return(FALSE);
}
return(TRUE);
} }
/************************************************************************ /************************************************************************
...@@ -160,8 +153,7 @@ buf_flush_ready_for_flush( ...@@ -160,8 +153,7 @@ buf_flush_ready_for_flush(
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
if ((ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) > 0) if (block->oldest_modification != 0 && block->io_fix == 0) {
&& (block->io_fix == 0)) {
if (flush_type != BUF_FLUSH_LRU) { if (flush_type != BUF_FLUSH_LRU) {
return(TRUE); return(TRUE);
...@@ -193,7 +185,7 @@ buf_flush_write_complete( ...@@ -193,7 +185,7 @@ buf_flush_write_complete(
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
block->oldest_modification = ut_dulint_zero; block->oldest_modification = 0;
UT_LIST_REMOVE(flush_list, buf_pool->flush_list, block); UT_LIST_REMOVE(flush_list, buf_pool->flush_list, block);
...@@ -511,7 +503,8 @@ buf_flush_init_for_writing( ...@@ -511,7 +503,8 @@ buf_flush_init_for_writing(
/*=======================*/ /*=======================*/
byte* page, /* in/out: page */ byte* page, /* in/out: page */
void* page_zip_, /* in/out: compressed page, or NULL */ void* page_zip_, /* in/out: compressed page, or NULL */
dulint newest_lsn) /* in: newest modification lsn to the page */ ib_ulonglong newest_lsn) /* in: newest modification lsn
to the page */
{ {
if (page_zip_) { if (page_zip_) {
page_zip_des_t* page_zip = page_zip_; page_zip_des_t* page_zip = page_zip_;
...@@ -531,7 +524,7 @@ buf_flush_init_for_writing( ...@@ -531,7 +524,7 @@ buf_flush_init_for_writing(
/* fall through */ /* fall through */
case FIL_PAGE_TYPE_ZBLOB: case FIL_PAGE_TYPE_ZBLOB:
case FIL_PAGE_INDEX: case FIL_PAGE_INDEX:
mach_write_to_8(page_zip->data mach_write_ull(page_zip->data
+ FIL_PAGE_LSN, newest_lsn); + FIL_PAGE_LSN, newest_lsn);
memset(page_zip->data + FIL_PAGE_FILE_FLUSH_LSN, 0, 8); memset(page_zip->data + FIL_PAGE_FILE_FLUSH_LSN, 0, 8);
mach_write_to_4(page_zip->data mach_write_to_4(page_zip->data
...@@ -547,9 +540,9 @@ buf_flush_init_for_writing( ...@@ -547,9 +540,9 @@ buf_flush_init_for_writing(
} }
/* Write the newest modification lsn to the page header and trailer */ /* Write the newest modification lsn to the page header and trailer */
mach_write_to_8(page + FIL_PAGE_LSN, newest_lsn); mach_write_ull(page + FIL_PAGE_LSN, newest_lsn);
mach_write_to_8(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, mach_write_ull(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
newest_lsn); newest_lsn);
/* Store the new formula checksum */ /* Store the new formula checksum */
...@@ -589,7 +582,7 @@ buf_flush_write_block_low( ...@@ -589,7 +582,7 @@ buf_flush_write_block_low(
ut_a(ibuf_count_get(buf_block_get_space(block), ut_a(ibuf_count_get(buf_block_get_space(block),
buf_block_get_page_no(block)) == 0); buf_block_get_page_no(block)) == 0);
#endif #endif
ut_ad(!ut_dulint_is_zero(block->newest_modification)); ut_ad(block->newest_modification != 0);
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (!univ_log_debug_warned) { if (!univ_log_debug_warned) {
...@@ -876,19 +869,22 @@ the calling thread is not allowed to own any latches on pages! */ ...@@ -876,19 +869,22 @@ the calling thread is not allowed to own any latches on pages! */
ulint ulint
buf_flush_batch( buf_flush_batch(
/*============*/ /*============*/
/* out: number of blocks for which the write /* out: number of blocks for which the
request was queued; ULINT_UNDEFINED if there write request was queued;
was a flush of the same type already running */ ULINT_UNDEFINED if there was a flush
ulint flush_type, /* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST; if of the same type already running */
BUF_FLUSH_LIST, then the caller must not own ulint flush_type, /* in: BUF_FLUSH_LRU or
any latches on pages */ BUF_FLUSH_LIST; if BUF_FLUSH_LIST,
ulint min_n, /* in: wished minimum mumber of blocks flushed then the caller must not own any
(it is not guaranteed that the actual number latches on pages */
is that big, though) */ ulint min_n, /* in: wished minimum mumber of blocks
dulint lsn_limit) /* in the case BUF_FLUSH_LIST all blocks whose flushed (it is not guaranteed that the
oldest_modification is smaller than this actual number is that big, though) */
should be flushed (if their number does not ib_ulonglong lsn_limit) /* in the case BUF_FLUSH_LIST all
exceed min_n), otherwise ignored */ blocks whose oldest_modification is
smaller than this should be flushed
(if their number does not exceed
min_n), otherwise ignored */
{ {
buf_block_t* block; buf_block_t* block;
ulint page_count = 0; ulint page_count = 0;
...@@ -934,8 +930,7 @@ buf_flush_batch( ...@@ -934,8 +930,7 @@ buf_flush_batch(
block = UT_LIST_GET_LAST(buf_pool->flush_list); block = UT_LIST_GET_LAST(buf_pool->flush_list);
if (!block if (!block
|| (ut_dulint_cmp(block->oldest_modification, || block->oldest_modification >= lsn_limit) {
lsn_limit) >= 0)) {
/* We have flushed enough */ /* We have flushed enough */
break; break;
...@@ -1109,8 +1104,7 @@ buf_flush_free_margin(void) ...@@ -1109,8 +1104,7 @@ buf_flush_free_margin(void)
n_to_flush = buf_flush_LRU_recommendation(); n_to_flush = buf_flush_LRU_recommendation();
if (n_to_flush > 0) { if (n_to_flush > 0) {
n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush, n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush, 0);
ut_dulint_zero);
if (n_flushed == ULINT_UNDEFINED) { if (n_flushed == ULINT_UNDEFINED) {
/* There was an LRU type flush batch already running; /* There was an LRU type flush batch already running;
let us wait for it to end */ let us wait for it to end */
...@@ -1130,7 +1124,7 @@ buf_flush_validate_low(void) ...@@ -1130,7 +1124,7 @@ buf_flush_validate_low(void)
/* out: TRUE if ok */ /* out: TRUE if ok */
{ {
buf_block_t* block; buf_block_t* block;
dulint om; ib_ulonglong om;
UT_LIST_VALIDATE(flush_list, buf_block_t, buf_pool->flush_list); UT_LIST_VALIDATE(flush_list, buf_block_t, buf_pool->flush_list);
...@@ -1139,13 +1133,12 @@ buf_flush_validate_low(void) ...@@ -1139,13 +1133,12 @@ buf_flush_validate_low(void)
while (block != NULL) { while (block != NULL) {
om = block->oldest_modification; om = block->oldest_modification;
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
ut_a(ut_dulint_cmp(om, ut_dulint_zero) > 0); ut_a(om > 0);
block = UT_LIST_GET_NEXT(flush_list, block); block = UT_LIST_GET_NEXT(flush_list, block);
if (block) { if (block) {
ut_a(ut_dulint_cmp(om, block->oldest_modification) ut_a(om >= block->oldest_modification);
>= 0);
} }
} }
......
...@@ -129,12 +129,11 @@ buf_LRU_invalidate_tablespace( ...@@ -129,12 +129,11 @@ buf_LRU_invalidate_tablespace(
goto scan_again; goto scan_again;
} }
if (0 != ut_dulint_cmp(block->oldest_modification, if (block->oldest_modification != 0) {
ut_dulint_zero)) {
/* Remove from the flush list of modified /* Remove from the flush list of modified
blocks */ blocks */
block->oldest_modification = ut_dulint_zero; block->oldest_modification = 0;
UT_LIST_REMOVE(flush_list, UT_LIST_REMOVE(flush_list,
buf_pool->flush_list, block); buf_pool->flush_list, block);
...@@ -913,7 +912,7 @@ buf_LRU_block_remove_hashed_page( ...@@ -913,7 +912,7 @@ buf_LRU_block_remove_hashed_page(
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
ut_a(block->io_fix == 0); ut_a(block->io_fix == 0);
ut_a(block->buf_fix_count == 0); ut_a(block->buf_fix_count == 0);
ut_a(ut_dulint_cmp(block->oldest_modification, ut_dulint_zero) == 0); ut_a(block->oldest_modification == 0);
buf_LRU_remove_block(block); buf_LRU_remove_block(block);
...@@ -1091,7 +1090,7 @@ buf_LRU_print(void) ...@@ -1091,7 +1090,7 @@ buf_LRU_print(void)
fprintf(stderr, "io_fix %lu ", (ulong) block->io_fix); fprintf(stderr, "io_fix %lu ", (ulong) block->io_fix);
} }
if (!ut_dulint_is_zero(block->oldest_modification)) { if (block->oldest_modification) {
fputs("modif. ", stderr); fputs("modif. ", stderr);
} }
......
...@@ -1639,9 +1639,9 @@ static ...@@ -1639,9 +1639,9 @@ static
ulint ulint
fil_write_lsn_and_arch_no_to_file( fil_write_lsn_and_arch_no_to_file(
/*==============================*/ /*==============================*/
ulint sum_of_sizes, /* in: combined size of previous files in ulint sum_of_sizes, /* in: combined size of previous files
space, in database pages */ in space, in database pages */
dulint lsn, /* in: lsn to write */ ib_ulonglong lsn, /* in: lsn to write */
ulint arch_log_no /* in: archived log number to write */ ulint arch_log_no /* in: archived log number to write */
__attribute__((unused))) __attribute__((unused)))
{ {
...@@ -1653,7 +1653,7 @@ fil_write_lsn_and_arch_no_to_file( ...@@ -1653,7 +1653,7 @@ fil_write_lsn_and_arch_no_to_file(
fil_read(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL); fil_read(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
mach_write_to_8(buf + FIL_PAGE_FILE_FLUSH_LSN, lsn); mach_write_ull(buf + FIL_PAGE_FILE_FLUSH_LSN, lsn);
fil_write(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL); fil_write(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
...@@ -1668,8 +1668,9 @@ ulint ...@@ -1668,8 +1668,9 @@ ulint
fil_write_flushed_lsn_to_data_files( fil_write_flushed_lsn_to_data_files(
/*================================*/ /*================================*/
/* out: DB_SUCCESS or error number */ /* out: DB_SUCCESS or error number */
dulint lsn, /* in: lsn to write */ ib_ulonglong lsn, /* in: lsn to write */
ulint arch_log_no) /* in: latest archived log file number */ ulint arch_log_no) /* in: latest archived log
file number */
{ {
fil_space_t* space; fil_space_t* space;
fil_node_t* node; fil_node_t* node;
...@@ -1724,18 +1725,19 @@ void ...@@ -1724,18 +1725,19 @@ void
fil_read_flushed_lsn_and_arch_log_no( fil_read_flushed_lsn_and_arch_log_no(
/*=================================*/ /*=================================*/
os_file_t data_file, /* in: open data file */ os_file_t data_file, /* in: open data file */
ibool one_read_already, /* in: TRUE if min and max parameters ibool one_read_already, /* in: TRUE if min and max
below already contain sensible data */ parameters below already
contain sensible data */
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
ulint* min_arch_log_no, /* in/out: */ ulint* min_arch_log_no, /* in/out: */
ulint* max_arch_log_no, /* in/out: */ ulint* max_arch_log_no, /* in/out: */
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
dulint* min_flushed_lsn, /* in/out: */ ib_ulonglong* min_flushed_lsn, /* in/out: */
dulint* max_flushed_lsn) /* in/out: */ ib_ulonglong* max_flushed_lsn) /* in/out: */
{ {
byte* buf; byte* buf;
byte* buf2; byte* buf2;
dulint flushed_lsn; ib_ulonglong flushed_lsn;
buf2 = ut_malloc(2 * UNIV_PAGE_SIZE); buf2 = ut_malloc(2 * UNIV_PAGE_SIZE);
/* Align the memory for a possible read from a raw device */ /* Align the memory for a possible read from a raw device */
...@@ -1743,7 +1745,7 @@ fil_read_flushed_lsn_and_arch_log_no( ...@@ -1743,7 +1745,7 @@ fil_read_flushed_lsn_and_arch_log_no(
os_file_read(data_file, buf, 0, 0, UNIV_PAGE_SIZE); os_file_read(data_file, buf, 0, 0, UNIV_PAGE_SIZE);
flushed_lsn = mach_read_from_8(buf + FIL_PAGE_FILE_FLUSH_LSN); flushed_lsn = mach_read_ull(buf + FIL_PAGE_FILE_FLUSH_LSN);
ut_free(buf2); ut_free(buf2);
...@@ -1757,10 +1759,10 @@ fil_read_flushed_lsn_and_arch_log_no( ...@@ -1757,10 +1759,10 @@ fil_read_flushed_lsn_and_arch_log_no(
return; return;
} }
if (ut_dulint_cmp(*min_flushed_lsn, flushed_lsn) > 0) { if (*min_flushed_lsn > flushed_lsn) {
*min_flushed_lsn = flushed_lsn; *min_flushed_lsn = flushed_lsn;
} }
if (ut_dulint_cmp(*max_flushed_lsn, flushed_lsn) < 0) { if (*max_flushed_lsn < flushed_lsn) {
*max_flushed_lsn = flushed_lsn; *max_flushed_lsn = flushed_lsn;
} }
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
...@@ -2654,7 +2656,7 @@ fil_create_new_single_table_tablespace( ...@@ -2654,7 +2656,7 @@ fil_create_new_single_table_tablespace(
mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, *space_id); mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, *space_id);
if (!zip_size) { if (!zip_size) {
buf_flush_init_for_writing(page, NULL, ut_dulint_zero); buf_flush_init_for_writing(page, NULL, 0);
ret = os_file_write(path, file, page, 0, 0, UNIV_PAGE_SIZE); ret = os_file_write(path, file, page, 0, 0, UNIV_PAGE_SIZE);
} else { } else {
page_zip_des_t page_zip; page_zip_des_t page_zip;
...@@ -2662,7 +2664,7 @@ fil_create_new_single_table_tablespace( ...@@ -2662,7 +2664,7 @@ fil_create_new_single_table_tablespace(
page_zip.data = page + UNIV_PAGE_SIZE; page_zip.data = page + UNIV_PAGE_SIZE;
page_zip.state = page_zip.n_blobs page_zip.state = page_zip.n_blobs
= page_zip.m_start = page_zip.m_end = 0; = page_zip.m_start = page_zip.m_end = 0;
buf_flush_init_for_writing(page, &page_zip, ut_dulint_zero); buf_flush_init_for_writing(page, &page_zip, 0);
ret = os_file_write(path, file, page_zip.data, 0, 0, zip_size); ret = os_file_write(path, file, page_zip.data, 0, 0, zip_size);
} }
...@@ -2734,7 +2736,7 @@ fil_reset_too_high_lsns( ...@@ -2734,7 +2736,7 @@ fil_reset_too_high_lsns(
/* out: TRUE if success */ /* out: TRUE if success */
const char* name, /* in: table name in the const char* name, /* in: table name in the
databasename/tablename format */ databasename/tablename format */
dulint current_lsn) /* in: reset lsn's if the lsn stamped ib_ulonglong current_lsn) /* in: reset lsn's if the lsn stamped
to FIL_PAGE_FILE_FLUSH_LSN in the to FIL_PAGE_FILE_FLUSH_LSN in the
first page is too high */ first page is too high */
{ {
...@@ -2742,7 +2744,7 @@ fil_reset_too_high_lsns( ...@@ -2742,7 +2744,7 @@ fil_reset_too_high_lsns(
char* filepath; char* filepath;
byte* page; byte* page;
byte* buf2; byte* buf2;
dulint flush_lsn; ib_ulonglong flush_lsn;
ulint space_id; ulint space_id;
ib_longlong file_size; ib_longlong file_size;
ib_longlong offset; ib_longlong offset;
...@@ -2783,9 +2785,9 @@ fil_reset_too_high_lsns( ...@@ -2783,9 +2785,9 @@ fil_reset_too_high_lsns(
/* We have to read the file flush lsn from the header of the file */ /* We have to read the file flush lsn from the header of the file */
flush_lsn = mach_read_from_8(page + FIL_PAGE_FILE_FLUSH_LSN); flush_lsn = mach_read_ull(page + FIL_PAGE_FILE_FLUSH_LSN);
if (ut_dulint_cmp(current_lsn, flush_lsn) >= 0) { if (current_lsn >= flush_lsn) {
/* Ok */ /* Ok */
success = TRUE; success = TRUE;
...@@ -2799,14 +2801,11 @@ fil_reset_too_high_lsns( ...@@ -2799,14 +2801,11 @@ fil_reset_too_high_lsns(
fprintf(stderr, fprintf(stderr,
" InnoDB: Flush lsn in the tablespace file %lu" " InnoDB: Flush lsn in the tablespace file %lu"
" to be imported\n" " to be imported\n"
"InnoDB: is %lu %lu, which exceeds current" "InnoDB: is %llu, which exceeds current"
" system lsn %lu %lu.\n" " system lsn %llu.\n"
"InnoDB: We reset the lsn's in the file ", "InnoDB: We reset the lsn's in the file ",
(ulong) space_id, (ulong) space_id,
(ulong) ut_dulint_get_high(flush_lsn), flush_lsn, current_lsn);
(ulong) ut_dulint_get_low(flush_lsn),
(ulong) ut_dulint_get_high(current_lsn),
(ulong) ut_dulint_get_low(current_lsn));
ut_print_filename(stderr, filepath); ut_print_filename(stderr, filepath);
fputs(".\n", stderr); fputs(".\n", stderr);
...@@ -2828,8 +2827,7 @@ fil_reset_too_high_lsns( ...@@ -2828,8 +2827,7 @@ fil_reset_too_high_lsns(
goto func_exit; goto func_exit;
} }
if (ut_dulint_cmp(mach_read_from_8(page + FIL_PAGE_LSN), if (mach_read_ull(page + FIL_PAGE_LSN) > current_lsn) {
current_lsn) > 0) {
/* We have to reset the lsn */ /* We have to reset the lsn */
if (zip_size) { if (zip_size) {
...@@ -2868,7 +2866,7 @@ fil_reset_too_high_lsns( ...@@ -2868,7 +2866,7 @@ fil_reset_too_high_lsns(
goto func_exit; goto func_exit;
} }
mach_write_to_8(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn); mach_write_ull(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn);
success = os_file_write(filepath, file, page, 0, 0, success = os_file_write(filepath, file, page, 0, 0,
zip_size ? zip_size : UNIV_PAGE_SIZE); zip_size ? zip_size : UNIV_PAGE_SIZE);
......
...@@ -477,7 +477,7 @@ struct btr_pcur_struct{ ...@@ -477,7 +477,7 @@ struct btr_pcur_struct{
old_rec record */ old_rec record */
buf_block_t* block_when_stored;/* buffer block when the position was buf_block_t* block_when_stored;/* buffer block when the position was
stored */ stored */
dulint modify_clock; /* the modify clock value of the ib_ulonglong modify_clock; /* the modify clock value of the
buffer block when the cursor position buffer block when the cursor position
was stored */ was stored */
ulint pos_state; /* see TODO note below! ulint pos_state; /* see TODO note below!
......
...@@ -103,13 +103,13 @@ buf_pool_get_curr_size(void); ...@@ -103,13 +103,13 @@ buf_pool_get_curr_size(void);
/* out: size in bytes */ /* out: size in bytes */
/************************************************************************ /************************************************************************
Gets the smallest oldest_modification lsn for any page in the pool. Returns Gets the smallest oldest_modification lsn for any page in the pool. Returns
ut_dulint_zero if all modified pages have been flushed to disk. */ zero if all modified pages have been flushed to disk. */
UNIV_INLINE UNIV_INLINE
dulint ib_ulonglong
buf_pool_get_oldest_modification(void); buf_pool_get_oldest_modification(void);
/*==================================*/ /*==================================*/
/* out: oldest modification in pool, /* out: oldest modification in pool,
ut_dulint_zero if none */ zero if none */
/************************************************************************ /************************************************************************
Allocates a buffer block. */ Allocates a buffer block. */
UNIV_INLINE UNIV_INLINE
...@@ -173,7 +173,7 @@ buf_page_optimistic_get_func( ...@@ -173,7 +173,7 @@ buf_page_optimistic_get_func(
/* out: TRUE if success */ /* out: TRUE if success */
ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH */ ulint rw_latch,/* in: RW_S_LATCH, RW_X_LATCH */
buf_block_t* block, /* in: guessed block */ buf_block_t* block, /* in: guessed block */
dulint modify_clock,/* in: modify clock value if mode is ib_ulonglong modify_clock,/* in: modify clock value if mode is
..._GUESS_ON_CLOCK */ ..._GUESS_ON_CLOCK */
const char* file, /* in: file name */ const char* file, /* in: file name */
ulint line, /* in: line where called */ ulint line, /* in: line where called */
...@@ -364,7 +364,7 @@ buf_page_peek_if_search_hashed( ...@@ -364,7 +364,7 @@ buf_page_peek_if_search_hashed(
Gets the youngest modification log sequence number for a frame. Gets the youngest modification log sequence number for a frame.
Returns zero if not file page or no modification occurred yet. */ Returns zero if not file page or no modification occurred yet. */
UNIV_INLINE UNIV_INLINE
dulint ib_ulonglong
buf_block_get_newest_modification( buf_block_get_newest_modification(
/*==============================*/ /*==============================*/
/* out: newest modification to page */ /* out: newest modification to page */
...@@ -382,7 +382,7 @@ buf_block_modify_clock_inc( ...@@ -382,7 +382,7 @@ buf_block_modify_clock_inc(
Returns the value of the modify clock. The caller must have an s-lock Returns the value of the modify clock. The caller must have an s-lock
or x-lock on the block. */ or x-lock on the block. */
UNIV_INLINE UNIV_INLINE
dulint ib_ulonglong
buf_block_get_modify_clock( buf_block_get_modify_clock(
/*=======================*/ /*=======================*/
/* out: value */ /* out: value */
...@@ -755,11 +755,11 @@ struct buf_block_struct{ ...@@ -755,11 +755,11 @@ struct buf_block_struct{
UT_LIST_NODE_T(buf_block_t) flush_list; UT_LIST_NODE_T(buf_block_t) flush_list;
/* node of the modified, not yet /* node of the modified, not yet
flushed blocks list */ flushed blocks list */
dulint newest_modification; ib_ulonglong newest_modification;
/* log sequence number of the youngest /* log sequence number of the youngest
modification to this block, zero if modification to this block, zero if
not modified */ not modified */
dulint oldest_modification; ib_ulonglong oldest_modification;
/* log sequence number of the START of /* log sequence number of the START of
the log entry written of the oldest the log entry written of the oldest
modification to this block which has modification to this block which has
...@@ -812,7 +812,7 @@ struct buf_block_struct{ ...@@ -812,7 +812,7 @@ struct buf_block_struct{
protected by block->mutex */ protected by block->mutex */
/* 4. Optimistic search field */ /* 4. Optimistic search field */
dulint modify_clock; /* this clock is incremented every ib_ulonglong modify_clock; /* this clock is incremented every
time a pointer to a record on the time a pointer to a record on the
page may become obsolete; this is page may become obsolete; this is
used in the optimistic cursor used in the optimistic cursor
......
...@@ -39,23 +39,23 @@ buf_pool_get_curr_size(void) ...@@ -39,23 +39,23 @@ buf_pool_get_curr_size(void)
/************************************************************************ /************************************************************************
Gets the smallest oldest_modification lsn for any page in the pool. Returns Gets the smallest oldest_modification lsn for any page in the pool. Returns
ut_dulint_zero if all modified pages have been flushed to disk. */ zero if all modified pages have been flushed to disk. */
UNIV_INLINE UNIV_INLINE
dulint ib_ulonglong
buf_pool_get_oldest_modification(void) buf_pool_get_oldest_modification(void)
/*==================================*/ /*==================================*/
/* out: oldest modification in pool, /* out: oldest modification in pool,
ut_dulint_zero if none */ zero if none */
{ {
buf_block_t* block; buf_block_t* block;
dulint lsn; ib_ulonglong lsn;
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
block = UT_LIST_GET_LAST(buf_pool->flush_list); block = UT_LIST_GET_LAST(buf_pool->flush_list);
if (block == NULL) { if (block == NULL) {
lsn = ut_dulint_zero; lsn = 0;
} else { } else {
lsn = block->oldest_modification; lsn = block->oldest_modification;
} }
...@@ -408,23 +408,23 @@ buf_page_io_query( ...@@ -408,23 +408,23 @@ buf_page_io_query(
} }
/************************************************************************ /************************************************************************
Gets the youngest modification log sequence number for a frame. Returns zero Gets the youngest modification log sequence number for a frame.
if not a file page or no modification occurred yet. */ Returns zero if not file page or no modification occurred yet. */
UNIV_INLINE UNIV_INLINE
dulint ib_ulonglong
buf_block_get_newest_modification( buf_block_get_newest_modification(
/*==============================*/ /*==============================*/
/* out: newest modification to the page */ /* out: newest modification to page */
buf_block_t* block) /* in: block containing the page frame */ buf_block_t* block) /* in: block containing the page frame */
{ {
dulint lsn; ib_ulonglong lsn;
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
if (buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE) { if (buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE) {
lsn = block->newest_modification; lsn = block->newest_modification;
} else { } else {
lsn = ut_dulint_zero; lsn = 0;
} }
mutex_exit(&(buf_pool->mutex)); mutex_exit(&(buf_pool->mutex));
...@@ -447,14 +447,14 @@ buf_block_modify_clock_inc( ...@@ -447,14 +447,14 @@ buf_block_modify_clock_inc(
|| rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE)); || rw_lock_own(&(block->lock), RW_LOCK_EXCLUSIVE));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
UT_DULINT_INC(block->modify_clock); block->modify_clock++;
} }
/************************************************************************ /************************************************************************
Returns the value of the modify clock. The caller must have an s-lock Returns the value of the modify clock. The caller must have an s-lock
or x-lock on the block. */ or x-lock on the block. */
UNIV_INLINE UNIV_INLINE
dulint ib_ulonglong
buf_block_get_modify_clock( buf_block_get_modify_clock(
/*=======================*/ /*=======================*/
/* out: value */ /* out: value */
......
...@@ -35,8 +35,9 @@ void ...@@ -35,8 +35,9 @@ void
buf_flush_init_for_writing( buf_flush_init_for_writing(
/*=======================*/ /*=======================*/
byte* page, /* in/out: page */ byte* page, /* in/out: page */
void* page_zip, /* in/out: compressed page, or NULL */ void* page_zip_, /* in/out: compressed page, or NULL */
dulint newest_lsn); /* in: newest modification lsn to the page */ ib_ulonglong newest_lsn); /* in: newest modification lsn
to the page */
/*********************************************************************** /***********************************************************************
This utility flushes dirty blocks from the end of the LRU list or flush_list. This utility flushes dirty blocks from the end of the LRU list or flush_list.
NOTE 1: in the case of an LRU flush the calling thread may own latches to NOTE 1: in the case of an LRU flush the calling thread may own latches to
...@@ -47,18 +48,22 @@ the calling thread is not allowed to own any latches on pages! */ ...@@ -47,18 +48,22 @@ the calling thread is not allowed to own any latches on pages! */
ulint ulint
buf_flush_batch( buf_flush_batch(
/*============*/ /*============*/
/* out: number of blocks for which the write /* out: number of blocks for which the
request was queued */ write request was queued;
ulint flush_type, /* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST; if ULINT_UNDEFINED if there was a flush
BUF_FLUSH_LIST, then the caller must not own of the same type already running */
any latches on pages */ ulint flush_type, /* in: BUF_FLUSH_LRU or
ulint min_n, /* in: wished minimum mumber of blocks flushed BUF_FLUSH_LIST; if BUF_FLUSH_LIST,
(it is not guaranteed that the actual number then the caller must not own any
is that big, though) */ latches on pages */
dulint lsn_limit); /* in the case BUF_FLUSH_LIST all blocks whose ulint min_n, /* in: wished minimum mumber of blocks
oldest_modification is smaller than this flushed (it is not guaranteed that the
should be flushed (if their number does not actual number is that big, though) */
exceed min_n), otherwise ignored */ ib_ulonglong lsn_limit); /* in the case BUF_FLUSH_LIST all
blocks whose oldest_modification is
smaller than this should be flushed
(if their number does not exceed
min_n), otherwise ignored */
/********************************************************************** /**********************************************************************
Waits until a flush batch of the given type ends */ Waits until a flush batch of the given type ends */
...@@ -83,9 +88,9 @@ void ...@@ -83,9 +88,9 @@ void
buf_flush_recv_note_modification( buf_flush_recv_note_modification(
/*=============================*/ /*=============================*/
buf_block_t* block, /* in: block which is modified */ buf_block_t* block, /* in: block which is modified */
dulint start_lsn, /* in: start lsn of the first mtr in a ib_ulonglong start_lsn, /* in: start lsn of the first mtr in a
set of mtr's */ set of mtr's */
dulint end_lsn); /* in: end lsn of the last mtr in the ib_ulonglong end_lsn); /* in: end lsn of the last mtr in the
set of mtr's */ set of mtr's */
/************************************************************************ /************************************************************************
Returns TRUE if the file page block is immediately suitable for replacement, Returns TRUE if the file page block is immediately suitable for replacement,
......
...@@ -45,21 +45,20 @@ buf_flush_note_modification( ...@@ -45,21 +45,20 @@ buf_flush_note_modification(
ut_ad(mutex_own(&(buf_pool->mutex))); ut_ad(mutex_own(&(buf_pool->mutex)));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_ad(ut_dulint_cmp(mtr->start_lsn, ut_dulint_zero) != 0); ut_ad(mtr->start_lsn != 0);
ut_ad(mtr->modifications); ut_ad(mtr->modifications);
ut_ad(ut_dulint_cmp(block->newest_modification, mtr->end_lsn) <= 0); ut_ad(block->newest_modification <= mtr->end_lsn);
block->newest_modification = mtr->end_lsn; block->newest_modification = mtr->end_lsn;
if (ut_dulint_is_zero(block->oldest_modification)) { if (!block->oldest_modification) {
block->oldest_modification = mtr->start_lsn; block->oldest_modification = mtr->start_lsn;
ut_ad(!ut_dulint_is_zero(block->oldest_modification)); ut_ad(block->oldest_modification != 0);
buf_flush_insert_into_flush_list(block); buf_flush_insert_into_flush_list(block);
} else { } else {
ut_ad(ut_dulint_cmp(block->oldest_modification, ut_ad(block->oldest_modification <= mtr->start_lsn);
mtr->start_lsn) <= 0);
} }
++srv_buf_pool_write_requests; ++srv_buf_pool_write_requests;
...@@ -72,9 +71,9 @@ void ...@@ -72,9 +71,9 @@ void
buf_flush_recv_note_modification( buf_flush_recv_note_modification(
/*=============================*/ /*=============================*/
buf_block_t* block, /* in: block which is modified */ buf_block_t* block, /* in: block which is modified */
dulint start_lsn, /* in: start lsn of the first mtr in a ib_ulonglong start_lsn, /* in: start lsn of the first mtr in a
set of mtr's */ set of mtr's */
dulint end_lsn) /* in: end lsn of the last mtr in the ib_ulonglong end_lsn) /* in: end lsn of the last mtr in the
set of mtr's */ set of mtr's */
{ {
ut_ad(block); ut_ad(block);
...@@ -86,20 +85,19 @@ buf_flush_recv_note_modification( ...@@ -86,20 +85,19 @@ buf_flush_recv_note_modification(
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
ut_ad(ut_dulint_cmp(block->newest_modification, end_lsn) <= 0); ut_ad(block->newest_modification <= end_lsn);
block->newest_modification = end_lsn; block->newest_modification = end_lsn;
if (ut_dulint_is_zero(block->oldest_modification)) { if (!block->oldest_modification) {
block->oldest_modification = start_lsn; block->oldest_modification = start_lsn;
ut_ad(!ut_dulint_is_zero(block->oldest_modification)); ut_ad(block->oldest_modification != 0);
buf_flush_insert_sorted_into_flush_list(block); buf_flush_insert_sorted_into_flush_list(block);
} else { } else {
ut_ad(ut_dulint_cmp(block->oldest_modification, ut_ad(block->oldest_modification <= start_lsn);
start_lsn) <= 0);
} }
mutex_exit(&(buf_pool->mutex)); mutex_exit(&(buf_pool->mutex));
......
...@@ -286,8 +286,9 @@ ulint ...@@ -286,8 +286,9 @@ ulint
fil_write_flushed_lsn_to_data_files( fil_write_flushed_lsn_to_data_files(
/*================================*/ /*================================*/
/* out: DB_SUCCESS or error number */ /* out: DB_SUCCESS or error number */
dulint lsn, /* in: lsn to write */ ib_ulonglong lsn, /* in: lsn to write */
ulint arch_log_no); /* in: latest archived log file number */ ulint arch_log_no); /* in: latest archived log
file number */
/*********************************************************************** /***********************************************************************
Reads the flushed lsn and arch no fields from a data file at database Reads the flushed lsn and arch no fields from a data file at database
startup. */ startup. */
...@@ -296,14 +297,15 @@ void ...@@ -296,14 +297,15 @@ void
fil_read_flushed_lsn_and_arch_log_no( fil_read_flushed_lsn_and_arch_log_no(
/*=================================*/ /*=================================*/
os_file_t data_file, /* in: open data file */ os_file_t data_file, /* in: open data file */
ibool one_read_already, /* in: TRUE if min and max parameters ibool one_read_already, /* in: TRUE if min and max
below already contain sensible data */ parameters below already
contain sensible data */
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
ulint* min_arch_log_no, /* in/out: */ ulint* min_arch_log_no, /* in/out: */
ulint* max_arch_log_no, /* in/out: */ ulint* max_arch_log_no, /* in/out: */
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
dulint* min_flushed_lsn, /* in/out: */ ib_ulonglong* min_flushed_lsn, /* in/out: */
dulint* max_flushed_lsn); /* in/out: */ ib_ulonglong* max_flushed_lsn); /* in/out: */
/*********************************************************************** /***********************************************************************
Increments the count of pending insert buffer page merges, if space is not Increments the count of pending insert buffer page merges, if space is not
being deleted. */ being deleted. */
...@@ -455,7 +457,7 @@ fil_reset_too_high_lsns( ...@@ -455,7 +457,7 @@ fil_reset_too_high_lsns(
/* out: TRUE if success */ /* out: TRUE if success */
const char* name, /* in: table name in the const char* name, /* in: table name in the
databasename/tablename format */ databasename/tablename format */
dulint current_lsn); /* in: reset lsn's if the lsn stamped ib_ulonglong current_lsn); /* in: reset lsn's if the lsn stamped
to FIL_PAGE_FILE_FLUSH_LSN in the to FIL_PAGE_FILE_FLUSH_LSN in the
first page is too high */ first page is too high */
/************************************************************************ /************************************************************************
......
...@@ -48,9 +48,9 @@ log_calc_where_lsn_is( ...@@ -48,9 +48,9 @@ log_calc_where_lsn_is(
/* out: log file number */ /* out: log file number */
ib_longlong* log_file_offset, /* out: offset in that file ib_longlong* log_file_offset, /* out: offset in that file
(including the header) */ (including the header) */
dulint first_header_lsn, /* in: first log file start ib_ulonglong first_header_lsn, /* in: first log file start
lsn */ lsn */
dulint lsn, /* in: lsn whose position to ib_ulonglong lsn, /* in: lsn whose position to
determine */ determine */
ulint n_log_files, /* in: total number of log ulint n_log_files, /* in: total number of log
files */ files */
...@@ -60,14 +60,14 @@ log_calc_where_lsn_is( ...@@ -60,14 +60,14 @@ log_calc_where_lsn_is(
Writes to the log the string given. The log must be released with Writes to the log the string given. The log must be released with
log_release. */ log_release. */
UNIV_INLINE UNIV_INLINE
dulint ib_ulonglong
log_reserve_and_write_fast( log_reserve_and_write_fast(
/*=======================*/ /*=======================*/
/* out: end lsn of the log record, ut_dulint_zero if /* out: end lsn of the log record,
did not succeed */ zero if did not succeed */
byte* str, /* in: string */ byte* str, /* in: string */
ulint len, /* in: string length */ ulint len, /* in: string length */
dulint* start_lsn,/* out: start lsn of the log record */ ib_ulonglong* start_lsn,/* out: start lsn of the log record */
ibool* success);/* out: TRUE if success */ ibool* success);/* out: TRUE if success */
/*************************************************************************** /***************************************************************************
Releases the log mutex. */ Releases the log mutex. */
...@@ -88,7 +88,7 @@ log_free_check(void); ...@@ -88,7 +88,7 @@ log_free_check(void);
Opens the log for log_write_low. The log must be closed with log_close and Opens the log for log_write_low. The log must be closed with log_close and
released with log_release. */ released with log_release. */
dulint ib_ulonglong
log_reserve_and_open( log_reserve_and_open(
/*=================*/ /*=================*/
/* out: start lsn of the log record */ /* out: start lsn of the log record */
...@@ -105,14 +105,14 @@ log_write_low( ...@@ -105,14 +105,14 @@ log_write_low(
/**************************************************************** /****************************************************************
Closes the log. */ Closes the log. */
dulint ib_ulonglong
log_close(void); log_close(void);
/*===========*/ /*===========*/
/* out: lsn */ /* out: lsn */
/**************************************************************** /****************************************************************
Gets the current lsn. */ Gets the current lsn. */
UNIV_INLINE UNIV_INLINE
dulint ib_ulonglong
log_get_lsn(void); log_get_lsn(void);
/*=============*/ /*=============*/
/* out: current lsn */ /* out: current lsn */
...@@ -155,13 +155,14 @@ flush flushed enough. If not, starts a new flush. */ ...@@ -155,13 +155,14 @@ flush flushed enough. If not, starts a new flush. */
void void
log_write_up_to( log_write_up_to(
/*============*/ /*============*/
dulint lsn, /* in: log sequence number up to which the log should ib_ulonglong lsn, /* in: log sequence number up to which
be written, ut_dulint_max if not specified */ the log should be written,
IB_ULONGLONG_MAX if not specified */
ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP, ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
or LOG_WAIT_ALL_GROUPS */ or LOG_WAIT_ALL_GROUPS */
ibool flush_to_disk); ibool flush_to_disk);
/* in: TRUE if we want the written log also to be /* in: TRUE if we want the written log
flushed to disk */ also to be flushed to disk */
/******************************************************************** /********************************************************************
Does a syncronous flush of the log buffer to disk. */ Does a syncronous flush of the log buffer to disk. */
...@@ -176,13 +177,16 @@ be called if the calling thread owns no synchronization objects! */ ...@@ -176,13 +177,16 @@ be called if the calling thread owns no synchronization objects! */
ibool ibool
log_preflush_pool_modified_pages( log_preflush_pool_modified_pages(
/*=============================*/ /*=============================*/
/* out: FALSE if there was a flush batch of /* out: FALSE if there was a
the same type running, which means that we flush batch of the same type
could not start this flush batch */ running, which means that we
dulint new_oldest, /* in: try to advance oldest_modified_lsn could not start this flush
at least to this lsn */ batch */
ibool sync); /* in: TRUE if synchronous operation is ib_ulonglong new_oldest, /* in: try to advance
desired */ oldest_modified_lsn at least
to this lsn */
ibool sync); /* in: TRUE if synchronous
operation is desired */
/********************************************************** /**********************************************************
Makes a checkpoint. Note that this function does not flush dirty Makes a checkpoint. Note that this function does not flush dirty
blocks from the buffer pool: it only checks what is lsn of the oldest blocks from the buffer pool: it only checks what is lsn of the oldest
...@@ -208,15 +212,16 @@ Makes a checkpoint at a given lsn or later. */ ...@@ -208,15 +212,16 @@ Makes a checkpoint at a given lsn or later. */
void void
log_make_checkpoint_at( log_make_checkpoint_at(
/*===================*/ /*===================*/
dulint lsn, /* in: make a checkpoint at this or a later ib_ulonglong lsn, /* in: make a checkpoint at this or a
lsn, if ut_dulint_max, makes a checkpoint at later lsn, if IB_ULONGLONG_MAX, makes
the latest lsn */ a checkpoint at the latest lsn */
ibool write_always); /* in: the function normally checks if the ibool write_always); /* in: the function normally checks if
the new checkpoint would have a greater the the new checkpoint would have a
lsn than the previous one: if not, then no greater lsn than the previous one: if
physical write is done; by setting this not, then no physical write is done;
parameter TRUE, a physical write will always be by setting this parameter TRUE, a
made to log files */ physical write will always be made to
log files */
/******************************************************************** /********************************************************************
Makes a checkpoint at the latest lsn and writes it to first page of each Makes a checkpoint at the latest lsn and writes it to first page of each
data file in the database, so that we know that the file spaces contain data file in the database, so that we know that the file spaces contain
...@@ -257,9 +262,9 @@ backup restoration. */ ...@@ -257,9 +262,9 @@ backup restoration. */
void void
log_reset_first_header_and_checkpoint( log_reset_first_header_and_checkpoint(
/*==================================*/ /*==================================*/
byte* hdr_buf,/* in: buffer which will be written to the start byte* hdr_buf,/* in: buffer which will be written to the
of the first log file */ start of the first log file */
dulint start); /* in: lsn of the start of the first log file; ib_ulonglong start); /* in: lsn of the start of the first log file;
we pretend that there is a checkpoint at we pretend that there is a checkpoint at
start + LOG_BLOCK_HDR_SIZE */ start + LOG_BLOCK_HDR_SIZE */
/************************************************************************ /************************************************************************
...@@ -332,8 +337,8 @@ log_group_read_log_seg( ...@@ -332,8 +337,8 @@ log_group_read_log_seg(
ulint type, /* in: LOG_ARCHIVE or LOG_RECOVER */ ulint type, /* in: LOG_ARCHIVE or LOG_RECOVER */
byte* buf, /* in: buffer where to read */ byte* buf, /* in: buffer where to read */
log_group_t* group, /* in: log group */ log_group_t* group, /* in: log group */
dulint start_lsn, /* in: read area start */ ib_ulonglong start_lsn, /* in: read area start */
dulint end_lsn); /* in: read area end */ ib_ulonglong end_lsn); /* in: read area end */
/********************************************************** /**********************************************************
Writes a buffer to a log file group. */ Writes a buffer to a log file group. */
...@@ -344,7 +349,7 @@ log_group_write_buf( ...@@ -344,7 +349,7 @@ log_group_write_buf(
byte* buf, /* in: buffer */ byte* buf, /* in: buffer */
ulint len, /* in: buffer len; must be divisible ulint len, /* in: buffer len; must be divisible
by OS_FILE_LOG_BLOCK_SIZE */ by OS_FILE_LOG_BLOCK_SIZE */
dulint start_lsn, /* in: start lsn of the buffer; must ib_ulonglong start_lsn, /* in: start lsn of the buffer; must
be divisible by be divisible by
OS_FILE_LOG_BLOCK_SIZE */ OS_FILE_LOG_BLOCK_SIZE */
ulint new_data_offset);/* in: start offset of new data in ulint new_data_offset);/* in: start offset of new data in
...@@ -360,7 +365,7 @@ void ...@@ -360,7 +365,7 @@ void
log_group_set_fields( log_group_set_fields(
/*=================*/ /*=================*/
log_group_t* group, /* in: group */ log_group_t* group, /* in: group */
dulint lsn); /* in: lsn for which the values should be ib_ulonglong lsn); /* in: lsn for which the values should be
set */ set */
/********************************************************** /**********************************************************
Calculates the data capacity of a log group, when the log file headers are not Calculates the data capacity of a log group, when the log file headers are not
...@@ -462,7 +467,7 @@ void ...@@ -462,7 +467,7 @@ void
log_block_init( log_block_init(
/*===========*/ /*===========*/
byte* log_block, /* in: pointer to the log buffer */ byte* log_block, /* in: pointer to the log buffer */
dulint lsn); /* in: lsn within the log block */ ib_ulonglong lsn); /* in: lsn within the log block */
/**************************************************************** /****************************************************************
Initializes a log block in the log buffer in the old, < 3.23.52 format, where Initializes a log block in the log buffer in the old, < 3.23.52 format, where
there was no checksum yet. */ there was no checksum yet. */
...@@ -471,15 +476,16 @@ void ...@@ -471,15 +476,16 @@ void
log_block_init_in_old_format( log_block_init_in_old_format(
/*=========================*/ /*=========================*/
byte* log_block, /* in: pointer to the log buffer */ byte* log_block, /* in: pointer to the log buffer */
dulint lsn); /* in: lsn within the log block */ ib_ulonglong lsn); /* in: lsn within the log block */
/**************************************************************** /****************************************************************
Converts a lsn to a log block number. */ Converts a lsn to a log block number. */
UNIV_INLINE UNIV_INLINE
ulint ulint
log_block_convert_lsn_to_no( log_block_convert_lsn_to_no(
/*========================*/ /*========================*/
/* out: log block number, it is > 0 and <= 1G */ /* out: log block number,
dulint lsn); /* in: lsn of a byte within the block */ it is > 0 and <= 1G */
ib_ulonglong lsn); /* in: lsn of a byte within the block */
/********************************************************** /**********************************************************
Prints info of the log. */ Prints info of the log. */
...@@ -493,9 +499,9 @@ Peeks the current lsn. */ ...@@ -493,9 +499,9 @@ Peeks the current lsn. */
ibool ibool
log_peek_lsn( log_peek_lsn(
/*=========*/ /*=========*/
/* out: TRUE if success, FALSE if could not get the /* out: TRUE if success, FALSE if
log system mutex */ could not get the log system mutex */
dulint* lsn); /* out: if returns TRUE, current lsn is here */ ib_ulonglong* lsn); /* out: if returns TRUE, current lsn is here */
/************************************************************************** /**************************************************************************
Refreshes the statistics used to print per-second averages. */ Refreshes the statistics used to print per-second averages. */
...@@ -512,7 +518,7 @@ extern log_t* log_sys; ...@@ -512,7 +518,7 @@ extern log_t* log_sys;
#define LOG_RECOVER 98887331 #define LOG_RECOVER 98887331
/* The counting of lsn's starts from this value: this must be non-zero */ /* The counting of lsn's starts from this value: this must be non-zero */
#define LOG_START_LSN ut_dulint_create(0, 16 * OS_FILE_LOG_BLOCK_SIZE) #define LOG_START_LSN ((ib_ulonglong) (16 * OS_FILE_LOG_BLOCK_SIZE))
#define LOG_BUFFER_SIZE (srv_log_buffer_size * UNIV_PAGE_SIZE) #define LOG_BUFFER_SIZE (srv_log_buffer_size * UNIV_PAGE_SIZE)
#define LOG_ARCHIVE_BUF_SIZE (srv_log_buffer_size * UNIV_PAGE_SIZE / 4) #define LOG_ARCHIVE_BUF_SIZE (srv_log_buffer_size * UNIV_PAGE_SIZE / 4)
...@@ -645,7 +651,7 @@ struct log_group_struct{ ...@@ -645,7 +651,7 @@ struct log_group_struct{
group */ group */
ulint state; /* LOG_GROUP_OK or ulint state; /* LOG_GROUP_OK or
LOG_GROUP_CORRUPTED */ LOG_GROUP_CORRUPTED */
dulint lsn; /* lsn used to fix coordinates within ib_ulonglong lsn; /* lsn used to fix coordinates within
the log group */ the log group */
ulint lsn_offset; /* the offset of the above lsn */ ulint lsn_offset; /* the offset of the above lsn */
ulint n_pending_writes;/* number of currently pending flush ulint n_pending_writes;/* number of currently pending flush
...@@ -671,7 +677,7 @@ struct log_group_struct{ ...@@ -671,7 +677,7 @@ struct log_group_struct{
value to ..._file_no */ value to ..._file_no */
ulint next_archived_offset; /* like the preceding field */ ulint next_archived_offset; /* like the preceding field */
/*-----------------------------*/ /*-----------------------------*/
dulint scanned_lsn; /* used only in recovery: recovery scan ib_ulonglong scanned_lsn; /* used only in recovery: recovery scan
succeeded up to this lsn in this log succeeded up to this lsn in this log
group */ group */
byte* checkpoint_buf; /* checkpoint header is written from byte* checkpoint_buf; /* checkpoint header is written from
...@@ -684,7 +690,7 @@ struct log_struct{ ...@@ -684,7 +690,7 @@ struct log_struct{
byte pad[64]; /* padding to prevent other memory byte pad[64]; /* padding to prevent other memory
update hotspots from residing on the update hotspots from residing on the
same memory cache line */ same memory cache line */
dulint lsn; /* log sequence number */ ib_ulonglong lsn; /* log sequence number */
ulint buf_free; /* first free offset within the log ulint buf_free; /* first free offset within the log
buffer */ buffer */
mutex_t mutex; /* mutex protecting the log */ mutex_t mutex; /* mutex protecting the log */
...@@ -696,7 +702,7 @@ struct log_struct{ ...@@ -696,7 +702,7 @@ struct log_struct{
ulint old_buf_free; /* value of buf free when log was ulint old_buf_free; /* value of buf free when log was
last time opened; only in the debug last time opened; only in the debug
version */ version */
dulint old_lsn; /* value of lsn when log was last time ib_ulonglong old_lsn; /* value of lsn when log was last time
opened; only in the debug version */ opened; only in the debug version */
ibool check_flush_or_checkpoint; ibool check_flush_or_checkpoint;
/* this is set to TRUE when there may /* this is set to TRUE when there may
...@@ -719,27 +725,27 @@ struct log_struct{ ...@@ -719,27 +725,27 @@ struct log_struct{
later; this is advanced when a flush later; this is advanced when a flush
operation is completed to all the log operation is completed to all the log
groups */ groups */
dulint written_to_some_lsn; ib_ulonglong written_to_some_lsn;
/* first log sequence number not yet /* first log sequence number not yet
written to any log group; for this to written to any log group; for this to
be advanced, it is enough that the be advanced, it is enough that the
write i/o has been completed for any write i/o has been completed for any
one log group */ one log group */
dulint written_to_all_lsn; ib_ulonglong written_to_all_lsn;
/* first log sequence number not yet /* first log sequence number not yet
written to some log group; for this to written to some log group; for this to
be advanced, it is enough that the be advanced, it is enough that the
write i/o has been completed for all write i/o has been completed for all
log groups */ log groups */
dulint write_lsn; /* end lsn for the current running ib_ulonglong write_lsn; /* end lsn for the current running
write */ write */
ulint write_end_offset;/* the data in buffer has been written ulint write_end_offset;/* the data in buffer has been written
up to this offset when the current up to this offset when the current
write ends: this field will then write ends: this field will then
be copied to buf_next_to_write */ be copied to buf_next_to_write */
dulint current_flush_lsn;/* end lsn for the current running ib_ulonglong current_flush_lsn;/* end lsn for the current running
write + flush operation */ write + flush operation */
dulint flushed_to_disk_lsn; ib_ulonglong flushed_to_disk_lsn;
/* how far we have written the log /* how far we have written the log
AND flushed to disk */ AND flushed to disk */
ulint n_pending_writes;/* number of currently pending flushes ulint n_pending_writes;/* number of currently pending flushes
...@@ -802,11 +808,11 @@ struct log_struct{ ...@@ -802,11 +808,11 @@ struct log_struct{
/* this is the maximum allowed value /* this is the maximum allowed value
for lsn - last_checkpoint_lsn when a for lsn - last_checkpoint_lsn when a
new query step is started */ new query step is started */
dulint next_checkpoint_no; ib_ulonglong next_checkpoint_no;
/* next checkpoint number */ /* next checkpoint number */
dulint last_checkpoint_lsn; ib_ulonglong last_checkpoint_lsn;
/* latest checkpoint lsn */ /* latest checkpoint lsn */
dulint next_checkpoint_lsn; ib_ulonglong next_checkpoint_lsn;
/* next checkpoint lsn */ /* next checkpoint lsn */
ulint n_pending_checkpoint_writes; ulint n_pending_checkpoint_writes;
/* number of currently pending /* number of currently pending
...@@ -817,10 +823,11 @@ struct log_struct{ ...@@ -817,10 +823,11 @@ struct log_struct{
the log mutex */ the log mutex */
byte* checkpoint_buf; /* checkpoint header is read to this byte* checkpoint_buf; /* checkpoint header is read to this
buffer */ buffer */
#ifdef UNIV_LOG_ARCHIVE
/* Fields involved in archiving */ /* Fields involved in archiving */
ulint archiving_state;/* LOG_ARCH_ON, LOG_ARCH_STOPPING ulint archiving_state;/* LOG_ARCH_ON, LOG_ARCH_STOPPING
LOG_ARCH_STOPPED, LOG_ARCH_OFF */ LOG_ARCH_STOPPED, LOG_ARCH_OFF */
dulint archived_lsn; /* archiving has advanced to this ib_ulonglong archived_lsn; /* archiving has advanced to this
lsn */ lsn */
ulint max_archived_lsn_age_async; ulint max_archived_lsn_age_async;
/* recommended maximum age of /* recommended maximum age of
...@@ -829,7 +836,7 @@ struct log_struct{ ...@@ -829,7 +836,7 @@ struct log_struct{
ulint max_archived_lsn_age; ulint max_archived_lsn_age;
/* maximum allowed age for /* maximum allowed age for
archived_lsn */ archived_lsn */
dulint next_archived_lsn;/* during an archive write, ib_ulonglong next_archived_lsn;/* during an archive write,
until the write is completed, we until the write is completed, we
store the next value for store the next value for
archived_lsn here: the write archived_lsn here: the write
...@@ -850,6 +857,7 @@ struct log_struct{ ...@@ -850,6 +857,7 @@ struct log_struct{
os_event_t archiving_on; /* if archiving has been stopped, os_event_t archiving_on; /* if archiving has been stopped,
a thread can wait for this event to a thread can wait for this event to
become signaled */ become signaled */
#endif /* UNIV_LOG_ARCHIVE */
}; };
#define LOG_ARCH_ON 71 #define LOG_ARCH_ON 71
......
...@@ -17,10 +17,11 @@ consistent. */ ...@@ -17,10 +17,11 @@ consistent. */
ibool ibool
log_check_log_recs( log_check_log_recs(
/*===============*/ /*===============*/
byte* buf, /* in: pointer to the start of the log segment byte* buf, /* in: pointer to the start of
in the log_sys->buf log buffer */ the log segment in the
log_sys->buf log buffer */
ulint len, /* in: segment length in bytes */ ulint len, /* in: segment length in bytes */
dulint buf_start_lsn); /* in: buffer start lsn */ ib_ulonglong buf_start_lsn); /* in: buffer start lsn */
/**************************************************************** /****************************************************************
Gets a log block flush bit. */ Gets a log block flush bit. */
...@@ -163,10 +164,9 @@ void ...@@ -163,10 +164,9 @@ void
log_block_set_checkpoint_no( log_block_set_checkpoint_no(
/*========================*/ /*========================*/
byte* log_block, /* in: log block */ byte* log_block, /* in: log block */
dulint no) /* in: checkpoint no */ ib_ulonglong no) /* in: checkpoint no */
{ {
mach_write_to_4(log_block + LOG_BLOCK_CHECKPOINT_NO, mach_write_to_4(log_block + LOG_BLOCK_CHECKPOINT_NO, (ulint) no);
ut_dulint_get_low(no));
} }
/**************************************************************** /****************************************************************
...@@ -175,18 +175,11 @@ UNIV_INLINE ...@@ -175,18 +175,11 @@ UNIV_INLINE
ulint ulint
log_block_convert_lsn_to_no( log_block_convert_lsn_to_no(
/*========================*/ /*========================*/
/* out: log block number, it is > 0 and <= 1G */ /* out: log block number,
dulint lsn) /* in: lsn of a byte within the block */ it is > 0 and <= 1G */
ib_ulonglong lsn) /* in: lsn of a byte within the block */
{ {
ulint no; return(((ulint) (lsn / OS_FILE_LOG_BLOCK_SIZE) & 0x3FFFFFFFUL) + 1);
no = ut_dulint_get_low(lsn) / OS_FILE_LOG_BLOCK_SIZE;
no += (ut_dulint_get_high(lsn) % OS_FILE_LOG_BLOCK_SIZE)
* 2 * (0x80000000UL / OS_FILE_LOG_BLOCK_SIZE);
no = no & 0x3FFFFFFFUL;
return(no + 1);
} }
/**************************************************************** /****************************************************************
...@@ -251,7 +244,7 @@ void ...@@ -251,7 +244,7 @@ void
log_block_init( log_block_init(
/*===========*/ /*===========*/
byte* log_block, /* in: pointer to the log buffer */ byte* log_block, /* in: pointer to the log buffer */
dulint lsn) /* in: lsn within the log block */ ib_ulonglong lsn) /* in: lsn within the log block */
{ {
ulint no; ulint no;
...@@ -275,7 +268,7 @@ void ...@@ -275,7 +268,7 @@ void
log_block_init_in_old_format( log_block_init_in_old_format(
/*=========================*/ /*=========================*/
byte* log_block, /* in: pointer to the log buffer */ byte* log_block, /* in: pointer to the log buffer */
dulint lsn) /* in: lsn within the log block */ ib_ulonglong lsn) /* in: lsn within the log block */
{ {
ulint no; ulint no;
...@@ -296,19 +289,19 @@ log_block_init_in_old_format( ...@@ -296,19 +289,19 @@ log_block_init_in_old_format(
Writes to the log the string given. The log must be released with Writes to the log the string given. The log must be released with
log_release. */ log_release. */
UNIV_INLINE UNIV_INLINE
dulint ib_ulonglong
log_reserve_and_write_fast( log_reserve_and_write_fast(
/*=======================*/ /*=======================*/
/* out: end lsn of the log record, ut_dulint_zero if /* out: end lsn of the log record,
did not succeed */ zero if did not succeed */
byte* str, /* in: string */ byte* str, /* in: string */
ulint len, /* in: string length */ ulint len, /* in: string length */
dulint* start_lsn,/* out: start lsn of the log record */ ib_ulonglong* start_lsn,/* out: start lsn of the log record */
ibool* success)/* out: TRUE if success */ ibool* success)/* out: TRUE if success */
{ {
log_t* log = log_sys; log_t* log = log_sys;
ulint data_len; ulint data_len;
dulint lsn; ib_ulonglong lsn;
*success = TRUE; *success = TRUE;
...@@ -325,7 +318,7 @@ log_reserve_and_write_fast( ...@@ -325,7 +318,7 @@ log_reserve_and_write_fast(
mutex_exit(&(log->mutex)); mutex_exit(&(log->mutex));
return(ut_dulint_zero); return(0);
} }
*start_lsn = log->lsn; *start_lsn = log->lsn;
...@@ -343,9 +336,7 @@ log_reserve_and_write_fast( ...@@ -343,9 +336,7 @@ log_reserve_and_write_fast(
ut_ad(log->buf_free <= log->buf_size); ut_ad(log->buf_free <= log->buf_size);
lsn = ut_dulint_add(log->lsn, len); lsn = log->lsn += len;
log->lsn = lsn;
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
log_check_log_recs(log->buf + log->old_buf_free, log_check_log_recs(log->buf + log->old_buf_free,
...@@ -367,12 +358,12 @@ log_release(void) ...@@ -367,12 +358,12 @@ log_release(void)
/**************************************************************** /****************************************************************
Gets the current lsn. */ Gets the current lsn. */
UNIV_INLINE UNIV_INLINE
dulint ib_ulonglong
log_get_lsn(void) log_get_lsn(void)
/*=============*/ /*=============*/
/* out: current lsn */ /* out: current lsn */
{ {
dulint lsn; ib_ulonglong lsn;
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
......
...@@ -26,14 +26,17 @@ ibool ...@@ -26,14 +26,17 @@ ibool
recv_read_cp_info_for_backup( recv_read_cp_info_for_backup(
/*=========================*/ /*=========================*/
/* out: TRUE if success */ /* out: TRUE if success */
byte* hdr, /* in: buffer containing the log group header */ byte* hdr, /* in: buffer containing the log group
dulint* lsn, /* out: checkpoint lsn */ header */
ib_ulonglong* lsn, /* out: checkpoint lsn */
ulint* offset, /* out: checkpoint offset in the log group */ ulint* offset, /* out: checkpoint offset in the log group */
ulint* fsp_limit,/* out: fsp limit of space 0, 1000000000 if the ulint* fsp_limit,/* out: fsp limit of space 0,
database is running with < version 3.23.50 of InnoDB */ 1000000000 if the database is running
dulint* cp_no, /* out: checkpoint number */ with < version 3.23.50 of InnoDB */
dulint* first_header_lsn); ib_ulonglong* cp_no, /* out: checkpoint number */
/* out: lsn of of the start of the first log file */ ib_ulonglong* first_header_lsn);
/* out: lsn of of the start of the
first log file */
/*********************************************************************** /***********************************************************************
Scans the log segment and n_bytes_scanned is set to the length of valid Scans the log segment and n_bytes_scanned is set to the length of valid
log scanned. */ log scanned. */
...@@ -43,7 +46,7 @@ recv_scan_log_seg_for_backup( ...@@ -43,7 +46,7 @@ recv_scan_log_seg_for_backup(
/*=========================*/ /*=========================*/
byte* buf, /* in: buffer containing log data */ byte* buf, /* in: buffer containing log data */
ulint buf_len, /* in: data length in that buffer */ ulint buf_len, /* in: data length in that buffer */
dulint* scanned_lsn, /* in/out: lsn of buffer start, ib_ulonglong* scanned_lsn, /* in/out: lsn of buffer start,
we return scanned lsn */ we return scanned lsn */
ulint* scanned_checkpoint_no, ulint* scanned_checkpoint_no,
/* in/out: 4 lowest bytes of the /* in/out: 4 lowest bytes of the
...@@ -92,9 +95,12 @@ recv_recovery_from_checkpoint_start( ...@@ -92,9 +95,12 @@ recv_recovery_from_checkpoint_start(
/*================================*/ /*================================*/
/* out: error code or DB_SUCCESS */ /* out: error code or DB_SUCCESS */
ulint type, /* in: LOG_CHECKPOINT or LOG_ARCHIVE */ ulint type, /* in: LOG_CHECKPOINT or LOG_ARCHIVE */
dulint limit_lsn, /* in: recover up to this lsn if possible */ ib_ulonglong limit_lsn, /* in: recover up to this lsn
dulint min_flushed_lsn,/* in: min flushed lsn from data files */ if possible */
dulint max_flushed_lsn);/* in: max flushed lsn from data files */ ib_ulonglong min_flushed_lsn,/* in: min flushed lsn from
data files */
ib_ulonglong max_flushed_lsn);/* in: max flushed lsn from
data files */
/************************************************************ /************************************************************
Completes recovery from a checkpoint. */ Completes recovery from a checkpoint. */
...@@ -108,40 +114,48 @@ and hashes the log records if new data found. */ ...@@ -108,40 +114,48 @@ and hashes the log records if new data found. */
ibool ibool
recv_scan_log_recs( recv_scan_log_recs(
/*===============*/ /*===============*/
/* out: TRUE if limit_lsn has been reached, or /* out: TRUE if limit_lsn has been
not able to scan any more in this log group */ reached, or not able to scan any more
ibool apply_automatically,/* in: TRUE if we want this function to in this log group */
apply log records automatically when the ibool apply_automatically,/* in: TRUE if we want this
hash table becomes full; in the hot backup tool function to apply log records
automatically when the hash table
becomes full; in the hot backup tool
the tool does the applying, not this the tool does the applying, not this
function */ function */
ulint available_memory,/* in: we let the hash table of recs to grow ulint available_memory,/* in: we let the hash table of recs
to this size, at the maximum */ to grow to this size, at the maximum */
ibool store_to_hash, /* in: TRUE if the records should be stored ibool store_to_hash, /* in: TRUE if the records should be
to the hash table; this is set to FALSE if just stored to the hash table; this is set
debug checking is needed */ to FALSE if just debug checking is
byte* buf, /* in: buffer containing a log segment or needed */
garbage */ byte* buf, /* in: buffer containing a log segment
or garbage */
ulint len, /* in: buffer length */ ulint len, /* in: buffer length */
dulint start_lsn, /* in: buffer start lsn */ ib_ulonglong start_lsn, /* in: buffer start lsn */
dulint* contiguous_lsn, /* in/out: it is known that all log groups ib_ulonglong* contiguous_lsn, /* in/out: it is known that all log
contain contiguous log data up to this lsn */ groups contain contiguous log data up
dulint* group_scanned_lsn);/* out: scanning succeeded up to this lsn */ to this lsn */
ib_ulonglong* group_scanned_lsn);/* out: scanning succeeded up to
this lsn */
/********************************************************** /**********************************************************
Resets the logs. The contents of log files will be lost! */ Resets the logs. The contents of log files will be lost! */
void void
recv_reset_logs( recv_reset_logs(
/*============*/ /*============*/
dulint lsn, /* in: reset to this lsn rounded up to ib_ulonglong lsn, /* in: reset to this lsn
be divisible by OS_FILE_LOG_BLOCK_SIZE, rounded up to be divisible by
after which we add LOG_BLOCK_HDR_SIZE */ OS_FILE_LOG_BLOCK_SIZE, after
which we add
LOG_BLOCK_HDR_SIZE */
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
ulint arch_log_no, /* in: next archived log file number */ ulint arch_log_no, /* in: next archived log file number */
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
ibool new_logs_created);/* in: TRUE if resetting logs is done ibool new_logs_created);/* in: TRUE if resetting logs
at the log creation; FALSE if it is done is done at the log creation;
after archive recovery */ FALSE if it is done after
archive recovery */
#ifdef UNIV_HOTBACKUP #ifdef UNIV_HOTBACKUP
/********************************************************** /**********************************************************
Creates new log files after a backup has been restored. */ Creates new log files after a backup has been restored. */
...@@ -152,7 +166,7 @@ recv_reset_log_files_for_backup( ...@@ -152,7 +166,7 @@ recv_reset_log_files_for_backup(
const char* log_dir, /* in: log file directory path */ const char* log_dir, /* in: log file directory path */
ulint n_log_files, /* in: number of log files */ ulint n_log_files, /* in: number of log files */
ulint log_file_size, /* in: log file size */ ulint log_file_size, /* in: log file size */
dulint lsn); /* in: new start lsn, must be ib_ulonglong lsn); /* in: new start lsn, must be
divisible by OS_FILE_LOG_BLOCK_SIZE */ divisible by OS_FILE_LOG_BLOCK_SIZE */
#endif /* UNIV_HOTBACKUP */ #endif /* UNIV_HOTBACKUP */
/************************************************************ /************************************************************
...@@ -200,13 +214,15 @@ ulint ...@@ -200,13 +214,15 @@ ulint
recv_recovery_from_archive_start( recv_recovery_from_archive_start(
/*=============================*/ /*=============================*/
/* out: error code or DB_SUCCESS */ /* out: error code or DB_SUCCESS */
dulint min_flushed_lsn,/* in: min flushed lsn field from the ib_ulonglong min_flushed_lsn,/* in: min flushed lsn field from the
data files */ data files */
dulint limit_lsn, /* in: recover up to this lsn if possible */ ib_ulonglong limit_lsn, /* in: recover up to this lsn if
ulint first_log_no); /* in: number of the first archived log file possible */
to use in the recovery; the file will be ulint first_log_no); /* in: number of the first archived
searched from INNOBASE_LOG_ARCH_DIR specified log file to use in the recovery; the
in server config file */ file will be searched from
INNOBASE_LOG_ARCH_DIR specified in
server config file */
/************************************************************ /************************************************************
Completes recovery from archive. */ Completes recovery from archive. */
...@@ -231,11 +247,11 @@ struct recv_struct{ ...@@ -231,11 +247,11 @@ struct recv_struct{
ulint len; /* log record body length in bytes */ ulint len; /* log record body length in bytes */
recv_data_t* data; /* chain of blocks containing the log record recv_data_t* data; /* chain of blocks containing the log record
body */ body */
dulint start_lsn;/* start lsn of the log segment written by ib_ulonglong start_lsn;/* start lsn of the log segment written by
the mtr which generated this log record: NOTE the mtr which generated this log record: NOTE
that this is not necessarily the start lsn of that this is not necessarily the start lsn of
this log record */ this log record */
dulint end_lsn;/* end lsn of the log segment written by ib_ulonglong end_lsn;/* end lsn of the log segment written by
the mtr which generated this log record: NOTE the mtr which generated this log record: NOTE
that this is not necessarily the end lsn of that this is not necessarily the end lsn of
this log record */ this log record */
...@@ -269,7 +285,7 @@ struct recv_sys_struct{ ...@@ -269,7 +285,7 @@ struct recv_sys_struct{
ibool apply_batch_on; ibool apply_batch_on;
/* this is TRUE when a log rec application /* this is TRUE when a log rec application
batch is running */ batch is running */
dulint lsn; /* log sequence number */ ib_ulonglong lsn; /* log sequence number */
ulint last_log_buf_size; ulint last_log_buf_size;
/* size of the log buffer when the database /* size of the log buffer when the database
last time wrote to the log */ last time wrote to the log */
...@@ -281,12 +297,12 @@ struct recv_sys_struct{ ...@@ -281,12 +297,12 @@ struct recv_sys_struct{
preceding buffer */ preceding buffer */
byte* buf; /* buffer for parsing log records */ byte* buf; /* buffer for parsing log records */
ulint len; /* amount of data in buf */ ulint len; /* amount of data in buf */
dulint parse_start_lsn; ib_ulonglong parse_start_lsn;
/* this is the lsn from which we were able to /* this is the lsn from which we were able to
start parsing log records and adding them to start parsing log records and adding them to
the hash table; ut_dulint_zero if a suitable the hash table; zero if a suitable
start point not found yet */ start point not found yet */
dulint scanned_lsn; ib_ulonglong scanned_lsn;
/* the log data has been scanned up to this /* the log data has been scanned up to this
lsn */ lsn */
ulint scanned_checkpoint_no; ulint scanned_checkpoint_no;
...@@ -295,10 +311,10 @@ struct recv_sys_struct{ ...@@ -295,10 +311,10 @@ struct recv_sys_struct{
ulint recovered_offset; ulint recovered_offset;
/* start offset of non-parsed log records in /* start offset of non-parsed log records in
buf */ buf */
dulint recovered_lsn; ib_ulonglong recovered_lsn;
/* the log records have been parsed up to /* the log records have been parsed up to
this lsn */ this lsn */
dulint limit_lsn;/* recovery should be made at most up to this ib_ulonglong limit_lsn;/* recovery should be made at most up to this
lsn */ lsn */
ibool found_corrupt_log; ibool found_corrupt_log;
/* this is set to TRUE if we during log /* this is set to TRUE if we during log
......
...@@ -179,6 +179,15 @@ mach_write_to_8( ...@@ -179,6 +179,15 @@ mach_write_to_8(
/*============*/ /*============*/
byte* b, /* in: pointer to 8 bytes where to store */ byte* b, /* in: pointer to 8 bytes where to store */
dulint n); /* in: dulint integer to be stored */ dulint n); /* in: dulint integer to be stored */
/***********************************************************
The following function is used to store data in 8 consecutive
bytes. We store the most significant byte to the lowest address. */
UNIV_INLINE
void
mach_write_ull(
/*===========*/
byte* b, /* in: pointer to 8 bytes where to store */
ib_ulonglong n); /* in: 64-bit integer to be stored */
/************************************************************ /************************************************************
The following function is used to fetch data from 8 consecutive The following function is used to fetch data from 8 consecutive
bytes. The most significant byte is at the lowest address. */ bytes. The most significant byte is at the lowest address. */
...@@ -188,6 +197,15 @@ mach_read_from_8( ...@@ -188,6 +197,15 @@ mach_read_from_8(
/*=============*/ /*=============*/
/* out: dulint integer */ /* out: dulint integer */
const byte* b); /* in: pointer to 8 bytes */ const byte* b); /* in: pointer to 8 bytes */
/************************************************************
The following function is used to fetch data from 8 consecutive
bytes. The most significant byte is at the lowest address. */
UNIV_INLINE
ib_ulonglong
mach_read_ull(
/*==========*/
/* out: 64-bit integer */
const byte* b); /* in: pointer to 8 bytes */
/************************************************************* /*************************************************************
Writes a dulint in a compressed form (5..9 bytes). */ Writes a dulint in a compressed form (5..9 bytes). */
UNIV_INLINE UNIV_INLINE
......
...@@ -273,6 +273,22 @@ mach_write_to_8( ...@@ -273,6 +273,22 @@ mach_write_to_8(
mach_write_to_4(b + 4, ut_dulint_get_low(n)); mach_write_to_4(b + 4, ut_dulint_get_low(n));
} }
/***********************************************************
The following function is used to store data in 8 consecutive
bytes. We store the most significant byte to the lowest address. */
UNIV_INLINE
void
mach_write_ull(
/*===========*/
byte* b, /* in: pointer to 8 bytes where to store */
ib_ulonglong n) /* in: 64-bit integer to be stored */
{
ut_ad(b);
mach_write_to_4(b, n >> 32);
mach_write_to_4(b + 4, n);
}
/************************************************************ /************************************************************
The following function is used to fetch data from 8 consecutive The following function is used to fetch data from 8 consecutive
bytes. The most significant byte is at the lowest address. */ bytes. The most significant byte is at the lowest address. */
...@@ -294,6 +310,24 @@ mach_read_from_8( ...@@ -294,6 +310,24 @@ mach_read_from_8(
return(ut_dulint_create(high, low)); return(ut_dulint_create(high, low));
} }
/************************************************************
The following function is used to fetch data from 8 consecutive
bytes. The most significant byte is at the lowest address. */
UNIV_INLINE
ib_ulonglong
mach_read_ull(
/*==========*/
/* out: 64-bit integer */
const byte* b) /* in: pointer to 8 bytes */
{
ib_ulonglong ull;
ull = ((ib_ulonglong) mach_read_from_4(b)) << 32;
ull |= (ib_ulonglong) mach_read_from_4(b + 4);
return(ull);
}
/*********************************************************** /***********************************************************
The following function is used to store data in 7 consecutive The following function is used to store data in 7 consecutive
bytes. We store the most significant byte to the lowest address. */ bytes. We store the most significant byte to the lowest address. */
......
...@@ -350,9 +350,9 @@ struct mtr_struct{ ...@@ -350,9 +350,9 @@ struct mtr_struct{
have been written to the mtr log */ have been written to the mtr log */
ulint log_mode; /* specifies which operations should be ulint log_mode; /* specifies which operations should be
logged; default value MTR_LOG_ALL */ logged; default value MTR_LOG_ALL */
dulint start_lsn;/* start lsn of the possible log entry for ib_ulonglong start_lsn;/* start lsn of the possible log entry for
this mtr */ this mtr */
dulint end_lsn;/* end lsn of the possible log entry for ib_ulonglong end_lsn;/* end lsn of the possible log entry for
this mtr */ this mtr */
ulint magic_n; ulint magic_n;
}; };
......
...@@ -78,8 +78,8 @@ int ...@@ -78,8 +78,8 @@ int
innobase_shutdown_for_mysql(void); innobase_shutdown_for_mysql(void);
/*=============================*/ /*=============================*/
/* out: DB_SUCCESS or error code */ /* out: DB_SUCCESS or error code */
extern dulint srv_shutdown_lsn; extern ib_ulonglong srv_shutdown_lsn;
extern dulint srv_start_lsn; extern ib_ulonglong srv_start_lsn;
#ifdef __NETWARE__ #ifdef __NETWARE__
void set_panic_flag_for_netware(void); void set_panic_flag_for_netware(void);
......
...@@ -446,7 +446,7 @@ struct trx_struct{ ...@@ -446,7 +446,7 @@ struct trx_struct{
were modifications by the transaction; were modifications by the transaction;
in that case we must flush the log in that case we must flush the log
in trx_commit_complete_for_mysql() */ in trx_commit_complete_for_mysql() */
dulint commit_lsn; /* lsn at the time of the commit */ ib_ulonglong commit_lsn; /* lsn at the time of the commit */
ibool dict_operation; /* TRUE if the trx is used to create ibool dict_operation; /* TRUE if the trx is used to create
a table, create an index, or drop a a table, create an index, or drop a
table. This is a hint that the table table. This is a hint that the table
......
...@@ -202,8 +202,10 @@ typedef long int lint; ...@@ -202,8 +202,10 @@ typedef long int lint;
#ifdef __WIN__ #ifdef __WIN__
typedef __int64 ib_longlong; typedef __int64 ib_longlong;
typedef unsigned __int64 ib_ulonglong;
#else #else
typedef longlong ib_longlong; typedef longlong ib_longlong;
typedef ulonglong ib_ulonglong;
#endif #endif
#ifndef __WIN__ #ifndef __WIN__
...@@ -221,6 +223,9 @@ typedef longlong ib_longlong; ...@@ -221,6 +223,9 @@ typedef longlong ib_longlong;
/* Maximum value for a ulint */ /* Maximum value for a ulint */
#define ULINT_MAX ((ulint)(-2)) #define ULINT_MAX ((ulint)(-2))
/* Maximum value for ib_ulonglong */
#define IB_ULONGLONG_MAX ((ib_ulonglong) (~0ULL))
/* This 'ibool' type is used within Innobase. Remember that different included /* This 'ibool' type is used within Innobase. Remember that different included
headers may define 'bool' differently. Do not assume that 'bool' is a ulint! */ headers may define 'bool' differently. Do not assume that 'bool' is a ulint! */
#define ibool ulint #define ibool ulint
......
...@@ -148,6 +148,26 @@ ut_dulint_align_up( ...@@ -148,6 +148,26 @@ ut_dulint_align_up(
dulint n, /* in: number to be rounded */ dulint n, /* in: number to be rounded */
ulint align_no); /* in: align by this number which must be a ulint align_no); /* in: align by this number which must be a
power of 2 */ power of 2 */
/************************************************************
Rounds a dulint downward to a multiple of a power of 2. */
UNIV_INLINE
ib_ulonglong
ut_ulonglong_align_down(
/*====================*/
/* out: rounded value */
ib_ulonglong n, /* in: number to be rounded */
ulint align_no); /* in: align by this number
which must be a power of 2 */
/************************************************************
Rounds ib_ulonglong upward to a multiple of a power of 2. */
UNIV_INLINE
ib_ulonglong
ut_ulonglong_align_up(
/*==================*/
/* out: rounded value */
ib_ulonglong n, /* in: number to be rounded */
ulint align_no); /* in: align by this number
which must be a power of 2 */
/*********************************************************** /***********************************************************
Increments a dulint variable by 1. */ Increments a dulint variable by 1. */
#define UT_DULINT_INC(D)\ #define UT_DULINT_INC(D)\
......
...@@ -260,6 +260,42 @@ ut_dulint_align_up( ...@@ -260,6 +260,42 @@ ut_dulint_align_up(
return(ut_dulint_align_down(ut_dulint_add(n, align_no - 1), align_no)); return(ut_dulint_align_down(ut_dulint_add(n, align_no - 1), align_no));
} }
/************************************************************
Rounds ib_ulonglong downward to a multiple of a power of 2. */
UNIV_INLINE
ib_ulonglong
ut_ulonglong_align_down(
/*====================*/
/* out: rounded value */
ib_ulonglong n, /* in: number to be rounded */
ulint align_no) /* in: align by this number
which must be a power of 2 */
{
ut_ad(align_no > 0);
ut_ad(ut_is_2pow(align_no));
return(n & (ib_ulonglong) ~(align_no - 1));
}
/************************************************************
Rounds ib_ulonglong upward to a multiple of a power of 2. */
UNIV_INLINE
ib_ulonglong
ut_ulonglong_align_up(
/*==================*/
/* out: rounded value */
ib_ulonglong n, /* in: number to be rounded */
ulint align_no) /* in: align by this number
which must be a power of 2 */
{
ib_ulonglong align_1 = (ib_ulonglong) align_no - 1;
ut_ad(align_no > 0);
ut_ad(ut_is_2pow(align_no));
return((n + align_1) & ~align_1);
}
/************************************************************ /************************************************************
The following function calculates the value of an integer n rounded The following function calculates the value of an integer n rounded
to the least product of align_no which is >= n. align_no to the least product of align_no which is >= n. align_no
......
...@@ -159,11 +159,11 @@ log_fsp_current_free_limit_set_and_checkpoint( ...@@ -159,11 +159,11 @@ log_fsp_current_free_limit_set_and_checkpoint(
Returns the oldest modified block lsn in the pool, or log_sys->lsn if none Returns the oldest modified block lsn in the pool, or log_sys->lsn if none
exists. */ exists. */
static static
dulint ib_ulonglong
log_buf_pool_get_oldest_modification(void) log_buf_pool_get_oldest_modification(void)
/*======================================*/ /*======================================*/
{ {
dulint lsn; ib_ulonglong lsn;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(log_sys->mutex))); ut_ad(mutex_own(&(log_sys->mutex)));
...@@ -171,7 +171,7 @@ log_buf_pool_get_oldest_modification(void) ...@@ -171,7 +171,7 @@ log_buf_pool_get_oldest_modification(void)
lsn = buf_pool_get_oldest_modification(); lsn = buf_pool_get_oldest_modification();
if (ut_dulint_is_zero(lsn)) { if (!lsn) {
lsn = log_sys->lsn; lsn = log_sys->lsn;
} }
...@@ -183,7 +183,7 @@ log_buf_pool_get_oldest_modification(void) ...@@ -183,7 +183,7 @@ log_buf_pool_get_oldest_modification(void)
Opens the log for log_write_low. The log must be closed with log_close and Opens the log for log_write_low. The log must be closed with log_close and
released with log_release. */ released with log_release. */
dulint ib_ulonglong
log_reserve_and_open( log_reserve_and_open(
/*=================*/ /*=================*/
/* out: start lsn of the log record */ /* out: start lsn of the log record */
...@@ -227,8 +227,7 @@ log_reserve_and_open( ...@@ -227,8 +227,7 @@ log_reserve_and_open(
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
if (log->archiving_state != LOG_ARCH_OFF) { if (log->archiving_state != LOG_ARCH_OFF) {
archived_lsn_age = ut_dulint_minus(log->lsn, archived_lsn_age = log->lsn - log->archived_lsn;
log->archived_lsn);
if (archived_lsn_age + len_upper_limit if (archived_lsn_age + len_upper_limit
> log->max_archived_lsn_age) { > log->max_archived_lsn_age) {
/* Not enough free archived space in log groups: do a /* Not enough free archived space in log groups: do a
...@@ -306,12 +305,12 @@ log_write_low( ...@@ -306,12 +305,12 @@ log_write_low(
log_sys->next_checkpoint_no); log_sys->next_checkpoint_no);
len += LOG_BLOCK_HDR_SIZE + LOG_BLOCK_TRL_SIZE; len += LOG_BLOCK_HDR_SIZE + LOG_BLOCK_TRL_SIZE;
log->lsn = ut_dulint_add(log->lsn, len); log->lsn += len;
/* Initialize the next block header */ /* Initialize the next block header */
log_block_init(log_block + OS_FILE_LOG_BLOCK_SIZE, log->lsn); log_block_init(log_block + OS_FILE_LOG_BLOCK_SIZE, log->lsn);
} else { } else {
log->lsn = ut_dulint_add(log->lsn, len); log->lsn += len;
} }
log->buf_free += len; log->buf_free += len;
...@@ -328,15 +327,15 @@ log_write_low( ...@@ -328,15 +327,15 @@ log_write_low(
/**************************************************************** /****************************************************************
Closes the log. */ Closes the log. */
dulint ib_ulonglong
log_close(void) log_close(void)
/*===========*/ /*===========*/
/* out: lsn */ /* out: lsn */
{ {
byte* log_block; byte* log_block;
ulint first_rec_group; ulint first_rec_group;
dulint oldest_lsn; ib_ulonglong oldest_lsn;
dulint lsn; ib_ulonglong lsn;
log_t* log = log_sys; log_t* log = log_sys;
ulint checkpoint_age; ulint checkpoint_age;
...@@ -364,7 +363,7 @@ log_close(void) ...@@ -364,7 +363,7 @@ log_close(void)
log->check_flush_or_checkpoint = TRUE; log->check_flush_or_checkpoint = TRUE;
} }
checkpoint_age = ut_dulint_minus(lsn, log->last_checkpoint_lsn); checkpoint_age = lsn - log->last_checkpoint_lsn;
if (checkpoint_age >= log->log_group_capacity) { if (checkpoint_age >= log->log_group_capacity) {
/* TODO: split btr_store_big_rec_extern_fields() into small /* TODO: split btr_store_big_rec_extern_fields() into small
...@@ -402,9 +401,8 @@ log_close(void) ...@@ -402,9 +401,8 @@ log_close(void)
oldest_lsn = buf_pool_get_oldest_modification(); oldest_lsn = buf_pool_get_oldest_modification();
if (ut_dulint_is_zero(oldest_lsn) if (!oldest_lsn
|| (ut_dulint_minus(lsn, oldest_lsn) || lsn - oldest_lsn > log->max_modified_age_async
> log->max_modified_age_async)
|| checkpoint_age > log->max_checkpoint_age_async) { || checkpoint_age > log->max_checkpoint_age_async) {
log->check_flush_or_checkpoint = TRUE; log->check_flush_or_checkpoint = TRUE;
...@@ -431,7 +429,7 @@ log_pad_current_log_block(void) ...@@ -431,7 +429,7 @@ log_pad_current_log_block(void)
byte b = MLOG_DUMMY_RECORD; byte b = MLOG_DUMMY_RECORD;
ulint pad_length; ulint pad_length;
ulint i; ulint i;
dulint lsn; ib_ulonglong lsn;
/* We retrieve lsn only because otherwise gcc crashed on HP-UX */ /* We retrieve lsn only because otherwise gcc crashed on HP-UX */
lsn = log_reserve_and_open(OS_FILE_LOG_BLOCK_SIZE); lsn = log_reserve_and_open(OS_FILE_LOG_BLOCK_SIZE);
...@@ -449,8 +447,7 @@ log_pad_current_log_block(void) ...@@ -449,8 +447,7 @@ log_pad_current_log_block(void)
log_close(); log_close();
log_release(); log_release();
ut_a((ut_dulint_get_low(lsn) % OS_FILE_LOG_BLOCK_SIZE) ut_a(lsn % OS_FILE_LOG_BLOCK_SIZE == LOG_BLOCK_HDR_SIZE);
== LOG_BLOCK_HDR_SIZE);
} }
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
...@@ -515,11 +512,11 @@ ulint ...@@ -515,11 +512,11 @@ ulint
log_group_calc_lsn_offset( log_group_calc_lsn_offset(
/*======================*/ /*======================*/
/* out: offset within the log group */ /* out: offset within the log group */
dulint lsn, /* in: lsn, must be within 4 GB of ib_ulonglong lsn, /* in: lsn, must be within 4 GB of
group->lsn */ group->lsn */
log_group_t* group) /* in: log group */ log_group_t* group) /* in: log group */
{ {
dulint gr_lsn; ib_ulonglong gr_lsn;
ib_longlong gr_lsn_size_offset; ib_longlong gr_lsn_size_offset;
ib_longlong difference; ib_longlong difference;
ib_longlong group_size; ib_longlong group_size;
...@@ -539,11 +536,11 @@ log_group_calc_lsn_offset( ...@@ -539,11 +536,11 @@ log_group_calc_lsn_offset(
group_size = (ib_longlong) log_group_get_capacity(group); group_size = (ib_longlong) log_group_get_capacity(group);
if (ut_dulint_cmp(lsn, gr_lsn) >= 0) { if (lsn >= gr_lsn) {
difference = (ib_longlong) ut_dulint_minus(lsn, gr_lsn); difference = (ib_longlong) (lsn - gr_lsn);
} else { } else {
difference = (ib_longlong) ut_dulint_minus(gr_lsn, lsn); difference = (ib_longlong) (gr_lsn - lsn);
difference = difference % group_size; difference = difference % group_size;
...@@ -571,36 +568,31 @@ log_calc_where_lsn_is( ...@@ -571,36 +568,31 @@ log_calc_where_lsn_is(
/* out: log file number */ /* out: log file number */
ib_longlong* log_file_offset, /* out: offset in that file ib_longlong* log_file_offset, /* out: offset in that file
(including the header) */ (including the header) */
dulint first_header_lsn, /* in: first log file start ib_ulonglong first_header_lsn, /* in: first log file start
lsn */ lsn */
dulint lsn, /* in: lsn whose position to ib_ulonglong lsn, /* in: lsn whose position to
determine */ determine */
ulint n_log_files, /* in: total number of log ulint n_log_files, /* in: total number of log
files */ files */
ib_longlong log_file_size) /* in: log file size ib_longlong log_file_size) /* in: log file size
(including the header) */ (including the header) */
{ {
ib_longlong ib_lsn;
ib_longlong ib_first_header_lsn;
ib_longlong capacity = log_file_size - LOG_FILE_HDR_SIZE; ib_longlong capacity = log_file_size - LOG_FILE_HDR_SIZE;
ulint file_no; ulint file_no;
ib_longlong add_this_many; ib_longlong add_this_many;
ib_lsn = ut_conv_dulint_to_longlong(lsn); if (lsn < first_header_lsn) {
ib_first_header_lsn = ut_conv_dulint_to_longlong(first_header_lsn); add_this_many = 1 + (first_header_lsn - lsn)
if (ib_lsn < ib_first_header_lsn) {
add_this_many = 1 + (ib_first_header_lsn - ib_lsn)
/ (capacity * (ib_longlong)n_log_files); / (capacity * (ib_longlong)n_log_files);
ib_lsn += add_this_many lsn += add_this_many
* capacity * (ib_longlong)n_log_files; * capacity * (ib_longlong)n_log_files;
} }
ut_a(ib_lsn >= ib_first_header_lsn); ut_a(lsn >= first_header_lsn);
file_no = ((ulint)((ib_lsn - ib_first_header_lsn) / capacity)) file_no = ((ulint)((lsn - first_header_lsn) / capacity))
% n_log_files; % n_log_files;
*log_file_offset = (ib_lsn - ib_first_header_lsn) % capacity; *log_file_offset = (lsn - first_header_lsn) % capacity;
*log_file_offset = *log_file_offset + LOG_FILE_HDR_SIZE; *log_file_offset = *log_file_offset + LOG_FILE_HDR_SIZE;
...@@ -616,7 +608,7 @@ void ...@@ -616,7 +608,7 @@ void
log_group_set_fields( log_group_set_fields(
/*=================*/ /*=================*/
log_group_t* group, /* in: group */ log_group_t* group, /* in: group */
dulint lsn) /* in: lsn for which the values should be ib_ulonglong lsn) /* in: lsn for which the values should be
set */ set */
{ {
group->lsn_offset = log_group_calc_lsn_offset(lsn, group); group->lsn_offset = log_group_calc_lsn_offset(lsn, group);
...@@ -783,9 +775,9 @@ log_init(void) ...@@ -783,9 +775,9 @@ log_init(void)
log_sys->buf_next_to_write = 0; log_sys->buf_next_to_write = 0;
log_sys->write_lsn = ut_dulint_zero; log_sys->write_lsn = 0;
log_sys->current_flush_lsn = ut_dulint_zero; log_sys->current_flush_lsn = 0;
log_sys->flushed_to_disk_lsn = ut_dulint_zero; log_sys->flushed_to_disk_lsn = 0;
log_sys->written_to_some_lsn = log_sys->lsn; log_sys->written_to_some_lsn = log_sys->lsn;
log_sys->written_to_all_lsn = log_sys->lsn; log_sys->written_to_all_lsn = log_sys->lsn;
...@@ -803,7 +795,7 @@ log_init(void) ...@@ -803,7 +795,7 @@ log_init(void)
/*----------------------------*/ /*----------------------------*/
log_sys->adm_checkpoint_interval = ULINT_MAX; log_sys->adm_checkpoint_interval = ULINT_MAX;
log_sys->next_checkpoint_no = ut_dulint_zero; log_sys->next_checkpoint_no = 0;
log_sys->last_checkpoint_lsn = log_sys->lsn; log_sys->last_checkpoint_lsn = log_sys->lsn;
log_sys->n_pending_checkpoint_writes = 0; log_sys->n_pending_checkpoint_writes = 0;
...@@ -819,7 +811,7 @@ log_init(void) ...@@ -819,7 +811,7 @@ log_init(void)
/* Under MySQL, log archiving is always off */ /* Under MySQL, log archiving is always off */
log_sys->archiving_state = LOG_ARCH_OFF; log_sys->archiving_state = LOG_ARCH_OFF;
log_sys->archived_lsn = log_sys->lsn; log_sys->archived_lsn = log_sys->lsn;
log_sys->next_archived_lsn = ut_dulint_zero; log_sys->next_archived_lsn = 0;
log_sys->n_pending_archive_ios = 0; log_sys->n_pending_archive_ios = 0;
...@@ -844,7 +836,7 @@ log_init(void) ...@@ -844,7 +836,7 @@ log_init(void)
log_block_set_first_rec_group(log_sys->buf, LOG_BLOCK_HDR_SIZE); log_block_set_first_rec_group(log_sys->buf, LOG_BLOCK_HDR_SIZE);
log_sys->buf_free = LOG_BLOCK_HDR_SIZE; log_sys->buf_free = LOG_BLOCK_HDR_SIZE;
log_sys->lsn = ut_dulint_add(LOG_START_LSN, LOG_BLOCK_HDR_SIZE); log_sys->lsn = LOG_START_LSN + LOG_BLOCK_HDR_SIZE;
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
...@@ -856,7 +848,7 @@ log_init(void) ...@@ -856,7 +848,7 @@ log_init(void)
recv_sys->scanned_lsn = log_sys->lsn; recv_sys->scanned_lsn = log_sys->lsn;
recv_sys->scanned_checkpoint_no = 0; recv_sys->scanned_checkpoint_no = 0;
recv_sys->recovered_lsn = log_sys->lsn; recv_sys->recovered_lsn = log_sys->lsn;
recv_sys->limit_lsn = ut_dulint_max; recv_sys->limit_lsn = IB_ULONGLONG_MAX;
#endif #endif
} }
...@@ -1124,7 +1116,7 @@ log_group_file_header_flush( ...@@ -1124,7 +1116,7 @@ log_group_file_header_flush(
log_group_t* group, /* in: log group */ log_group_t* group, /* in: log group */
ulint nth_file, /* in: header to the nth file in the ulint nth_file, /* in: header to the nth file in the
log file space */ log file space */
dulint start_lsn) /* in: log file data starts at this ib_ulonglong start_lsn) /* in: log file data starts at this
lsn */ lsn */
{ {
byte* buf; byte* buf;
...@@ -1138,7 +1130,7 @@ log_group_file_header_flush( ...@@ -1138,7 +1130,7 @@ log_group_file_header_flush(
buf = *(group->file_header_bufs + nth_file); buf = *(group->file_header_bufs + nth_file);
mach_write_to_4(buf + LOG_GROUP_ID, group->id); mach_write_to_4(buf + LOG_GROUP_ID, group->id);
mach_write_to_8(buf + LOG_FILE_START_LSN, start_lsn); mach_write_ull(buf + LOG_FILE_START_LSN, start_lsn);
/* Wipe over possible label of ibbackup --restore */ /* Wipe over possible label of ibbackup --restore */
memcpy(buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, " ", 4); memcpy(buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, " ", 4);
...@@ -1190,7 +1182,7 @@ log_group_write_buf( ...@@ -1190,7 +1182,7 @@ log_group_write_buf(
byte* buf, /* in: buffer */ byte* buf, /* in: buffer */
ulint len, /* in: buffer len; must be divisible ulint len, /* in: buffer len; must be divisible
by OS_FILE_LOG_BLOCK_SIZE */ by OS_FILE_LOG_BLOCK_SIZE */
dulint start_lsn, /* in: start lsn of the buffer; must ib_ulonglong start_lsn, /* in: start lsn of the buffer; must
be divisible by be divisible by
OS_FILE_LOG_BLOCK_SIZE */ OS_FILE_LOG_BLOCK_SIZE */
ulint new_data_offset)/* in: start offset of new data in ulint new_data_offset)/* in: start offset of new data in
...@@ -1207,7 +1199,7 @@ log_group_write_buf( ...@@ -1207,7 +1199,7 @@ log_group_write_buf(
ut_ad(mutex_own(&(log_sys->mutex))); ut_ad(mutex_own(&(log_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_a(len % OS_FILE_LOG_BLOCK_SIZE == 0); ut_a(len % OS_FILE_LOG_BLOCK_SIZE == 0);
ut_a(ut_dulint_get_low(start_lsn) % OS_FILE_LOG_BLOCK_SIZE == 0); ut_a(((ulint) start_lsn) % OS_FILE_LOG_BLOCK_SIZE == 0);
if (new_data_offset == 0) { if (new_data_offset == 0) {
write_header = TRUE; write_header = TRUE;
...@@ -1247,12 +1239,11 @@ log_group_write_buf( ...@@ -1247,12 +1239,11 @@ log_group_write_buf(
fprintf(stderr, fprintf(stderr,
"Writing log file segment to group %lu" "Writing log file segment to group %lu"
" offset %lu len %lu\n" " offset %lu len %lu\n"
"start lsn %lu %lu\n" "start lsn %llu\n"
"First block n:o %lu last block n:o %lu\n", "First block n:o %lu last block n:o %lu\n",
(ulong) group->id, (ulong) next_offset, (ulong) group->id, (ulong) next_offset,
(ulong) write_len, (ulong) write_len,
(ulong) ut_dulint_get_high(start_lsn), start_lsn,
(ulong) ut_dulint_get_low(start_lsn),
(ulong) log_block_get_hdr_no(buf), (ulong) log_block_get_hdr_no(buf),
(ulong) log_block_get_hdr_no( (ulong) log_block_get_hdr_no(
buf + write_len - OS_FILE_LOG_BLOCK_SIZE)); buf + write_len - OS_FILE_LOG_BLOCK_SIZE));
...@@ -1290,7 +1281,7 @@ log_group_write_buf( ...@@ -1290,7 +1281,7 @@ log_group_write_buf(
} }
if (write_len < len) { if (write_len < len) {
start_lsn = ut_dulint_add(start_lsn, write_len); start_lsn += write_len;
len -= write_len; len -= write_len;
buf += write_len; buf += write_len;
...@@ -1309,13 +1300,14 @@ flush flushed enough. If not, starts a new flush. */ ...@@ -1309,13 +1300,14 @@ flush flushed enough. If not, starts a new flush. */
void void
log_write_up_to( log_write_up_to(
/*============*/ /*============*/
dulint lsn, /* in: log sequence number up to which the log should ib_ulonglong lsn, /* in: log sequence number up to which
be written, ut_dulint_max if not specified */ the log should be written,
IB_ULONGLONG_MAX if not specified */
ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP, ulint wait, /* in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
or LOG_WAIT_ALL_GROUPS */ or LOG_WAIT_ALL_GROUPS */
ibool flush_to_disk) ibool flush_to_disk)
/* in: TRUE if we want the written log also to be /* in: TRUE if we want the written log
flushed to disk */ also to be flushed to disk */
{ {
log_group_t* group; log_group_t* group;
ulint start_offset; ulint start_offset;
...@@ -1350,7 +1342,7 @@ log_write_up_to( ...@@ -1350,7 +1342,7 @@ log_write_up_to(
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
if (flush_to_disk if (flush_to_disk
&& ut_dulint_cmp(log_sys->flushed_to_disk_lsn, lsn) >= 0) { && log_sys->flushed_to_disk_lsn >= lsn) {
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
...@@ -1358,9 +1350,8 @@ log_write_up_to( ...@@ -1358,9 +1350,8 @@ log_write_up_to(
} }
if (!flush_to_disk if (!flush_to_disk
&& (ut_dulint_cmp(log_sys->written_to_all_lsn, lsn) >= 0 && (log_sys->written_to_all_lsn >= lsn
|| (ut_dulint_cmp(log_sys->written_to_some_lsn, lsn) || (log_sys->written_to_some_lsn >= lsn
>= 0
&& wait != LOG_WAIT_ALL_GROUPS))) { && wait != LOG_WAIT_ALL_GROUPS))) {
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
...@@ -1372,8 +1363,7 @@ log_write_up_to( ...@@ -1372,8 +1363,7 @@ log_write_up_to(
/* A write (+ possibly flush to disk) is running */ /* A write (+ possibly flush to disk) is running */
if (flush_to_disk if (flush_to_disk
&& ut_dulint_cmp(log_sys->current_flush_lsn, lsn) && log_sys->current_flush_lsn >= lsn) {
>= 0) {
/* The write + flush will write enough: wait for it to /* The write + flush will write enough: wait for it to
complete */ complete */
...@@ -1381,7 +1371,7 @@ log_write_up_to( ...@@ -1381,7 +1371,7 @@ log_write_up_to(
} }
if (!flush_to_disk if (!flush_to_disk
&& ut_dulint_cmp(log_sys->write_lsn, lsn) >= 0) { && log_sys->write_lsn >= lsn) {
/* The write will write enough: wait for it to /* The write will write enough: wait for it to
complete */ complete */
...@@ -1410,13 +1400,9 @@ log_write_up_to( ...@@ -1410,13 +1400,9 @@ log_write_up_to(
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
fprintf(stderr, fprintf(stderr,
"Writing log from %lu %lu up to lsn %lu %lu\n", "Writing log from %llu up to lsn %llu\n",
(ulong) ut_dulint_get_high( log_sys->written_to_all_lsn,
log_sys->written_to_all_lsn), log_sys->lsn);
(ulong) ut_dulint_get_low(
log_sys->written_to_all_lsn),
(ulong) ut_dulint_get_high(log_sys->lsn),
(ulong) ut_dulint_get_low(log_sys->lsn));
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
log_sys->n_pending_writes++; log_sys->n_pending_writes++;
...@@ -1468,7 +1454,7 @@ log_write_up_to( ...@@ -1468,7 +1454,7 @@ log_write_up_to(
log_group_write_buf( log_group_write_buf(
group, log_sys->buf + area_start, group, log_sys->buf + area_start,
area_end - area_start, area_end - area_start,
ut_dulint_align_down(log_sys->written_to_all_lsn, ut_ulonglong_align_down(log_sys->written_to_all_lsn,
OS_FILE_LOG_BLOCK_SIZE), OS_FILE_LOG_BLOCK_SIZE),
start_offset - area_start); start_offset - area_start);
...@@ -1531,7 +1517,7 @@ void ...@@ -1531,7 +1517,7 @@ void
log_buffer_flush_to_disk(void) log_buffer_flush_to_disk(void)
/*==========================*/ /*==========================*/
{ {
dulint lsn; ib_ulonglong lsn;
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
...@@ -1552,7 +1538,7 @@ log_flush_margin(void) ...@@ -1552,7 +1538,7 @@ log_flush_margin(void)
{ {
ibool do_flush = FALSE; ibool do_flush = FALSE;
log_t* log = log_sys; log_t* log = log_sys;
dulint lsn; ib_ulonglong lsn;
mutex_enter(&(log->mutex)); mutex_enter(&(log->mutex));
...@@ -1582,13 +1568,16 @@ no synchronization objects! */ ...@@ -1582,13 +1568,16 @@ no synchronization objects! */
ibool ibool
log_preflush_pool_modified_pages( log_preflush_pool_modified_pages(
/*=============================*/ /*=============================*/
/* out: FALSE if there was a flush batch of /* out: FALSE if there was a
the same type running, which means that we flush batch of the same type
could not start this flush batch */ running, which means that we
dulint new_oldest, /* in: try to advance oldest_modified_lsn could not start this flush
at least to this lsn */ batch */
ibool sync) /* in: TRUE if synchronous operation is ib_ulonglong new_oldest, /* in: try to advance
desired */ oldest_modified_lsn at least
to this lsn */
ibool sync) /* in: TRUE if synchronous
operation is desired */
{ {
ulint n_pages; ulint n_pages;
...@@ -1631,8 +1620,7 @@ log_complete_checkpoint(void) ...@@ -1631,8 +1620,7 @@ log_complete_checkpoint(void)
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_ad(log_sys->n_pending_checkpoint_writes == 0); ut_ad(log_sys->n_pending_checkpoint_writes == 0);
log_sys->next_checkpoint_no log_sys->next_checkpoint_no++;
= ut_dulint_add(log_sys->next_checkpoint_no, 1);
log_sys->last_checkpoint_lsn = log_sys->next_checkpoint_lsn; log_sys->last_checkpoint_lsn = log_sys->next_checkpoint_lsn;
...@@ -1707,8 +1695,8 @@ log_group_checkpoint( ...@@ -1707,8 +1695,8 @@ log_group_checkpoint(
{ {
log_group_t* group2; log_group_t* group2;
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
dulint archived_lsn; ib_ulonglong archived_lsn;
dulint next_archived_lsn; ib_ulonglong next_archived_lsn;
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
ulint write_offset; ulint write_offset;
ulint fold; ulint fold;
...@@ -1724,9 +1712,8 @@ log_group_checkpoint( ...@@ -1724,9 +1712,8 @@ log_group_checkpoint(
buf = group->checkpoint_buf; buf = group->checkpoint_buf;
mach_write_to_8(buf + LOG_CHECKPOINT_NO, log_sys->next_checkpoint_no); mach_write_ull(buf + LOG_CHECKPOINT_NO, log_sys->next_checkpoint_no);
mach_write_to_8(buf + LOG_CHECKPOINT_LSN, mach_write_ull(buf + LOG_CHECKPOINT_LSN, log_sys->next_checkpoint_lsn);
log_sys->next_checkpoint_lsn);
mach_write_to_4(buf + LOG_CHECKPOINT_OFFSET, mach_write_to_4(buf + LOG_CHECKPOINT_OFFSET,
log_group_calc_lsn_offset( log_group_calc_lsn_offset(
...@@ -1736,20 +1723,19 @@ log_group_checkpoint( ...@@ -1736,20 +1723,19 @@ log_group_checkpoint(
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
if (log_sys->archiving_state == LOG_ARCH_OFF) { if (log_sys->archiving_state == LOG_ARCH_OFF) {
archived_lsn = ut_dulint_max; archived_lsn = IB_ULONGLONG_MAX;
} else { } else {
archived_lsn = log_sys->archived_lsn; archived_lsn = log_sys->archived_lsn;
if (0 != ut_dulint_cmp(archived_lsn, if (archived_lsn != log_sys->next_archived_lsn) {
log_sys->next_archived_lsn)) {
next_archived_lsn = log_sys->next_archived_lsn; next_archived_lsn = log_sys->next_archived_lsn;
/* For debugging only */ /* For debugging only */
} }
} }
mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, archived_lsn); mach_write_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN, archived_lsn);
#else /* UNIV_LOG_ARCHIVE */ #else /* UNIV_LOG_ARCHIVE */
mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, ut_dulint_max); mach_write_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX);
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
for (i = 0; i < LOG_MAX_N_GROUPS; i++) { for (i = 0; i < LOG_MAX_N_GROUPS; i++) {
...@@ -1790,7 +1776,7 @@ log_group_checkpoint( ...@@ -1790,7 +1776,7 @@ log_group_checkpoint(
/* We alternate the physical place of the checkpoint info in the first /* We alternate the physical place of the checkpoint info in the first
log file */ log file */
if (ut_dulint_get_low(log_sys->next_checkpoint_no) % 2 == 0) { if ((log_sys->next_checkpoint_no & 1) == 0) {
write_offset = LOG_CHECKPOINT_1; write_offset = LOG_CHECKPOINT_1;
} else { } else {
write_offset = LOG_CHECKPOINT_2; write_offset = LOG_CHECKPOINT_2;
...@@ -1828,20 +1814,20 @@ backup restoration. */ ...@@ -1828,20 +1814,20 @@ backup restoration. */
void void
log_reset_first_header_and_checkpoint( log_reset_first_header_and_checkpoint(
/*==================================*/ /*==================================*/
byte* hdr_buf,/* in: buffer which will be written to the start byte* hdr_buf,/* in: buffer which will be written to the
of the first log file */ start of the first log file */
dulint start) /* in: lsn of the start of the first log file; ib_ulonglong start) /* in: lsn of the start of the first log file;
we pretend that there is a checkpoint at we pretend that there is a checkpoint at
start + LOG_BLOCK_HDR_SIZE */ start + LOG_BLOCK_HDR_SIZE */
{ {
ulint fold; ulint fold;
byte* buf; byte* buf;
dulint lsn; ib_ulonglong lsn;
mach_write_to_4(hdr_buf + LOG_GROUP_ID, 0); mach_write_to_4(hdr_buf + LOG_GROUP_ID, 0);
mach_write_to_8(hdr_buf + LOG_FILE_START_LSN, start); mach_write_ull(hdr_buf + LOG_FILE_START_LSN, start);
lsn = ut_dulint_add(start, LOG_BLOCK_HDR_SIZE); lsn = start + LOG_BLOCK_HDR_SIZE;
/* Write the label of ibbackup --restore */ /* Write the label of ibbackup --restore */
strcpy((char*) hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, strcpy((char*) hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP,
...@@ -1851,15 +1837,15 @@ log_reset_first_header_and_checkpoint( ...@@ -1851,15 +1837,15 @@ log_reset_first_header_and_checkpoint(
+ (sizeof "ibbackup ") - 1)); + (sizeof "ibbackup ") - 1));
buf = hdr_buf + LOG_CHECKPOINT_1; buf = hdr_buf + LOG_CHECKPOINT_1;
mach_write_to_8(buf + LOG_CHECKPOINT_NO, ut_dulint_zero); mach_write_ull(buf + LOG_CHECKPOINT_NO, 0);
mach_write_to_8(buf + LOG_CHECKPOINT_LSN, lsn); mach_write_ull(buf + LOG_CHECKPOINT_LSN, lsn);
mach_write_to_4(buf + LOG_CHECKPOINT_OFFSET, mach_write_to_4(buf + LOG_CHECKPOINT_OFFSET,
LOG_FILE_HDR_SIZE + LOG_BLOCK_HDR_SIZE); LOG_FILE_HDR_SIZE + LOG_BLOCK_HDR_SIZE);
mach_write_to_4(buf + LOG_CHECKPOINT_LOG_BUF_SIZE, 2 * 1024 * 1024); mach_write_to_4(buf + LOG_CHECKPOINT_LOG_BUF_SIZE, 2 * 1024 * 1024);
mach_write_to_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN, ut_dulint_max); mach_write_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN, IB_ULONGLONG_MAX);
fold = ut_fold_binary(buf, LOG_CHECKPOINT_CHECKSUM_1); fold = ut_fold_binary(buf, LOG_CHECKPOINT_CHECKSUM_1);
mach_write_to_4(buf + LOG_CHECKPOINT_CHECKSUM_1, fold); mach_write_to_4(buf + LOG_CHECKPOINT_CHECKSUM_1, fold);
...@@ -1935,7 +1921,7 @@ log_checkpoint( ...@@ -1935,7 +1921,7 @@ log_checkpoint(
parameter TRUE, a physical write will always be parameter TRUE, a physical write will always be
made to log files */ made to log files */
{ {
dulint oldest_lsn; ib_ulonglong oldest_lsn;
if (recv_recovery_is_on()) { if (recv_recovery_is_on()) {
recv_apply_hashed_log_recs(TRUE); recv_apply_hashed_log_recs(TRUE);
...@@ -1964,14 +1950,14 @@ log_checkpoint( ...@@ -1964,14 +1950,14 @@ log_checkpoint(
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
if (!write_always if (!write_always
&& ut_dulint_cmp(log_sys->last_checkpoint_lsn, oldest_lsn) >= 0) { && log_sys->last_checkpoint_lsn >= oldest_lsn) {
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
return(TRUE); return(TRUE);
} }
ut_ad(ut_dulint_cmp(log_sys->written_to_all_lsn, oldest_lsn) >= 0); ut_ad(log_sys->written_to_all_lsn >= oldest_lsn);
if (log_sys->n_pending_checkpoint_writes > 0) { if (log_sys->n_pending_checkpoint_writes > 0) {
/* A checkpoint write is running */ /* A checkpoint write is running */
...@@ -1991,10 +1977,9 @@ log_checkpoint( ...@@ -1991,10 +1977,9 @@ log_checkpoint(
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
fprintf(stderr, "Making checkpoint no %lu at lsn %lu %lu\n", fprintf(stderr, "Making checkpoint no %lu at lsn %llu\n",
(ulong) ut_dulint_get_low(log_sys->next_checkpoint_no), (ulong) log_sys->next_checkpoint_no,
(ulong) ut_dulint_get_high(oldest_lsn), oldest_lsn);
(ulong) ut_dulint_get_low(oldest_lsn));
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
...@@ -2017,31 +2002,22 @@ Makes a checkpoint at a given lsn or later. */ ...@@ -2017,31 +2002,22 @@ Makes a checkpoint at a given lsn or later. */
void void
log_make_checkpoint_at( log_make_checkpoint_at(
/*===================*/ /*===================*/
dulint lsn, /* in: make a checkpoint at this or a later ib_ulonglong lsn, /* in: make a checkpoint at this or a
lsn, if ut_dulint_max, makes a checkpoint at later lsn, if IB_ULONGLONG_MAX, makes
the latest lsn */ a checkpoint at the latest lsn */
ibool write_always) /* in: the function normally checks if the ibool write_always) /* in: the function normally checks if
the new checkpoint would have a greater the the new checkpoint would have a
lsn than the previous one: if not, then no greater lsn than the previous one: if
physical write is done; by setting this not, then no physical write is done;
parameter TRUE, a physical write will always be by setting this parameter TRUE, a
made to log files */ physical write will always be made to
log files */
{ {
ibool success;
/* Preflush pages synchronously */ /* Preflush pages synchronously */
success = FALSE; while (!log_preflush_pool_modified_pages(lsn, TRUE));
while (!success) {
success = log_preflush_pool_modified_pages(lsn, TRUE);
}
success = FALSE;
while (!success) { while (!log_checkpoint(TRUE, write_always));
success = log_checkpoint(TRUE, write_always);
}
} }
/******************************************************************** /********************************************************************
...@@ -2058,7 +2034,7 @@ log_checkpoint_margin(void) ...@@ -2058,7 +2034,7 @@ log_checkpoint_margin(void)
ulint age; ulint age;
ulint checkpoint_age; ulint checkpoint_age;
ulint advance; ulint advance;
dulint oldest_lsn; ib_ulonglong oldest_lsn;
ibool sync; ibool sync;
ibool checkpoint_sync; ibool checkpoint_sync;
ibool do_checkpoint; ibool do_checkpoint;
...@@ -2078,7 +2054,7 @@ log_checkpoint_margin(void) ...@@ -2078,7 +2054,7 @@ log_checkpoint_margin(void)
oldest_lsn = log_buf_pool_get_oldest_modification(); oldest_lsn = log_buf_pool_get_oldest_modification();
age = ut_dulint_minus(log->lsn, oldest_lsn); age = log->lsn - oldest_lsn;
if (age > log->max_modified_age_sync) { if (age > log->max_modified_age_sync) {
...@@ -2094,7 +2070,7 @@ log_checkpoint_margin(void) ...@@ -2094,7 +2070,7 @@ log_checkpoint_margin(void)
advance = 0; advance = 0;
} }
checkpoint_age = ut_dulint_minus(log->lsn, log->last_checkpoint_lsn); checkpoint_age = log->lsn - log->last_checkpoint_lsn;
if (checkpoint_age > log->max_checkpoint_age) { if (checkpoint_age > log->max_checkpoint_age) {
/* A checkpoint is urgent: we do it synchronously */ /* A checkpoint is urgent: we do it synchronously */
...@@ -2116,7 +2092,7 @@ log_checkpoint_margin(void) ...@@ -2116,7 +2092,7 @@ log_checkpoint_margin(void)
mutex_exit(&(log->mutex)); mutex_exit(&(log->mutex));
if (advance) { if (advance) {
dulint new_oldest = ut_dulint_add(oldest_lsn, advance); ib_ulonglong new_oldest = oldest_lsn + advance;
success = log_preflush_pool_modified_pages(new_oldest, sync); success = log_preflush_pool_modified_pages(new_oldest, sync);
...@@ -2155,8 +2131,8 @@ log_group_read_log_seg( ...@@ -2155,8 +2131,8 @@ log_group_read_log_seg(
ulint type, /* in: LOG_ARCHIVE or LOG_RECOVER */ ulint type, /* in: LOG_ARCHIVE or LOG_RECOVER */
byte* buf, /* in: buffer where to read */ byte* buf, /* in: buffer where to read */
log_group_t* group, /* in: log group */ log_group_t* group, /* in: log group */
dulint start_lsn, /* in: read area start */ ib_ulonglong start_lsn, /* in: read area start */
dulint end_lsn) /* in: read area end */ ib_ulonglong end_lsn) /* in: read area end */
{ {
ulint len; ulint len;
ulint source_offset; ulint source_offset;
...@@ -2166,15 +2142,11 @@ log_group_read_log_seg( ...@@ -2166,15 +2142,11 @@ log_group_read_log_seg(
ut_ad(mutex_own(&(log_sys->mutex))); ut_ad(mutex_own(&(log_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
sync = FALSE; sync = (type == LOG_RECOVER);
if (type == LOG_RECOVER) {
sync = TRUE;
}
loop: loop:
source_offset = log_group_calc_lsn_offset(start_lsn, group); source_offset = log_group_calc_lsn_offset(start_lsn, group);
len = ut_dulint_minus(end_lsn, start_lsn); len = (ulint) (end_lsn - start_lsn);
ut_ad(len != 0); ut_ad(len != 0);
...@@ -2196,10 +2168,10 @@ log_group_read_log_seg( ...@@ -2196,10 +2168,10 @@ log_group_read_log_seg(
source_offset / UNIV_PAGE_SIZE, source_offset % UNIV_PAGE_SIZE, source_offset / UNIV_PAGE_SIZE, source_offset % UNIV_PAGE_SIZE,
len, buf, NULL); len, buf, NULL);
start_lsn = ut_dulint_add(start_lsn, len); start_lsn += len;
buf += len; buf += len;
if (ut_dulint_cmp(start_lsn, end_lsn) != 0) { if (start_lsn != end_lsn) {
goto loop; goto loop;
} }
...@@ -2231,7 +2203,7 @@ log_group_archive_file_header_write( ...@@ -2231,7 +2203,7 @@ log_group_archive_file_header_write(
ulint nth_file, /* in: header to the nth file in the ulint nth_file, /* in: header to the nth file in the
archive log file space */ archive log file space */
ulint file_no, /* in: archived file number */ ulint file_no, /* in: archived file number */
dulint start_lsn) /* in: log file data starts at this ib_ulonglong start_lsn) /* in: log file data starts at this
lsn */ lsn */
{ {
byte* buf; byte* buf;
...@@ -2246,7 +2218,7 @@ log_group_archive_file_header_write( ...@@ -2246,7 +2218,7 @@ log_group_archive_file_header_write(
buf = *(group->archive_file_header_bufs + nth_file); buf = *(group->archive_file_header_bufs + nth_file);
mach_write_to_4(buf + LOG_GROUP_ID, group->id); mach_write_to_4(buf + LOG_GROUP_ID, group->id);
mach_write_to_8(buf + LOG_FILE_START_LSN, start_lsn); mach_write_ull(buf + LOG_FILE_START_LSN, start_lsn);
mach_write_to_4(buf + LOG_FILE_NO, file_no); mach_write_to_4(buf + LOG_FILE_NO, file_no);
mach_write_to_4(buf + LOG_FILE_ARCH_COMPLETED, FALSE); mach_write_to_4(buf + LOG_FILE_ARCH_COMPLETED, FALSE);
...@@ -2271,7 +2243,7 @@ log_group_archive_completed_header_write( ...@@ -2271,7 +2243,7 @@ log_group_archive_completed_header_write(
log_group_t* group, /* in: log group */ log_group_t* group, /* in: log group */
ulint nth_file, /* in: header to the nth file in the ulint nth_file, /* in: header to the nth file in the
archive log file space */ archive log file space */
dulint end_lsn) /* in: end lsn of the file */ ib_ulonglong end_lsn) /* in: end lsn of the file */
{ {
byte* buf; byte* buf;
ulint dest_offset; ulint dest_offset;
...@@ -2284,7 +2256,7 @@ log_group_archive_completed_header_write( ...@@ -2284,7 +2256,7 @@ log_group_archive_completed_header_write(
buf = *(group->archive_file_header_bufs + nth_file); buf = *(group->archive_file_header_bufs + nth_file);
mach_write_to_4(buf + LOG_FILE_ARCH_COMPLETED, TRUE); mach_write_to_4(buf + LOG_FILE_ARCH_COMPLETED, TRUE);
mach_write_to_8(buf + LOG_FILE_END_LSN, end_lsn); mach_write_ull(buf + LOG_FILE_END_LSN, end_lsn);
dest_offset = nth_file * group->file_size + LOG_FILE_ARCH_COMPLETED; dest_offset = nth_file * group->file_size + LOG_FILE_ARCH_COMPLETED;
...@@ -2307,8 +2279,8 @@ log_group_archive( ...@@ -2307,8 +2279,8 @@ log_group_archive(
log_group_t* group) /* in: log group */ log_group_t* group) /* in: log group */
{ {
os_file_t file_handle; os_file_t file_handle;
dulint start_lsn; ib_ulonglong start_lsn;
dulint end_lsn; ib_ulonglong end_lsn;
char name[1024]; char name[1024];
byte* buf; byte* buf;
ulint len; ulint len;
...@@ -2323,11 +2295,11 @@ log_group_archive( ...@@ -2323,11 +2295,11 @@ log_group_archive(
start_lsn = log_sys->archived_lsn; start_lsn = log_sys->archived_lsn;
ut_a(ut_dulint_get_low(start_lsn) % OS_FILE_LOG_BLOCK_SIZE == 0); ut_a(start_lsn % OS_FILE_LOG_BLOCK_SIZE == 0);
end_lsn = log_sys->next_archived_lsn; end_lsn = log_sys->next_archived_lsn;
ut_a(ut_dulint_get_low(end_lsn) % OS_FILE_LOG_BLOCK_SIZE == 0); ut_a(end_lsn % OS_FILE_LOG_BLOCK_SIZE == 0);
buf = log_sys->archive_buf; buf = log_sys->archive_buf;
...@@ -2396,7 +2368,7 @@ log_group_archive( ...@@ -2396,7 +2368,7 @@ log_group_archive(
} }
} }
len = ut_dulint_minus(end_lsn, start_lsn); len = end_lsn - start_lsn;
if (group->file_size < (next_offset % group->file_size) + len) { if (group->file_size < (next_offset % group->file_size) + len) {
...@@ -2406,10 +2378,9 @@ log_group_archive( ...@@ -2406,10 +2378,9 @@ log_group_archive(
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
fprintf(stderr, fprintf(stderr,
"Archiving starting at lsn %lu %lu, len %lu" "Archiving starting at lsn %llu, len %lu"
" to group %lu\n", " to group %lu\n",
(ulong) ut_dulint_get_high(start_lsn), start_lsn,
(ulong) ut_dulint_get_low(start_lsn),
(ulong) len, (ulong) group->id); (ulong) len, (ulong) group->id);
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
...@@ -2423,7 +2394,7 @@ log_group_archive( ...@@ -2423,7 +2394,7 @@ log_group_archive(
ut_calc_align(len, OS_FILE_LOG_BLOCK_SIZE), buf, ut_calc_align(len, OS_FILE_LOG_BLOCK_SIZE), buf,
&log_archive_io); &log_archive_io);
start_lsn = ut_dulint_add(start_lsn, len); start_lsn += len;
next_offset += len; next_offset += len;
buf += len; buf += len;
...@@ -2431,7 +2402,7 @@ log_group_archive( ...@@ -2431,7 +2402,7 @@ log_group_archive(
n_files++; n_files++;
} }
if (ut_dulint_cmp(end_lsn, start_lsn) != 0) { if (end_lsn != start_lsn) {
goto loop; goto loop;
} }
...@@ -2473,8 +2444,8 @@ log_archive_write_complete_groups(void) ...@@ -2473,8 +2444,8 @@ log_archive_write_complete_groups(void)
ulint end_offset; ulint end_offset;
ulint trunc_files; ulint trunc_files;
ulint n_files; ulint n_files;
dulint start_lsn; ib_ulonglong start_lsn;
dulint end_lsn; ib_ulonglong end_lsn;
ulint i; ulint i;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
...@@ -2512,16 +2483,14 @@ log_archive_write_complete_groups(void) ...@@ -2512,16 +2483,14 @@ log_archive_write_complete_groups(void)
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
/* Calculate the archive file space start lsn */ /* Calculate the archive file space start lsn */
start_lsn = ut_dulint_subtract( start_lsn = log_sys->next_archived_lsn
log_sys->next_archived_lsn, - (end_offset - LOG_FILE_HDR_SIZE + trunc_files
end_offset - LOG_FILE_HDR_SIZE + trunc_files
* (group->file_size - LOG_FILE_HDR_SIZE)); * (group->file_size - LOG_FILE_HDR_SIZE));
end_lsn = start_lsn; end_lsn = start_lsn;
for (i = 0; i < trunc_files; i++) { for (i = 0; i < trunc_files; i++) {
end_lsn = ut_dulint_add(end_lsn, end_lsn += group->file_size - LOG_FILE_HDR_SIZE;
group->file_size - LOG_FILE_HDR_SIZE);
/* Write a notice to the headers of archived log /* Write a notice to the headers of archived log
files that the file write has been completed */ files that the file write has been completed */
...@@ -2618,8 +2587,8 @@ log_archive_do( ...@@ -2618,8 +2587,8 @@ log_archive_do(
archive */ archive */
{ {
ibool calc_new_limit; ibool calc_new_limit;
dulint start_lsn; ib_ulonglong start_lsn;
dulint limit_lsn; ib_ulonglong limit_lsn;
calc_new_limit = TRUE; calc_new_limit = TRUE;
loop: loop:
...@@ -2648,19 +2617,18 @@ log_archive_do( ...@@ -2648,19 +2617,18 @@ log_archive_do(
if (calc_new_limit) { if (calc_new_limit) {
ut_a(log_sys->archive_buf_size % OS_FILE_LOG_BLOCK_SIZE == 0); ut_a(log_sys->archive_buf_size % OS_FILE_LOG_BLOCK_SIZE == 0);
limit_lsn = ut_dulint_add(start_lsn, limit_lsn = start_lsn + log_sys->archive_buf_size;
log_sys->archive_buf_size);
*n_bytes = log_sys->archive_buf_size; *n_bytes = log_sys->archive_buf_size;
if (ut_dulint_cmp(limit_lsn, log_sys->lsn) >= 0) { if (limit_lsn >= log_sys->lsn) {
limit_lsn = ut_dulint_align_down( limit_lsn = ut_ulonglong_align_down(
log_sys->lsn, OS_FILE_LOG_BLOCK_SIZE); log_sys->lsn, OS_FILE_LOG_BLOCK_SIZE);
} }
} }
if (ut_dulint_cmp(log_sys->archived_lsn, limit_lsn) >= 0) { if (log_sys->archived_lsn >= limit_lsn) {
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
...@@ -2669,7 +2637,7 @@ log_archive_do( ...@@ -2669,7 +2637,7 @@ log_archive_do(
return(TRUE); return(TRUE);
} }
if (ut_dulint_cmp(log_sys->written_to_all_lsn, limit_lsn) < 0) { if (log_sys->written_to_all_lsn < limit_lsn) {
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
...@@ -2704,11 +2672,8 @@ log_archive_do( ...@@ -2704,11 +2672,8 @@ log_archive_do(
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
fprintf(stderr, fprintf(stderr,
"Archiving from lsn %lu %lu to lsn %lu %lu\n", "Archiving from lsn %llu to lsn %llu\n",
(ulong) ut_dulint_get_high(log_sys->archived_lsn), log_sys->archived_lsn, limit_lsn);
(ulong) ut_dulint_get_low(log_sys->archived_lsn),
(ulong) ut_dulint_get_high(limit_lsn),
(ulong) ut_dulint_get_low(limit_lsn));
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
...@@ -2738,7 +2703,7 @@ void ...@@ -2738,7 +2703,7 @@ void
log_archive_all(void) log_archive_all(void)
/*=================*/ /*=================*/
{ {
dulint present_lsn; ib_ulonglong present_lsn;
ulint dummy; ulint dummy;
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
...@@ -2758,7 +2723,7 @@ log_archive_all(void) ...@@ -2758,7 +2723,7 @@ log_archive_all(void)
for (;;) { for (;;) {
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
if (ut_dulint_cmp(present_lsn, log_sys->archived_lsn) <= 0) { if (present_lsn <= log_sys->archived_lsn) {
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
...@@ -2965,7 +2930,7 @@ log_archive_archivelog(void) ...@@ -2965,7 +2930,7 @@ log_archive_archivelog(void)
log_sys->archiving_state = LOG_ARCH_ON; log_sys->archiving_state = LOG_ARCH_ON;
log_sys->archived_lsn log_sys->archived_lsn
= ut_dulint_align_down(log_sys->lsn, = ut_ulonglong_align_down(log_sys->lsn,
OS_FILE_LOG_BLOCK_SIZE); OS_FILE_LOG_BLOCK_SIZE);
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
...@@ -2999,7 +2964,7 @@ log_archive_margin(void) ...@@ -2999,7 +2964,7 @@ log_archive_margin(void)
return; return;
} }
age = ut_dulint_minus(log->lsn, log->archived_lsn); age = log->lsn - log->archived_lsn;
if (age > log->max_archived_lsn_age) { if (age > log->max_archived_lsn_age) {
...@@ -3073,7 +3038,7 @@ void ...@@ -3073,7 +3038,7 @@ void
logs_empty_and_mark_files_at_shutdown(void) logs_empty_and_mark_files_at_shutdown(void)
/*=======================================*/ /*=======================================*/
{ {
dulint lsn; ib_ulonglong lsn;
ulint arch_log_no; ulint arch_log_no;
if (srv_print_verbose_log) { if (srv_print_verbose_log) {
...@@ -3151,19 +3116,16 @@ logs_empty_and_mark_files_at_shutdown(void) ...@@ -3151,19 +3116,16 @@ logs_empty_and_mark_files_at_shutdown(void)
log_archive_all(); log_archive_all();
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
log_make_checkpoint_at(ut_dulint_max, TRUE); log_make_checkpoint_at(IB_ULONGLONG_MAX, TRUE);
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
lsn = log_sys->lsn; lsn = log_sys->lsn;
if ((ut_dulint_cmp(lsn, log_sys->last_checkpoint_lsn) != 0) if (lsn != log_sys->last_checkpoint_lsn
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
|| (srv_log_archive_on || (srv_log_archive_on
&& ut_dulint_cmp(lsn, && lsn != log_sys->archived_lsn + LOG_BLOCK_HDR_SIZE)
ut_dulint_add(log_sys->archived_lsn,
LOG_BLOCK_HDR_SIZE))
!= 0)
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
) { ) {
...@@ -3232,17 +3194,14 @@ logs_empty_and_mark_files_at_shutdown(void) ...@@ -3232,17 +3194,14 @@ logs_empty_and_mark_files_at_shutdown(void)
/* Make some checks that the server really is quiet */ /* Make some checks that the server really is quiet */
ut_a(srv_n_threads_active[SRV_MASTER] == 0); ut_a(srv_n_threads_active[SRV_MASTER] == 0);
ut_a(buf_all_freed()); ut_a(buf_all_freed());
ut_a(0 == ut_dulint_cmp(lsn, log_sys->lsn)); ut_a(lsn == log_sys->lsn);
if (ut_dulint_cmp(lsn, srv_start_lsn) < 0) { if (lsn < srv_start_lsn) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: log sequence number" "InnoDB: Error: log sequence number"
" at shutdown %lu %lu\n" " at shutdown %llu\n"
"InnoDB: is lower than at startup %lu %lu!\n", "InnoDB: is lower than at startup %llu!\n",
(ulong) ut_dulint_get_high(lsn), lsn, srv_start_lsn);
(ulong) ut_dulint_get_low(lsn),
(ulong) ut_dulint_get_high(srv_start_lsn),
(ulong) ut_dulint_get_low(srv_start_lsn));
} }
srv_shutdown_lsn = lsn; srv_shutdown_lsn = lsn;
...@@ -3256,7 +3215,7 @@ logs_empty_and_mark_files_at_shutdown(void) ...@@ -3256,7 +3215,7 @@ logs_empty_and_mark_files_at_shutdown(void)
/* Make some checks that the server really is quiet */ /* Make some checks that the server really is quiet */
ut_a(srv_n_threads_active[SRV_MASTER] == 0); ut_a(srv_n_threads_active[SRV_MASTER] == 0);
ut_a(buf_all_freed()); ut_a(buf_all_freed());
ut_a(0 == ut_dulint_cmp(lsn, log_sys->lsn)); ut_a(lsn == log_sys->lsn);
} }
/********************************************************** /**********************************************************
...@@ -3266,13 +3225,14 @@ consistent. */ ...@@ -3266,13 +3225,14 @@ consistent. */
ibool ibool
log_check_log_recs( log_check_log_recs(
/*===============*/ /*===============*/
byte* buf, /* in: pointer to the start of the log segment byte* buf, /* in: pointer to the start of
in the log_sys->buf log buffer */ the log segment in the
log_sys->buf log buffer */
ulint len, /* in: segment length in bytes */ ulint len, /* in: segment length in bytes */
dulint buf_start_lsn) /* in: buffer start lsn */ ib_ulonglong buf_start_lsn) /* in: buffer start lsn */
{ {
dulint contiguous_lsn; ib_ulonglong contiguous_lsn;
dulint scanned_lsn; ib_ulonglong scanned_lsn;
byte* start; byte* start;
byte* end; byte* end;
byte* buf1; byte* buf1;
...@@ -3299,13 +3259,12 @@ log_check_log_recs( ...@@ -3299,13 +3259,12 @@ log_check_log_recs(
(buf_pool->curr_size (buf_pool->curr_size
- recv_n_pool_free_frames) * UNIV_PAGE_SIZE, - recv_n_pool_free_frames) * UNIV_PAGE_SIZE,
FALSE, scan_buf, end - start, FALSE, scan_buf, end - start,
ut_dulint_align_down(buf_start_lsn, ut_ulonglong_align_down(buf_start_lsn,
OS_FILE_LOG_BLOCK_SIZE), OS_FILE_LOG_BLOCK_SIZE),
&contiguous_lsn, &scanned_lsn); &contiguous_lsn, &scanned_lsn);
ut_a(ut_dulint_cmp(scanned_lsn, ut_dulint_add(buf_start_lsn, len)) ut_a(scanned_lsn == buf_start_lsn + len);
== 0); ut_a(recv_sys->recovered_lsn == scanned_lsn);
ut_a(ut_dulint_cmp(recv_sys->recovered_lsn, scanned_lsn) == 0);
mem_free(buf1); mem_free(buf1);
...@@ -3318,9 +3277,9 @@ Peeks the current lsn. */ ...@@ -3318,9 +3277,9 @@ Peeks the current lsn. */
ibool ibool
log_peek_lsn( log_peek_lsn(
/*=========*/ /*=========*/
/* out: TRUE if success, FALSE if could not get the /* out: TRUE if success, FALSE if
log system mutex */ could not get the log system mutex */
dulint* lsn) /* out: if returns TRUE, current lsn is here */ ib_ulonglong* lsn) /* out: if returns TRUE, current lsn is here */
{ {
if (0 == mutex_enter_nowait(&(log_sys->mutex), __FILE__, __LINE__)) { if (0 == mutex_enter_nowait(&(log_sys->mutex), __FILE__, __LINE__)) {
*lsn = log_sys->lsn; *lsn = log_sys->lsn;
...@@ -3347,15 +3306,12 @@ log_print( ...@@ -3347,15 +3306,12 @@ log_print(
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
fprintf(file, fprintf(file,
"Log sequence number %lu %lu\n" "Log sequence number %llu\n"
"Log flushed up to %lu %lu\n" "Log flushed up to %llu\n"
"Last checkpoint at %lu %lu\n", "Last checkpoint at %llu\n",
(ulong) ut_dulint_get_high(log_sys->lsn), log_sys->lsn,
(ulong) ut_dulint_get_low(log_sys->lsn), log_sys->flushed_to_disk_lsn,
(ulong) ut_dulint_get_high(log_sys->flushed_to_disk_lsn), log_sys->last_checkpoint_lsn);
(ulong) ut_dulint_get_low(log_sys->flushed_to_disk_lsn),
(ulong) ut_dulint_get_high(log_sys->last_checkpoint_lsn),
(ulong) ut_dulint_get_low(log_sys->last_checkpoint_lsn));
current_time = time(NULL); current_time = time(NULL);
......
...@@ -97,7 +97,7 @@ ulint recv_n_pool_free_frames = 256; ...@@ -97,7 +97,7 @@ ulint recv_n_pool_free_frames = 256;
is bigger than the lsn we are able to scan up to, that is an indication that is bigger than the lsn we are able to scan up to, that is an indication that
the recovery failed and the database may be corrupt. */ the recovery failed and the database may be corrupt. */
dulint recv_max_page_lsn; ib_ulonglong recv_max_page_lsn;
/************************************************************ /************************************************************
Creates the recovery system. */ Creates the recovery system. */
...@@ -159,7 +159,7 @@ recv_sys_init( ...@@ -159,7 +159,7 @@ recv_sys_init(
OS_FILE_LOG_BLOCK_SIZE); OS_FILE_LOG_BLOCK_SIZE);
recv_sys->found_corrupt_log = FALSE; recv_sys->found_corrupt_log = FALSE;
recv_max_page_lsn = ut_dulint_zero; recv_max_page_lsn = 0;
mutex_exit(&(recv_sys->mutex)); mutex_exit(&(recv_sys->mutex));
} }
...@@ -218,46 +218,45 @@ void ...@@ -218,46 +218,45 @@ void
recv_truncate_group( recv_truncate_group(
/*================*/ /*================*/
log_group_t* group, /* in: log group */ log_group_t* group, /* in: log group */
dulint recovered_lsn, /* in: recovery succeeded up to this ib_ulonglong recovered_lsn, /* in: recovery succeeded up to this
lsn */ lsn */
dulint limit_lsn, /* in: this was the limit for ib_ulonglong limit_lsn, /* in: this was the limit for
recovery */ recovery */
dulint checkpoint_lsn, /* in: recovery was started from this ib_ulonglong checkpoint_lsn, /* in: recovery was started from this
checkpoint */ checkpoint */
dulint archived_lsn) /* in: the log has been archived up to ib_ulonglong archived_lsn) /* in: the log has been archived up to
this lsn */ this lsn */
{ {
dulint start_lsn; ib_ulonglong start_lsn;
dulint end_lsn; ib_ulonglong end_lsn;
dulint finish_lsn1; ib_ulonglong finish_lsn1;
dulint finish_lsn2; ib_ulonglong finish_lsn2;
dulint finish_lsn; ib_ulonglong finish_lsn;
ulint len; ulint len;
ulint i; ulint i;
if (ut_dulint_cmp(archived_lsn, ut_dulint_max) == 0) { if (archived_lsn == IB_ULONGLONG_MAX) {
/* Checkpoint was taken in the NOARCHIVELOG mode */ /* Checkpoint was taken in the NOARCHIVELOG mode */
archived_lsn = checkpoint_lsn; archived_lsn = checkpoint_lsn;
} }
finish_lsn1 = ut_dulint_add(ut_dulint_align_down( finish_lsn1 = ut_ulonglong_align_down(archived_lsn,
archived_lsn, OS_FILE_LOG_BLOCK_SIZE)
OS_FILE_LOG_BLOCK_SIZE), + log_group_get_capacity(group);
log_group_get_capacity(group));
finish_lsn2 = ut_dulint_add(ut_dulint_align_up( finish_lsn2 = ut_ulonglong_align_up(recovered_lsn,
recovered_lsn, OS_FILE_LOG_BLOCK_SIZE)
OS_FILE_LOG_BLOCK_SIZE), + recv_sys->last_log_buf_size;
recv_sys->last_log_buf_size);
if (ut_dulint_cmp(limit_lsn, ut_dulint_max) != 0) { if (limit_lsn != IB_ULONGLONG_MAX) {
/* We do not know how far we should erase log records: erase /* We do not know how far we should erase log records: erase
as much as possible */ as much as possible */
finish_lsn = finish_lsn1; finish_lsn = finish_lsn1;
} else { } else {
/* It is enough to erase the length of the log buffer */ /* It is enough to erase the length of the log buffer */
finish_lsn = ut_dulint_get_min(finish_lsn1, finish_lsn2); finish_lsn = finish_lsn1 < finish_lsn2
? finish_lsn1 : finish_lsn2;
} }
ut_a(RECV_SCAN_SIZE <= log_sys->buf_size); ut_a(RECV_SCAN_SIZE <= log_sys->buf_size);
...@@ -268,36 +267,36 @@ recv_truncate_group( ...@@ -268,36 +267,36 @@ recv_truncate_group(
*(log_sys->buf + i) = '\0'; *(log_sys->buf + i) = '\0';
} }
start_lsn = ut_dulint_align_down(recovered_lsn, start_lsn = ut_ulonglong_align_down(recovered_lsn,
OS_FILE_LOG_BLOCK_SIZE); OS_FILE_LOG_BLOCK_SIZE);
if (ut_dulint_cmp(start_lsn, recovered_lsn) != 0) { if (start_lsn != recovered_lsn) {
/* Copy the last incomplete log block to the log buffer and /* Copy the last incomplete log block to the log buffer and
edit its data length: */ edit its data length: */
ut_memcpy(log_sys->buf, recv_sys->last_block, ut_memcpy(log_sys->buf, recv_sys->last_block,
OS_FILE_LOG_BLOCK_SIZE); OS_FILE_LOG_BLOCK_SIZE);
log_block_set_data_len(log_sys->buf, ut_dulint_minus( log_block_set_data_len(log_sys->buf,
recovered_lsn, start_lsn)); recovered_lsn - start_lsn);
} }
if (ut_dulint_cmp(start_lsn, finish_lsn) >= 0) { if (start_lsn >= finish_lsn) {
return; return;
} }
for (;;) { for (;;) {
end_lsn = ut_dulint_add(start_lsn, RECV_SCAN_SIZE); end_lsn = start_lsn + RECV_SCAN_SIZE;
if (ut_dulint_cmp(end_lsn, finish_lsn) > 0) { if (end_lsn > finish_lsn) {
end_lsn = finish_lsn; end_lsn = finish_lsn;
} }
len = ut_dulint_minus(end_lsn, start_lsn); len = end_lsn - start_lsn;
log_group_write_buf(group, log_sys->buf, len, start_lsn, 0); log_group_write_buf(group, log_sys->buf, len, start_lsn, 0);
if (ut_dulint_cmp(end_lsn, finish_lsn) >= 0) { if (end_lsn >= finish_lsn) {
return; return;
} }
...@@ -323,38 +322,38 @@ recv_copy_group( ...@@ -323,38 +322,38 @@ recv_copy_group(
group */ group */
log_group_t* group, /* in: copy to this log log_group_t* group, /* in: copy to this log
group */ group */
dulint recovered_lsn) /* in: recovery succeeded up ib_ulonglong recovered_lsn) /* in: recovery succeeded up
to this lsn */ to this lsn */
{ {
dulint start_lsn; ib_ulonglong start_lsn;
dulint end_lsn; ib_ulonglong end_lsn;
ulint len; ulint len;
if (ut_dulint_cmp(group->scanned_lsn, recovered_lsn) >= 0) { if (group->scanned_lsn >= recovered_lsn) {
return; return;
} }
ut_a(RECV_SCAN_SIZE <= log_sys->buf_size); ut_a(RECV_SCAN_SIZE <= log_sys->buf_size);
start_lsn = ut_dulint_align_down(group->scanned_lsn, start_lsn = ut_ulonglong_align_down(group->scanned_lsn,
OS_FILE_LOG_BLOCK_SIZE); OS_FILE_LOG_BLOCK_SIZE);
for (;;) { for (;;) {
end_lsn = ut_dulint_add(start_lsn, RECV_SCAN_SIZE); end_lsn = start_lsn + RECV_SCAN_SIZE;
if (ut_dulint_cmp(end_lsn, recovered_lsn) > 0) { if (end_lsn > recovered_lsn) {
end_lsn = ut_dulint_align_up(recovered_lsn, end_lsn = ut_ulonglong_align_up(
OS_FILE_LOG_BLOCK_SIZE); recovered_lsn, OS_FILE_LOG_BLOCK_SIZE);
} }
log_group_read_log_seg(LOG_RECOVER, log_sys->buf, log_group_read_log_seg(LOG_RECOVER, log_sys->buf,
up_to_date_group, start_lsn, end_lsn); up_to_date_group, start_lsn, end_lsn);
len = ut_dulint_minus(end_lsn, start_lsn); len = end_lsn - start_lsn;
log_group_write_buf(group, log_sys->buf, len, start_lsn, 0); log_group_write_buf(group, log_sys->buf, len, start_lsn, 0);
if (ut_dulint_cmp(end_lsn, recovered_lsn) >= 0) { if (end_lsn >= recovered_lsn) {
return; return;
} }
...@@ -376,10 +375,10 @@ recv_synchronize_groups( ...@@ -376,10 +375,10 @@ recv_synchronize_groups(
log group */ log group */
{ {
log_group_t* group; log_group_t* group;
dulint start_lsn; ib_ulonglong start_lsn;
dulint end_lsn; ib_ulonglong end_lsn;
dulint recovered_lsn; ib_ulonglong recovered_lsn;
dulint limit_lsn; ib_ulonglong limit_lsn;
recovered_lsn = recv_sys->recovered_lsn; recovered_lsn = recv_sys->recovered_lsn;
limit_lsn = recv_sys->limit_lsn; limit_lsn = recv_sys->limit_lsn;
...@@ -387,11 +386,11 @@ recv_synchronize_groups( ...@@ -387,11 +386,11 @@ recv_synchronize_groups(
/* Read the last recovered log block to the recovery system buffer: /* Read the last recovered log block to the recovery system buffer:
the block is always incomplete */ the block is always incomplete */
start_lsn = ut_dulint_align_down(recovered_lsn, start_lsn = ut_ulonglong_align_down(recovered_lsn,
OS_FILE_LOG_BLOCK_SIZE); OS_FILE_LOG_BLOCK_SIZE);
end_lsn = ut_dulint_align_up(recovered_lsn, OS_FILE_LOG_BLOCK_SIZE); end_lsn = ut_ulonglong_align_up(recovered_lsn, OS_FILE_LOG_BLOCK_SIZE);
ut_a(ut_dulint_cmp(start_lsn, end_lsn) != 0); ut_a(start_lsn != end_lsn);
log_group_read_log_seg(LOG_RECOVER, recv_sys->last_block, log_group_read_log_seg(LOG_RECOVER, recv_sys->last_block,
up_to_date_group, start_lsn, end_lsn); up_to_date_group, start_lsn, end_lsn);
...@@ -472,14 +471,14 @@ recv_find_max_checkpoint( ...@@ -472,14 +471,14 @@ recv_find_max_checkpoint(
LOG_CHECKPOINT_2 */ LOG_CHECKPOINT_2 */
{ {
log_group_t* group; log_group_t* group;
dulint max_no; ib_ulonglong max_no;
dulint checkpoint_no; ib_ulonglong checkpoint_no;
ulint field; ulint field;
byte* buf; byte* buf;
group = UT_LIST_GET_FIRST(log_sys->log_groups); group = UT_LIST_GET_FIRST(log_sys->log_groups);
max_no = ut_dulint_zero; max_no = 0;
*max_group = NULL; *max_group = NULL;
*max_field = 0; *max_field = 0;
...@@ -512,11 +511,11 @@ recv_find_max_checkpoint( ...@@ -512,11 +511,11 @@ recv_find_max_checkpoint(
group->state = LOG_GROUP_OK; group->state = LOG_GROUP_OK;
group->lsn = mach_read_from_8( group->lsn = mach_read_ull(
buf + LOG_CHECKPOINT_LSN); buf + LOG_CHECKPOINT_LSN);
group->lsn_offset = mach_read_from_4( group->lsn_offset = mach_read_from_4(
buf + LOG_CHECKPOINT_OFFSET); buf + LOG_CHECKPOINT_OFFSET);
checkpoint_no = mach_read_from_8( checkpoint_no = mach_read_ull(
buf + LOG_CHECKPOINT_NO); buf + LOG_CHECKPOINT_NO);
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
...@@ -524,13 +523,12 @@ recv_find_max_checkpoint( ...@@ -524,13 +523,12 @@ recv_find_max_checkpoint(
fprintf(stderr, fprintf(stderr,
"InnoDB: Checkpoint number %lu" "InnoDB: Checkpoint number %lu"
" found in group %lu\n", " found in group %lu\n",
(ulong) ut_dulint_get_low( (ulong) checkpoint_no,
checkpoint_no),
(ulong) group->id); (ulong) group->id);
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
if (ut_dulint_cmp(checkpoint_no, max_no) >= 0) { if (checkpoint_no >= max_no) {
*max_group = group; *max_group = group;
*max_field = field; *max_field = field;
max_no = checkpoint_no; max_no = checkpoint_no;
...@@ -569,31 +567,33 @@ ibool ...@@ -569,31 +567,33 @@ ibool
recv_read_cp_info_for_backup( recv_read_cp_info_for_backup(
/*=========================*/ /*=========================*/
/* out: TRUE if success */ /* out: TRUE if success */
byte* hdr, /* in: buffer containing the log group header */ byte* hdr, /* in: buffer containing the log group
dulint* lsn, /* out: checkpoint lsn */ header */
ib_ulonglong* lsn, /* out: checkpoint lsn */
ulint* offset, /* out: checkpoint offset in the log group */ ulint* offset, /* out: checkpoint offset in the log group */
ulint* fsp_limit,/* out: fsp limit of space 0, 1000000000 if the ulint* fsp_limit,/* out: fsp limit of space 0,
database is running with < version 3.23.50 of InnoDB */ 1000000000 if the database is running
dulint* cp_no, /* out: checkpoint number */ with < version 3.23.50 of InnoDB */
dulint* first_header_lsn) ib_ulonglong* cp_no, /* out: checkpoint number */
/* out: lsn of of the start of the first log file */ ib_ulonglong* first_header_lsn)
/* out: lsn of of the start of the
first log file */
{ {
ulint max_cp = 0; ulint max_cp = 0;
dulint max_cp_no = ut_dulint_zero; ib_ulonglong max_cp_no = 0;
byte* cp_buf; byte* cp_buf;
cp_buf = hdr + LOG_CHECKPOINT_1; cp_buf = hdr + LOG_CHECKPOINT_1;
if (recv_check_cp_is_consistent(cp_buf)) { if (recv_check_cp_is_consistent(cp_buf)) {
max_cp_no = mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO); max_cp_no = mach_read_ull(cp_buf + LOG_CHECKPOINT_NO);
max_cp = LOG_CHECKPOINT_1; max_cp = LOG_CHECKPOINT_1;
} }
cp_buf = hdr + LOG_CHECKPOINT_2; cp_buf = hdr + LOG_CHECKPOINT_2;
if (recv_check_cp_is_consistent(cp_buf)) { if (recv_check_cp_is_consistent(cp_buf)) {
if (ut_dulint_cmp(mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO), if (mach_read_ull(cp_buf + LOG_CHECKPOINT_NO) > max_cp_no) {
max_cp_no) > 0) {
max_cp = LOG_CHECKPOINT_2; max_cp = LOG_CHECKPOINT_2;
} }
} }
...@@ -604,7 +604,7 @@ recv_read_cp_info_for_backup( ...@@ -604,7 +604,7 @@ recv_read_cp_info_for_backup(
cp_buf = hdr + max_cp; cp_buf = hdr + max_cp;
*lsn = mach_read_from_8(cp_buf + LOG_CHECKPOINT_LSN); *lsn = mach_read_ull(cp_buf + LOG_CHECKPOINT_LSN);
*offset = mach_read_from_4(cp_buf + LOG_CHECKPOINT_OFFSET); *offset = mach_read_from_4(cp_buf + LOG_CHECKPOINT_OFFSET);
/* If the user is running a pre-3.23.50 version of InnoDB, its /* If the user is running a pre-3.23.50 version of InnoDB, its
...@@ -624,9 +624,9 @@ recv_read_cp_info_for_backup( ...@@ -624,9 +624,9 @@ recv_read_cp_info_for_backup(
/* fprintf(stderr, "fsp limit %lu MB\n", *fsp_limit); */ /* fprintf(stderr, "fsp limit %lu MB\n", *fsp_limit); */
*cp_no = mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO); *cp_no = mach_read_ull(cp_buf + LOG_CHECKPOINT_NO);
*first_header_lsn = mach_read_from_8(hdr + LOG_FILE_START_LSN); *first_header_lsn = mach_read_ull(hdr + LOG_FILE_START_LSN);
return(TRUE); return(TRUE);
} }
...@@ -676,7 +676,7 @@ recv_scan_log_seg_for_backup( ...@@ -676,7 +676,7 @@ recv_scan_log_seg_for_backup(
/*=========================*/ /*=========================*/
byte* buf, /* in: buffer containing log data */ byte* buf, /* in: buffer containing log data */
ulint buf_len, /* in: data length in that buffer */ ulint buf_len, /* in: data length in that buffer */
dulint* scanned_lsn, /* in/out: lsn of buffer start, ib_ulonglong* scanned_lsn, /* in/out: lsn of buffer start,
we return scanned lsn */ we return scanned lsn */
ulint* scanned_checkpoint_no, ulint* scanned_checkpoint_no,
/* in/out: 4 lowest bytes of the /* in/out: 4 lowest bytes of the
...@@ -741,7 +741,7 @@ recv_scan_log_seg_for_backup( ...@@ -741,7 +741,7 @@ recv_scan_log_seg_for_backup(
*scanned_checkpoint_no *scanned_checkpoint_no
= log_block_get_checkpoint_no(log_block); = log_block_get_checkpoint_no(log_block);
*scanned_lsn = ut_dulint_add(*scanned_lsn, data_len); *scanned_lsn += data_len;
*n_bytes_scanned += data_len; *n_bytes_scanned += data_len;
...@@ -1040,8 +1040,8 @@ recv_add_to_hash_table( ...@@ -1040,8 +1040,8 @@ recv_add_to_hash_table(
ulint page_no, /* in: page number */ ulint page_no, /* in: page number */
byte* body, /* in: log record body */ byte* body, /* in: log record body */
byte* rec_end, /* in: log record end */ byte* rec_end, /* in: log record end */
dulint start_lsn, /* in: start lsn of the mtr */ ib_ulonglong start_lsn, /* in: start lsn of the mtr */
dulint end_lsn) /* in: end lsn of the mtr */ ib_ulonglong end_lsn) /* in: end lsn of the mtr */
{ {
recv_t* recv; recv_t* recv;
ulint len; ulint len;
...@@ -1168,10 +1168,10 @@ recv_recover_page( ...@@ -1168,10 +1168,10 @@ recv_recover_page(
recv_addr_t* recv_addr; recv_addr_t* recv_addr;
recv_t* recv; recv_t* recv;
byte* buf; byte* buf;
dulint start_lsn; ib_ulonglong start_lsn;
dulint end_lsn; ib_ulonglong end_lsn;
dulint page_lsn; ib_ulonglong page_lsn;
dulint page_newest_lsn; ib_ulonglong page_newest_lsn;
ibool modification_to_page; ibool modification_to_page;
ibool success; ibool success;
mtr_t mtr; mtr_t mtr;
...@@ -1236,7 +1236,7 @@ recv_recover_page( ...@@ -1236,7 +1236,7 @@ recv_recover_page(
} }
/* Read the newest modification lsn from the page */ /* Read the newest modification lsn from the page */
page_lsn = mach_read_from_8(page + FIL_PAGE_LSN); page_lsn = mach_read_ull(page + FIL_PAGE_LSN);
if (!recover_backup) { if (!recover_backup) {
/* It may be that the page has been modified in the buffer /* It may be that the page has been modified in the buffer
...@@ -1244,7 +1244,7 @@ recv_recover_page( ...@@ -1244,7 +1244,7 @@ recv_recover_page(
page_newest_lsn = buf_block_get_newest_modification(block); page_newest_lsn = buf_block_get_newest_modification(block);
if (!ut_dulint_is_zero(page_newest_lsn)) { if (page_newest_lsn) {
page_lsn = page_newest_lsn; page_lsn = page_newest_lsn;
} }
...@@ -1252,11 +1252,11 @@ recv_recover_page( ...@@ -1252,11 +1252,11 @@ recv_recover_page(
/* In recovery from a backup we do not really use the buffer /* In recovery from a backup we do not really use the buffer
pool */ pool */
page_newest_lsn = ut_dulint_zero; page_newest_lsn = 0;
} }
modification_to_page = FALSE; modification_to_page = FALSE;
start_lsn = end_lsn = ut_dulint_zero; start_lsn = end_lsn = 0;
recv = UT_LIST_GET_FIRST(recv_addr->rec_list); recv = UT_LIST_GET_FIRST(recv_addr->rec_list);
...@@ -1277,13 +1277,12 @@ recv_recover_page( ...@@ -1277,13 +1277,12 @@ recv_recover_page(
if (recv->type == MLOG_INIT_FILE_PAGE) { if (recv->type == MLOG_INIT_FILE_PAGE) {
page_lsn = page_newest_lsn; page_lsn = page_newest_lsn;
mach_write_to_8(page + UNIV_PAGE_SIZE mach_write_ull(page + UNIV_PAGE_SIZE
- FIL_PAGE_END_LSN_OLD_CHKSUM, - FIL_PAGE_END_LSN_OLD_CHKSUM, 0);
ut_dulint_zero); mach_write_ull(page + FIL_PAGE_LSN, 0);
mach_write_to_8(page + FIL_PAGE_LSN, ut_dulint_zero);
} }
if (ut_dulint_cmp(recv->start_lsn, page_lsn) >= 0) { if (recv->start_lsn >= page_lsn) {
if (!modification_to_page) { if (!modification_to_page) {
...@@ -1306,13 +1305,11 @@ recv_recover_page( ...@@ -1306,13 +1305,11 @@ recv_recover_page(
recv_parse_or_apply_log_rec_body(recv->type, buf, recv_parse_or_apply_log_rec_body(recv->type, buf,
buf + recv->len, buf + recv->len,
block, &mtr); block, &mtr);
mach_write_to_8(page + UNIV_PAGE_SIZE mach_write_ull(page + UNIV_PAGE_SIZE
- FIL_PAGE_END_LSN_OLD_CHKSUM, - FIL_PAGE_END_LSN_OLD_CHKSUM,
ut_dulint_add(recv->start_lsn, recv->start_lsn + recv->len);
recv->len)); mach_write_ull(page + FIL_PAGE_LSN,
mach_write_to_8(page + FIL_PAGE_LSN, recv->start_lsn + recv->len);
ut_dulint_add(recv->start_lsn,
recv->len));
} }
if (recv->len > RECV_DATA_BLOCK_SIZE) { if (recv->len > RECV_DATA_BLOCK_SIZE) {
...@@ -1324,7 +1321,7 @@ recv_recover_page( ...@@ -1324,7 +1321,7 @@ recv_recover_page(
mutex_enter(&(recv_sys->mutex)); mutex_enter(&(recv_sys->mutex));
if (ut_dulint_cmp(recv_max_page_lsn, page_lsn) < 0) { if (recv_max_page_lsn < page_lsn) {
recv_max_page_lsn = page_lsn; recv_max_page_lsn = page_lsn;
} }
...@@ -1522,7 +1519,7 @@ recv_apply_hashed_log_recs( ...@@ -1522,7 +1519,7 @@ recv_apply_hashed_log_recs(
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
n_pages = buf_flush_batch(BUF_FLUSH_LIST, ULINT_MAX, n_pages = buf_flush_batch(BUF_FLUSH_LIST, ULINT_MAX,
ut_dulint_max); IB_ULONGLONG_MAX);
ut_a(n_pages != ULINT_UNDEFINED); ut_a(n_pages != ULINT_UNDEFINED);
buf_flush_wait_batch_end(BUF_FLUSH_LIST); buf_flush_wait_batch_end(BUF_FLUSH_LIST);
...@@ -1661,7 +1658,7 @@ recv_apply_log_recs_for_backup(void) ...@@ -1661,7 +1658,7 @@ recv_apply_log_recs_for_backup(void)
buf_flush_init_for_writing( buf_flush_init_for_writing(
block->frame, buf_block_get_page_zip(block), block->frame, buf_block_get_page_zip(block),
mach_read_from_8(block->frame + FIL_PAGE_LSN)); mach_read_ull(block->frame + FIL_PAGE_LSN));
if (zip_size) { if (zip_size) {
error = fil_io(OS_FILE_WRITE, TRUE, error = fil_io(OS_FILE_WRITE, TRUE,
...@@ -1767,17 +1764,17 @@ recv_parse_log_rec( ...@@ -1767,17 +1764,17 @@ recv_parse_log_rec(
/*********************************************************** /***********************************************************
Calculates the new value for lsn when more data is added to the log. */ Calculates the new value for lsn when more data is added to the log. */
static static
dulint ib_ulonglong
recv_calc_lsn_on_data_add( recv_calc_lsn_on_data_add(
/*======================*/ /*======================*/
dulint lsn, /* in: old lsn */ ib_ulonglong lsn, /* in: old lsn */
ulint len) /* in: this many bytes of data is added, log block ib_ulonglong len) /* in: this many bytes of data is
headers not included */ added, log block headers not included */
{ {
ulint frag_len; ulint frag_len;
ulint lsn_len; ulint lsn_len;
frag_len = (ut_dulint_get_low(lsn) % OS_FILE_LOG_BLOCK_SIZE) frag_len = (((ulint) lsn) % OS_FILE_LOG_BLOCK_SIZE)
- LOG_BLOCK_HDR_SIZE; - LOG_BLOCK_HDR_SIZE;
ut_ad(frag_len < OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_HDR_SIZE ut_ad(frag_len < OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_HDR_SIZE
- LOG_BLOCK_TRL_SIZE); - LOG_BLOCK_TRL_SIZE);
...@@ -1786,7 +1783,7 @@ recv_calc_lsn_on_data_add( ...@@ -1786,7 +1783,7 @@ recv_calc_lsn_on_data_add(
- LOG_BLOCK_TRL_SIZE)) - LOG_BLOCK_TRL_SIZE))
* (LOG_BLOCK_HDR_SIZE + LOG_BLOCK_TRL_SIZE); * (LOG_BLOCK_HDR_SIZE + LOG_BLOCK_TRL_SIZE);
return(ut_dulint_add(lsn, lsn_len)); return(lsn + lsn_len);
} }
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
...@@ -1827,12 +1824,11 @@ recv_report_corrupt_log( ...@@ -1827,12 +1824,11 @@ recv_report_corrupt_log(
fprintf(stderr, fprintf(stderr,
"InnoDB: ############### CORRUPT LOG RECORD FOUND\n" "InnoDB: ############### CORRUPT LOG RECORD FOUND\n"
"InnoDB: Log record type %lu, space id %lu, page number %lu\n" "InnoDB: Log record type %lu, space id %lu, page number %lu\n"
"InnoDB: Log parsing proceeded successfully up to %lu %lu\n" "InnoDB: Log parsing proceeded successfully up to %llu\n"
"InnoDB: Previous log record type %lu, is multi %lu\n" "InnoDB: Previous log record type %lu, is multi %lu\n"
"InnoDB: Recv offset %lu, prev %lu\n", "InnoDB: Recv offset %lu, prev %lu\n",
(ulong) type, (ulong) space, (ulong) page_no, (ulong) type, (ulong) space, (ulong) page_no,
(ulong) ut_dulint_get_high(recv_sys->recovered_lsn), recv_sys->recovered_lsn,
(ulong) ut_dulint_get_low(recv_sys->recovered_lsn),
(ulong) recv_previous_parsed_rec_type, (ulong) recv_previous_parsed_rec_type,
(ulong) recv_previous_parsed_rec_is_multi, (ulong) recv_previous_parsed_rec_is_multi,
(ulong) (ptr - recv_sys->buf), (ulong) (ptr - recv_sys->buf),
...@@ -1887,8 +1883,8 @@ recv_parse_log_recs( ...@@ -1887,8 +1883,8 @@ recv_parse_log_recs(
ulint single_rec; ulint single_rec;
ulint len; ulint len;
ulint total_len; ulint total_len;
dulint new_recovered_lsn; ib_ulonglong new_recovered_lsn;
dulint old_lsn; ib_ulonglong old_lsn;
byte type; byte type;
ulint space; ulint space;
ulint page_no; ulint page_no;
...@@ -1898,7 +1894,7 @@ recv_parse_log_recs( ...@@ -1898,7 +1894,7 @@ recv_parse_log_recs(
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(log_sys->mutex))); ut_ad(mutex_own(&(log_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_ad(!ut_dulint_is_zero(recv_sys->parse_start_lsn)); ut_ad(recv_sys->parse_start_lsn != 0);
loop: loop:
ptr = recv_sys->buf + recv_sys->recovered_offset; ptr = recv_sys->buf + recv_sys->recovered_offset;
...@@ -1934,8 +1930,7 @@ recv_parse_log_recs( ...@@ -1934,8 +1930,7 @@ recv_parse_log_recs(
new_recovered_lsn = recv_calc_lsn_on_data_add(old_lsn, len); new_recovered_lsn = recv_calc_lsn_on_data_add(old_lsn, len);
if (ut_dulint_cmp(new_recovered_lsn, recv_sys->scanned_lsn) if (new_recovered_lsn > recv_sys->scanned_lsn) {
> 0) {
/* The log record filled a log block, and we require /* The log record filled a log block, and we require
that also the next log block should have been scanned that also the next log block should have been scanned
in */ in */
...@@ -2065,8 +2060,7 @@ recv_parse_log_recs( ...@@ -2065,8 +2060,7 @@ recv_parse_log_recs(
new_recovered_lsn = recv_calc_lsn_on_data_add( new_recovered_lsn = recv_calc_lsn_on_data_add(
recv_sys->recovered_lsn, total_len); recv_sys->recovered_lsn, total_len);
if (ut_dulint_cmp(new_recovered_lsn, recv_sys->scanned_lsn) if (new_recovered_lsn > recv_sys->scanned_lsn) {
> 0) {
/* The log record filled a log block, and we require /* The log record filled a log block, and we require
that also the next log block should have been scanned that also the next log block should have been scanned
in */ in */
...@@ -2124,17 +2118,17 @@ recv_sys_add_to_parsing_buf( ...@@ -2124,17 +2118,17 @@ recv_sys_add_to_parsing_buf(
/*========================*/ /*========================*/
/* out: TRUE if more data added */ /* out: TRUE if more data added */
byte* log_block, /* in: log block */ byte* log_block, /* in: log block */
dulint scanned_lsn) /* in: lsn of how far we were able to find ib_ulonglong scanned_lsn) /* in: lsn of how far we were able
data in this log block */ to find data in this log block */
{ {
ulint more_len; ulint more_len;
ulint data_len; ulint data_len;
ulint start_offset; ulint start_offset;
ulint end_offset; ulint end_offset;
ut_ad(ut_dulint_cmp(scanned_lsn, recv_sys->scanned_lsn) >= 0); ut_ad(scanned_lsn >= recv_sys->scanned_lsn);
if (ut_dulint_is_zero(recv_sys->parse_start_lsn)) { if (!recv_sys->parse_start_lsn) {
/* Cannot start parsing yet because no start point for /* Cannot start parsing yet because no start point for
it found */ it found */
...@@ -2143,20 +2137,18 @@ recv_sys_add_to_parsing_buf( ...@@ -2143,20 +2137,18 @@ recv_sys_add_to_parsing_buf(
data_len = log_block_get_data_len(log_block); data_len = log_block_get_data_len(log_block);
if (ut_dulint_cmp(recv_sys->parse_start_lsn, scanned_lsn) >= 0) { if (recv_sys->parse_start_lsn >= scanned_lsn) {
return(FALSE); return(FALSE);
} else if (ut_dulint_cmp(recv_sys->scanned_lsn, scanned_lsn) >= 0) { } else if (recv_sys->scanned_lsn >= scanned_lsn) {
return(FALSE); return(FALSE);
} else if (ut_dulint_cmp(recv_sys->parse_start_lsn, } else if (recv_sys->parse_start_lsn > recv_sys->scanned_lsn) {
recv_sys->scanned_lsn) > 0) { more_len = (ulint) (scanned_lsn - recv_sys->parse_start_lsn);
more_len = ut_dulint_minus(scanned_lsn,
recv_sys->parse_start_lsn);
} else { } else {
more_len = ut_dulint_minus(scanned_lsn, recv_sys->scanned_lsn); more_len = (ulint) (scanned_lsn - recv_sys->scanned_lsn);
} }
if (more_len == 0) { if (more_len == 0) {
...@@ -2214,34 +2206,39 @@ and hashes the log records if new data found. */ ...@@ -2214,34 +2206,39 @@ and hashes the log records if new data found. */
ibool ibool
recv_scan_log_recs( recv_scan_log_recs(
/*===============*/ /*===============*/
/* out: TRUE if limit_lsn has been reached, or /* out: TRUE if limit_lsn has been
not able to scan any more in this log group */ reached, or not able to scan any more
ibool apply_automatically,/* in: TRUE if we want this function to in this log group */
apply log records automatically when the ibool apply_automatically,/* in: TRUE if we want this
hash table becomes full; in the hot backup tool function to apply log records
automatically when the hash table
becomes full; in the hot backup tool
the tool does the applying, not this the tool does the applying, not this
function */ function */
ulint available_memory,/* in: we let the hash table of recs to grow ulint available_memory,/* in: we let the hash table of recs
to this size, at the maximum */ to grow to this size, at the maximum */
ibool store_to_hash, /* in: TRUE if the records should be stored ibool store_to_hash, /* in: TRUE if the records should be
to the hash table; this is set to FALSE if just stored to the hash table; this is set
debug checking is needed */ to FALSE if just debug checking is
byte* buf, /* in: buffer containing a log segment or needed */
garbage */ byte* buf, /* in: buffer containing a log segment
or garbage */
ulint len, /* in: buffer length */ ulint len, /* in: buffer length */
dulint start_lsn, /* in: buffer start lsn */ ib_ulonglong start_lsn, /* in: buffer start lsn */
dulint* contiguous_lsn, /* in/out: it is known that all log groups ib_ulonglong* contiguous_lsn, /* in/out: it is known that all log
contain contiguous log data up to this lsn */ groups contain contiguous log data up
dulint* group_scanned_lsn)/* out: scanning succeeded up to this lsn */ to this lsn */
ib_ulonglong* group_scanned_lsn)/* out: scanning succeeded up to
this lsn */
{ {
byte* log_block; byte* log_block;
ulint no; ulint no;
dulint scanned_lsn; ib_ulonglong scanned_lsn;
ibool finished; ibool finished;
ulint data_len; ulint data_len;
ibool more_data; ibool more_data;
ut_ad(ut_dulint_get_low(start_lsn) % OS_FILE_LOG_BLOCK_SIZE == 0); ut_ad(start_lsn % OS_FILE_LOG_BLOCK_SIZE == 0);
ut_ad(len % OS_FILE_LOG_BLOCK_SIZE == 0); ut_ad(len % OS_FILE_LOG_BLOCK_SIZE == 0);
ut_ad(len > 0); ut_ad(len > 0);
ut_a(apply_automatically <= TRUE); ut_a(apply_automatically <= TRUE);
...@@ -2270,13 +2267,11 @@ recv_scan_log_recs( ...@@ -2270,13 +2267,11 @@ recv_scan_log_recs(
log_block)) { log_block)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Log block no %lu at" "InnoDB: Log block no %lu at"
" lsn %lu %lu has\n" " lsn %llu has\n"
"InnoDB: ok header, but checksum field" "InnoDB: ok header, but checksum field"
" contains %lu, should be %lu\n", " contains %lu, should be %lu\n",
(ulong) no, (ulong) no,
(ulong) ut_dulint_get_high( scanned_lsn,
scanned_lsn),
(ulong) ut_dulint_get_low(scanned_lsn),
(ulong) log_block_get_checksum( (ulong) log_block_get_checksum(
log_block), log_block),
(ulong) log_block_calc_checksum( (ulong) log_block_calc_checksum(
...@@ -2298,7 +2293,7 @@ recv_scan_log_recs( ...@@ -2298,7 +2293,7 @@ recv_scan_log_recs(
we know that log data is contiguous up to scanned_lsn we know that log data is contiguous up to scanned_lsn
in all non-corrupt log groups. */ in all non-corrupt log groups. */
if (ut_dulint_cmp(scanned_lsn, *contiguous_lsn) > 0) { if (scanned_lsn > *contiguous_lsn) {
*contiguous_lsn = scanned_lsn; *contiguous_lsn = scanned_lsn;
} }
} }
...@@ -2306,8 +2301,7 @@ recv_scan_log_recs( ...@@ -2306,8 +2301,7 @@ recv_scan_log_recs(
data_len = log_block_get_data_len(log_block); data_len = log_block_get_data_len(log_block);
if ((store_to_hash || (data_len == OS_FILE_LOG_BLOCK_SIZE)) if ((store_to_hash || (data_len == OS_FILE_LOG_BLOCK_SIZE))
&& (ut_dulint_cmp(ut_dulint_add(scanned_lsn, data_len), && scanned_lsn + data_len > recv_sys->scanned_lsn
recv_sys->scanned_lsn) > 0)
&& (recv_sys->scanned_checkpoint_no > 0) && (recv_sys->scanned_checkpoint_no > 0)
&& (log_block_get_checkpoint_no(log_block) && (log_block_get_checkpoint_no(log_block)
< recv_sys->scanned_checkpoint_no) < recv_sys->scanned_checkpoint_no)
...@@ -2328,23 +2322,21 @@ recv_scan_log_recs( ...@@ -2328,23 +2322,21 @@ recv_scan_log_recs(
break; break;
} }
if (ut_dulint_is_zero(recv_sys->parse_start_lsn) if (!recv_sys->parse_start_lsn
&& (log_block_get_first_rec_group(log_block) > 0)) { && (log_block_get_first_rec_group(log_block) > 0)) {
/* We found a point from which to start the parsing /* We found a point from which to start the parsing
of log records */ of log records */
recv_sys->parse_start_lsn recv_sys->parse_start_lsn = scanned_lsn
= ut_dulint_add(scanned_lsn, + log_block_get_first_rec_group(log_block);
log_block_get_first_rec_group(
log_block));
recv_sys->scanned_lsn = recv_sys->parse_start_lsn; recv_sys->scanned_lsn = recv_sys->parse_start_lsn;
recv_sys->recovered_lsn = recv_sys->parse_start_lsn; recv_sys->recovered_lsn = recv_sys->parse_start_lsn;
} }
scanned_lsn = ut_dulint_add(scanned_lsn, data_len); scanned_lsn += data_len;
if (ut_dulint_cmp(scanned_lsn, recv_sys->scanned_lsn) > 0) { if (scanned_lsn > recv_sys->scanned_lsn) {
/* We were able to find more log data: add it to the /* We were able to find more log data: add it to the
parsing buffer if parse_start_lsn is already parsing buffer if parse_start_lsn is already
...@@ -2388,9 +2380,8 @@ recv_scan_log_recs( ...@@ -2388,9 +2380,8 @@ recv_scan_log_recs(
fprintf(stderr, fprintf(stderr,
"InnoDB: Doing recovery: scanned up to" "InnoDB: Doing recovery: scanned up to"
" log sequence number %lu %lu\n", " log sequence number %llu\n",
(ulong) ut_dulint_get_high(*group_scanned_lsn), *group_scanned_lsn);
(ulong) ut_dulint_get_low(*group_scanned_lsn));
} }
} }
...@@ -2430,20 +2421,22 @@ void ...@@ -2430,20 +2421,22 @@ void
recv_group_scan_log_recs( recv_group_scan_log_recs(
/*=====================*/ /*=====================*/
log_group_t* group, /* in: log group */ log_group_t* group, /* in: log group */
dulint* contiguous_lsn, /* in/out: it is known that all log groups ib_ulonglong* contiguous_lsn, /* in/out: it is known that all log
contain contiguous log data up to this lsn */ groups contain contiguous log data up
dulint* group_scanned_lsn)/* out: scanning succeeded up to this lsn */ to this lsn */
ib_ulonglong* group_scanned_lsn)/* out: scanning succeeded up to
this lsn */
{ {
ibool finished; ibool finished;
dulint start_lsn; ib_ulonglong start_lsn;
dulint end_lsn; ib_ulonglong end_lsn;
finished = FALSE; finished = FALSE;
start_lsn = *contiguous_lsn; start_lsn = *contiguous_lsn;
while (!finished) { while (!finished) {
end_lsn = ut_dulint_add(start_lsn, RECV_SCAN_SIZE); end_lsn = start_lsn + RECV_SCAN_SIZE;
log_group_read_log_seg(LOG_RECOVER, log_sys->buf, log_group_read_log_seg(LOG_RECOVER, log_sys->buf,
group, start_lsn, end_lsn); group, start_lsn, end_lsn);
...@@ -2459,10 +2452,9 @@ recv_group_scan_log_recs( ...@@ -2459,10 +2452,9 @@ recv_group_scan_log_recs(
if (log_debug_writes) { if (log_debug_writes) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Scanned group %lu up to" "InnoDB: Scanned group %lu up to"
" log sequence number %lu %lu\n", " log sequence number %llu\n",
(ulong) group->id, (ulong) group->id,
(ulong) ut_dulint_get_high(*group_scanned_lsn), *group_scanned_lsn);
(ulong) ut_dulint_get_low(*group_scanned_lsn));
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
} }
...@@ -2478,27 +2470,29 @@ recv_recovery_from_checkpoint_start( ...@@ -2478,27 +2470,29 @@ recv_recovery_from_checkpoint_start(
/*================================*/ /*================================*/
/* out: error code or DB_SUCCESS */ /* out: error code or DB_SUCCESS */
ulint type, /* in: LOG_CHECKPOINT or LOG_ARCHIVE */ ulint type, /* in: LOG_CHECKPOINT or LOG_ARCHIVE */
dulint limit_lsn, /* in: recover up to this lsn if possible */ ib_ulonglong limit_lsn, /* in: recover up to this lsn
dulint min_flushed_lsn,/* in: min flushed lsn from data files */ if possible */
dulint max_flushed_lsn)/* in: max flushed lsn from data files */ ib_ulonglong min_flushed_lsn,/* in: min flushed lsn from
data files */
ib_ulonglong max_flushed_lsn)/* in: max flushed lsn from
data files */
{ {
log_group_t* group; log_group_t* group;
log_group_t* max_cp_group; log_group_t* max_cp_group;
log_group_t* up_to_date_group; log_group_t* up_to_date_group;
ulint max_cp_field; ulint max_cp_field;
dulint checkpoint_lsn; ib_ulonglong checkpoint_lsn;
dulint checkpoint_no; ib_ulonglong checkpoint_no;
dulint old_scanned_lsn; ib_ulonglong old_scanned_lsn;
dulint group_scanned_lsn; ib_ulonglong group_scanned_lsn;
dulint contiguous_lsn; ib_ulonglong contiguous_lsn;
dulint archived_lsn; ib_ulonglong archived_lsn;
ulint capacity; ulint capacity;
byte* buf; byte* buf;
byte log_hdr_buf[LOG_FILE_HDR_SIZE]; byte log_hdr_buf[LOG_FILE_HDR_SIZE];
ulint err; ulint err;
ut_ad((type != LOG_CHECKPOINT) ut_ad(type != LOG_CHECKPOINT || limit_lsn == IB_ULONGLONG_MAX);
|| (ut_dulint_cmp(limit_lsn, ut_dulint_max) == 0));
if (type == LOG_CHECKPOINT) { if (type == LOG_CHECKPOINT) {
recv_sys_create(); recv_sys_create();
...@@ -2535,9 +2529,9 @@ recv_recovery_from_checkpoint_start( ...@@ -2535,9 +2529,9 @@ recv_recovery_from_checkpoint_start(
buf = log_sys->checkpoint_buf; buf = log_sys->checkpoint_buf;
checkpoint_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_LSN); checkpoint_lsn = mach_read_ull(buf + LOG_CHECKPOINT_LSN);
checkpoint_no = mach_read_from_8(buf + LOG_CHECKPOINT_NO); checkpoint_no = mach_read_ull(buf + LOG_CHECKPOINT_NO);
archived_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_ARCHIVED_LSN); archived_lsn = mach_read_ull(buf + LOG_CHECKPOINT_ARCHIVED_LSN);
/* Read the first log file header to print a note if this is /* Read the first log file header to print a note if this is
a recovery from a restored InnoDB Hot Backup */ a recovery from a restored InnoDB Hot Backup */
...@@ -2599,11 +2593,10 @@ recv_recovery_from_checkpoint_start( ...@@ -2599,11 +2593,10 @@ recv_recovery_from_checkpoint_start(
there is something wrong we will print a message to the there is something wrong we will print a message to the
user about recovery: */ user about recovery: */
if (ut_dulint_cmp(checkpoint_lsn, max_flushed_lsn) != 0 if (checkpoint_lsn != max_flushed_lsn
|| ut_dulint_cmp(checkpoint_lsn, min_flushed_lsn) != 0) { || checkpoint_lsn != min_flushed_lsn) {
if (ut_dulint_cmp(checkpoint_lsn, max_flushed_lsn) if (checkpoint_lsn < max_flushed_lsn) {
< 0) {
fprintf(stderr, fprintf(stderr,
"InnoDB: #########################" "InnoDB: #########################"
"#################################\n" "#################################\n"
...@@ -2617,24 +2610,15 @@ recv_recovery_from_checkpoint_start( ...@@ -2617,24 +2610,15 @@ recv_recovery_from_checkpoint_start(
" ib_logfiles to start up" " ib_logfiles to start up"
" the database?\n" " the database?\n"
"InnoDB: Log sequence number in" "InnoDB: Log sequence number in"
" ib_logfiles is %lu %lu, log\n" " ib_logfiles is %llu, log\n"
"InnoDB: sequence numbers stamped" "InnoDB: sequence numbers stamped"
" to ibdata file headers are between\n" " to ibdata file headers are between\n"
"InnoDB: %lu %lu and %lu %lu.\n" "InnoDB: %llu and %llu.\n"
"InnoDB: #########################" "InnoDB: #########################"
"#################################\n", "#################################\n",
(ulong) ut_dulint_get_high( checkpoint_lsn,
checkpoint_lsn), min_flushed_lsn,
(ulong) ut_dulint_get_low( max_flushed_lsn);
checkpoint_lsn),
(ulong) ut_dulint_get_high(
min_flushed_lsn),
(ulong) ut_dulint_get_low(
min_flushed_lsn),
(ulong) ut_dulint_get_high(
max_flushed_lsn),
(ulong) ut_dulint_get_low(
max_flushed_lsn));
} }
recv_needed_recovery = TRUE; recv_needed_recovery = TRUE;
...@@ -2673,16 +2657,15 @@ recv_recovery_from_checkpoint_start( ...@@ -2673,16 +2657,15 @@ recv_recovery_from_checkpoint_start(
fprintf(stderr, fprintf(stderr,
" InnoDB: Starting log scan" " InnoDB: Starting log scan"
" based on checkpoint at\n" " based on checkpoint at\n"
"InnoDB: log sequence number %lu %lu.\n", "InnoDB: log sequence number %llu.\n",
(ulong) ut_dulint_get_high(checkpoint_lsn), checkpoint_lsn);
(ulong) ut_dulint_get_low(checkpoint_lsn));
} else { } else {
/* Init the doublewrite buffer memory structure */ /* Init the doublewrite buffer memory structure */
trx_sys_doublewrite_init_or_restore_pages(FALSE); trx_sys_doublewrite_init_or_restore_pages(FALSE);
} }
} }
contiguous_lsn = ut_dulint_align_down(recv_sys->scanned_lsn, contiguous_lsn = ut_ulonglong_align_down(recv_sys->scanned_lsn,
OS_FILE_LOG_BLOCK_SIZE); OS_FILE_LOG_BLOCK_SIZE);
if (type == LOG_ARCHIVE) { if (type == LOG_ARCHIVE) {
/* Try to recover the remaining part from logs: first from /* Try to recover the remaining part from logs: first from
...@@ -2691,11 +2674,8 @@ recv_recovery_from_checkpoint_start( ...@@ -2691,11 +2674,8 @@ recv_recovery_from_checkpoint_start(
group = recv_sys->archive_group; group = recv_sys->archive_group;
capacity = log_group_get_capacity(group); capacity = log_group_get_capacity(group);
if ((ut_dulint_cmp(recv_sys->scanned_lsn, ut_dulint_add( if (recv_sys->scanned_lsn > checkpoint_lsn + capacity
checkpoint_lsn, capacity)) > 0) || checkpoint_lsn > recv_sys->scanned_lsn + capacity) {
|| (ut_dulint_cmp(checkpoint_lsn, ut_dulint_add(
recv_sys->scanned_lsn, capacity))
> 0)) {
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
...@@ -2707,7 +2687,7 @@ recv_recovery_from_checkpoint_start( ...@@ -2707,7 +2687,7 @@ recv_recovery_from_checkpoint_start(
recv_group_scan_log_recs(group, &contiguous_lsn, recv_group_scan_log_recs(group, &contiguous_lsn,
&group_scanned_lsn); &group_scanned_lsn);
if (ut_dulint_cmp(recv_sys->scanned_lsn, checkpoint_lsn) < 0) { if (recv_sys->scanned_lsn < checkpoint_lsn) {
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
...@@ -2739,7 +2719,7 @@ recv_recovery_from_checkpoint_start( ...@@ -2739,7 +2719,7 @@ recv_recovery_from_checkpoint_start(
&group_scanned_lsn); &group_scanned_lsn);
group->scanned_lsn = group_scanned_lsn; group->scanned_lsn = group_scanned_lsn;
if (ut_dulint_cmp(old_scanned_lsn, group_scanned_lsn) < 0) { if (old_scanned_lsn < group_scanned_lsn) {
/* We found a more up-to-date group */ /* We found a more up-to-date group */
up_to_date_group = group; up_to_date_group = group;
...@@ -2754,39 +2734,35 @@ recv_recovery_from_checkpoint_start( ...@@ -2754,39 +2734,35 @@ recv_recovery_from_checkpoint_start(
} }
/* We currently have only one log group */ /* We currently have only one log group */
if (ut_dulint_cmp(group_scanned_lsn, checkpoint_lsn) < 0) { if (group_scanned_lsn < checkpoint_lsn) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: ERROR: We were only able to scan the log" " InnoDB: ERROR: We were only able to scan the log"
" up to\n" " up to\n"
"InnoDB: %lu %lu, but a checkpoint was at %lu %lu.\n" "InnoDB: %llu, but a checkpoint was at %llu.\n"
"InnoDB: It is possible that" "InnoDB: It is possible that"
" the database is now corrupt!\n", " the database is now corrupt!\n",
(ulong) ut_dulint_get_high(group_scanned_lsn), group_scanned_lsn,
(ulong) ut_dulint_get_low(group_scanned_lsn), checkpoint_lsn);
(ulong) ut_dulint_get_high(checkpoint_lsn),
(ulong) ut_dulint_get_low(checkpoint_lsn));
} }
if (ut_dulint_cmp(group_scanned_lsn, recv_max_page_lsn) < 0) { if (group_scanned_lsn < recv_max_page_lsn) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: ERROR: We were only able to scan the log" " InnoDB: ERROR: We were only able to scan the log"
" up to %lu %lu\n" " up to %llu\n"
"InnoDB: but a database page a had an lsn %lu %lu." "InnoDB: but a database page a had an lsn %llu."
" It is possible that the\n" " It is possible that the\n"
"InnoDB: database is now corrupt!\n", "InnoDB: database is now corrupt!\n",
(ulong) ut_dulint_get_high(group_scanned_lsn), group_scanned_lsn,
(ulong) ut_dulint_get_low(group_scanned_lsn), recv_max_page_lsn);
(ulong) ut_dulint_get_high(recv_max_page_lsn),
(ulong) ut_dulint_get_low(recv_max_page_lsn));
} }
if (ut_dulint_cmp(recv_sys->recovered_lsn, checkpoint_lsn) < 0) { if (recv_sys->recovered_lsn < checkpoint_lsn) {
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
if (ut_dulint_cmp(recv_sys->recovered_lsn, limit_lsn) >= 0) { if (recv_sys->recovered_lsn >= limit_lsn) {
return(DB_SUCCESS); return(DB_SUCCESS);
} }
...@@ -2800,7 +2776,7 @@ recv_recovery_from_checkpoint_start( ...@@ -2800,7 +2776,7 @@ recv_recovery_from_checkpoint_start(
group; we also copy checkpoint info to groups */ group; we also copy checkpoint info to groups */
log_sys->next_checkpoint_lsn = checkpoint_lsn; log_sys->next_checkpoint_lsn = checkpoint_lsn;
log_sys->next_checkpoint_no = ut_dulint_add(checkpoint_no, 1); log_sys->next_checkpoint_no = checkpoint_no + 1;
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
log_sys->archived_lsn = archived_lsn; log_sys->archived_lsn = archived_lsn;
...@@ -2809,19 +2785,14 @@ recv_recovery_from_checkpoint_start( ...@@ -2809,19 +2785,14 @@ recv_recovery_from_checkpoint_start(
recv_synchronize_groups(up_to_date_group); recv_synchronize_groups(up_to_date_group);
if (!recv_needed_recovery) { if (!recv_needed_recovery) {
if (ut_dulint_cmp(checkpoint_lsn, recv_sys->recovered_lsn) if (checkpoint_lsn != recv_sys->recovered_lsn) {
!= 0) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Warning: we did not need to do" "InnoDB: Warning: we did not need to do"
" crash recovery, but log scan\n" " crash recovery, but log scan\n"
"InnoDB: progressed past the checkpoint" "InnoDB: progressed past the checkpoint"
" lsn %lu %lu up to lsn %lu %lu\n", " lsn %llu up to lsn %llu\n",
(ulong) ut_dulint_get_high(checkpoint_lsn), checkpoint_lsn,
(ulong) ut_dulint_get_low(checkpoint_lsn), recv_sys->recovered_lsn);
(ulong) ut_dulint_get_high(
recv_sys->recovered_lsn),
(ulong) ut_dulint_get_low(
recv_sys->recovered_lsn));
} }
} else { } else {
srv_start_lsn = recv_sys->recovered_lsn; srv_start_lsn = recv_sys->recovered_lsn;
...@@ -2831,18 +2802,17 @@ recv_recovery_from_checkpoint_start( ...@@ -2831,18 +2802,17 @@ recv_recovery_from_checkpoint_start(
ut_memcpy(log_sys->buf, recv_sys->last_block, OS_FILE_LOG_BLOCK_SIZE); ut_memcpy(log_sys->buf, recv_sys->last_block, OS_FILE_LOG_BLOCK_SIZE);
log_sys->buf_free = ut_dulint_get_low(log_sys->lsn) log_sys->buf_free = (ulint) log_sys->lsn % OS_FILE_LOG_BLOCK_SIZE;
% OS_FILE_LOG_BLOCK_SIZE;
log_sys->buf_next_to_write = log_sys->buf_free; log_sys->buf_next_to_write = log_sys->buf_free;
log_sys->written_to_some_lsn = log_sys->lsn; log_sys->written_to_some_lsn = log_sys->lsn;
log_sys->written_to_all_lsn = log_sys->lsn; log_sys->written_to_all_lsn = log_sys->lsn;
log_sys->last_checkpoint_lsn = checkpoint_lsn; log_sys->last_checkpoint_lsn = checkpoint_lsn;
log_sys->next_checkpoint_no = ut_dulint_add(checkpoint_no, 1); log_sys->next_checkpoint_no = checkpoint_no + 1;
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
if (ut_dulint_cmp(archived_lsn, ut_dulint_max) == 0) { if (archived_lsn == IB_ULONGLONG_MAX) {
log_sys->archiving_state = LOG_ARCH_OFF; log_sys->archiving_state = LOG_ARCH_OFF;
} }
...@@ -2931,22 +2901,25 @@ Resets the logs. The contents of log files will be lost! */ ...@@ -2931,22 +2901,25 @@ Resets the logs. The contents of log files will be lost! */
void void
recv_reset_logs( recv_reset_logs(
/*============*/ /*============*/
dulint lsn, /* in: reset to this lsn rounded up to ib_ulonglong lsn, /* in: reset to this lsn
be divisible by OS_FILE_LOG_BLOCK_SIZE, rounded up to be divisible by
after which we add LOG_BLOCK_HDR_SIZE */ OS_FILE_LOG_BLOCK_SIZE, after
which we add
LOG_BLOCK_HDR_SIZE */
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
ulint arch_log_no, /* in: next archived log file number */ ulint arch_log_no, /* in: next archived log file number */
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
ibool new_logs_created)/* in: TRUE if resetting logs is done ibool new_logs_created)/* in: TRUE if resetting logs
at the log creation; FALSE if it is done is done at the log creation;
after archive recovery */ FALSE if it is done after
archive recovery */
{ {
log_group_t* group; log_group_t* group;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(log_sys->mutex))); ut_ad(mutex_own(&(log_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
log_sys->lsn = ut_dulint_align_up(lsn, OS_FILE_LOG_BLOCK_SIZE); log_sys->lsn = ut_ulonglong_align_up(lsn, OS_FILE_LOG_BLOCK_SIZE);
group = UT_LIST_GET_FIRST(log_sys->log_groups); group = UT_LIST_GET_FIRST(log_sys->log_groups);
...@@ -2970,8 +2943,8 @@ recv_reset_logs( ...@@ -2970,8 +2943,8 @@ recv_reset_logs(
log_sys->written_to_some_lsn = log_sys->lsn; log_sys->written_to_some_lsn = log_sys->lsn;
log_sys->written_to_all_lsn = log_sys->lsn; log_sys->written_to_all_lsn = log_sys->lsn;
log_sys->next_checkpoint_no = ut_dulint_zero; log_sys->next_checkpoint_no = 0;
log_sys->last_checkpoint_lsn = ut_dulint_zero; log_sys->last_checkpoint_lsn = 0;
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
log_sys->archived_lsn = log_sys->lsn; log_sys->archived_lsn = log_sys->lsn;
...@@ -2981,14 +2954,14 @@ recv_reset_logs( ...@@ -2981,14 +2954,14 @@ recv_reset_logs(
log_block_set_first_rec_group(log_sys->buf, LOG_BLOCK_HDR_SIZE); log_block_set_first_rec_group(log_sys->buf, LOG_BLOCK_HDR_SIZE);
log_sys->buf_free = LOG_BLOCK_HDR_SIZE; log_sys->buf_free = LOG_BLOCK_HDR_SIZE;
log_sys->lsn = ut_dulint_add(log_sys->lsn, LOG_BLOCK_HDR_SIZE); log_sys->lsn += LOG_BLOCK_HDR_SIZE;
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
/* Reset the checkpoint fields in logs */ /* Reset the checkpoint fields in logs */
log_make_checkpoint_at(ut_dulint_max, TRUE); log_make_checkpoint_at(IB_ULONGLONG_MAX, TRUE);
log_make_checkpoint_at(ut_dulint_max, TRUE); log_make_checkpoint_at(IB_ULONGLONG_MAX, TRUE);
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
} }
...@@ -3003,7 +2976,7 @@ recv_reset_log_files_for_backup( ...@@ -3003,7 +2976,7 @@ recv_reset_log_files_for_backup(
const char* log_dir, /* in: log file directory path */ const char* log_dir, /* in: log file directory path */
ulint n_log_files, /* in: number of log files */ ulint n_log_files, /* in: number of log files */
ulint log_file_size, /* in: log file size */ ulint log_file_size, /* in: log file size */
dulint lsn) /* in: new start lsn, must be ib_ulonglong lsn) /* in: new start lsn, must be
divisible by OS_FILE_LOG_BLOCK_SIZE */ divisible by OS_FILE_LOG_BLOCK_SIZE */
{ {
os_file_t log_file; os_file_t log_file;
...@@ -3097,10 +3070,10 @@ log_group_recover_from_archive_file( ...@@ -3097,10 +3070,10 @@ log_group_recover_from_archive_file(
log_group_t* group) /* in: log group */ log_group_t* group) /* in: log group */
{ {
os_file_t file_handle; os_file_t file_handle;
dulint start_lsn; ib_ulonglong start_lsn;
dulint file_end_lsn; ib_ulonglong file_end_lsn;
dulint dummy_lsn; ib_ulonglong dummy_lsn;
dulint scanned_lsn; ib_ulonglong scanned_lsn;
ulint len; ulint len;
ibool ret; ibool ret;
byte* buf; byte* buf;
...@@ -3196,12 +3169,12 @@ log_group_recover_from_archive_file( ...@@ -3196,12 +3169,12 @@ log_group_recover_from_archive_file(
return(TRUE); return(TRUE);
} }
start_lsn = mach_read_from_8(buf + LOG_FILE_START_LSN); start_lsn = mach_read_ull(buf + LOG_FILE_START_LSN);
file_end_lsn = mach_read_from_8(buf + LOG_FILE_END_LSN); file_end_lsn = mach_read_ull(buf + LOG_FILE_END_LSN);
if (ut_dulint_is_zero(recv_sys->scanned_lsn)) { if (!recv_sys->scanned_lsn) {
if (ut_dulint_cmp(recv_sys->parse_start_lsn, start_lsn) < 0) { if (recv_sys->parse_start_lsn < start_lsn) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Archive log file %s" "InnoDB: Archive log file %s"
" starts from too big a lsn\n", " starts from too big a lsn\n",
...@@ -3212,7 +3185,7 @@ log_group_recover_from_archive_file( ...@@ -3212,7 +3185,7 @@ log_group_recover_from_archive_file(
recv_sys->scanned_lsn = start_lsn; recv_sys->scanned_lsn = start_lsn;
} }
if (ut_dulint_cmp(recv_sys->scanned_lsn, start_lsn) != 0) { if (recv_sys->scanned_lsn != start_lsn) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Archive log file %s starts from" "InnoDB: Archive log file %s starts from"
...@@ -3240,9 +3213,8 @@ log_group_recover_from_archive_file( ...@@ -3240,9 +3213,8 @@ log_group_recover_from_archive_file(
if (log_debug_writes) { if (log_debug_writes) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Archive read starting at" "InnoDB: Archive read starting at"
" lsn %lu %lu, len %lu from file %s\n", " lsn %llu, len %lu from file %s\n",
(ulong) ut_dulint_get_high(start_lsn), start_lsn,
(ulong) ut_dulint_get_low(start_lsn),
(ulong) len, name); (ulong) len, name);
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
...@@ -3256,7 +3228,7 @@ log_group_recover_from_archive_file( ...@@ -3256,7 +3228,7 @@ log_group_recover_from_archive_file(
* UNIV_PAGE_SIZE, TRUE, buf, len, start_lsn, * UNIV_PAGE_SIZE, TRUE, buf, len, start_lsn,
&dummy_lsn, &scanned_lsn); &dummy_lsn, &scanned_lsn);
if (ut_dulint_cmp(scanned_lsn, file_end_lsn) == 0) { if (scanned_lsn == file_end_lsn) {
return(FALSE); return(FALSE);
} }
...@@ -3270,9 +3242,9 @@ log_group_recover_from_archive_file( ...@@ -3270,9 +3242,9 @@ log_group_recover_from_archive_file(
} }
read_offset += len; read_offset += len;
start_lsn = ut_dulint_add(start_lsn, len); start_lsn += len;
ut_ad(ut_dulint_cmp(start_lsn, scanned_lsn) == 0); ut_ad(start_lsn == scanned_lsn);
} }
return(FALSE); return(FALSE);
...@@ -3285,13 +3257,15 @@ ulint ...@@ -3285,13 +3257,15 @@ ulint
recv_recovery_from_archive_start( recv_recovery_from_archive_start(
/*=============================*/ /*=============================*/
/* out: error code or DB_SUCCESS */ /* out: error code or DB_SUCCESS */
dulint min_flushed_lsn,/* in: min flushed lsn field from the ib_ulonglong min_flushed_lsn,/* in: min flushed lsn field from the
data files */ data files */
dulint limit_lsn, /* in: recover up to this lsn if possible */ ib_ulonglong limit_lsn, /* in: recover up to this lsn if
ulint first_log_no) /* in: number of the first archived log file possible */
to use in the recovery; the file will be ulint first_log_no) /* in: number of the first archived
searched from INNOBASE_LOG_ARCH_DIR specified log file to use in the recovery; the
in server config file */ file will be searched from
INNOBASE_LOG_ARCH_DIR specified in
server config file */
{ {
log_group_t* group; log_group_t* group;
ulint group_id; ulint group_id;
...@@ -3333,7 +3307,7 @@ recv_recovery_from_archive_start( ...@@ -3333,7 +3307,7 @@ recv_recovery_from_archive_start(
recv_sys->parse_start_lsn = min_flushed_lsn; recv_sys->parse_start_lsn = min_flushed_lsn;
recv_sys->scanned_lsn = ut_dulint_zero; recv_sys->scanned_lsn = 0;
recv_sys->scanned_checkpoint_no = 0; recv_sys->scanned_checkpoint_no = 0;
recv_sys->recovered_lsn = recv_sys->parse_start_lsn; recv_sys->recovered_lsn = recv_sys->parse_start_lsn;
...@@ -3359,9 +3333,9 @@ recv_recovery_from_archive_start( ...@@ -3359,9 +3333,9 @@ recv_recovery_from_archive_start(
group->archived_file_no++; group->archived_file_no++;
} }
if (ut_dulint_cmp(recv_sys->recovered_lsn, limit_lsn) < 0) { if (recv_sys->recovered_lsn < limit_lsn) {
if (ut_dulint_is_zero(recv_sys->scanned_lsn)) { if (!recv_sys->scanned_lsn) {
recv_sys->scanned_lsn = recv_sys->parse_start_lsn; recv_sys->scanned_lsn = recv_sys->parse_start_lsn;
} }
...@@ -3370,8 +3344,8 @@ recv_recovery_from_archive_start( ...@@ -3370,8 +3344,8 @@ recv_recovery_from_archive_start(
err = recv_recovery_from_checkpoint_start(LOG_ARCHIVE, err = recv_recovery_from_checkpoint_start(LOG_ARCHIVE,
limit_lsn, limit_lsn,
ut_dulint_max, IB_ULONGLONG_MAX,
ut_dulint_max); IB_ULONGLONG_MAX);
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
return(err); return(err);
...@@ -3380,7 +3354,7 @@ recv_recovery_from_archive_start( ...@@ -3380,7 +3354,7 @@ recv_recovery_from_archive_start(
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
} }
if (ut_dulint_cmp(limit_lsn, ut_dulint_max) != 0) { if (limit_lsn != IB_ULONGLONG_MAX) {
recv_apply_hashed_log_recs(FALSE); recv_apply_hashed_log_recs(FALSE);
......
...@@ -2512,7 +2512,7 @@ row_import_tablespace_for_mysql( ...@@ -2512,7 +2512,7 @@ row_import_tablespace_for_mysql(
{ {
dict_table_t* table; dict_table_t* table;
ibool success; ibool success;
dulint current_lsn; ib_ulonglong current_lsn;
ulint err = DB_SUCCESS; ulint err = DB_SUCCESS;
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
......
...@@ -172,7 +172,7 @@ ulint srv_n_file_io_threads = ULINT_MAX; ...@@ -172,7 +172,7 @@ ulint srv_n_file_io_threads = ULINT_MAX;
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
ibool srv_log_archive_on = FALSE; ibool srv_log_archive_on = FALSE;
ibool srv_archive_recovery = 0; ibool srv_archive_recovery = 0;
dulint srv_archive_recovery_limit_lsn; ib_ulonglong srv_archive_recovery_limit_lsn;
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
ulint srv_lock_wait_timeout = 1024 * 1024 * 1024; ulint srv_lock_wait_timeout = 1024 * 1024 * 1024;
...@@ -2017,8 +2017,8 @@ srv_error_monitor_thread( ...@@ -2017,8 +2017,8 @@ srv_error_monitor_thread(
{ {
/* number of successive fatal timeouts observed */ /* number of successive fatal timeouts observed */
ulint fatal_cnt = 0; ulint fatal_cnt = 0;
dulint old_lsn; ib_ulonglong old_lsn;
dulint new_lsn; ib_ulonglong new_lsn;
old_lsn = srv_start_lsn; old_lsn = srv_start_lsn;
...@@ -2034,18 +2034,15 @@ srv_error_monitor_thread( ...@@ -2034,18 +2034,15 @@ srv_error_monitor_thread(
new_lsn = log_get_lsn(); new_lsn = log_get_lsn();
if (ut_dulint_cmp(new_lsn, old_lsn) < 0) { if (new_lsn < old_lsn) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Error: old log sequence number %lu %lu" " InnoDB: Error: old log sequence number %llu"
" was greater\n" " was greater\n"
"InnoDB: than the new log sequence number %lu %lu!\n" "InnoDB: than the new log sequence number %llu!\n"
"InnoDB: Please submit a bug report" "InnoDB: Please submit a bug report"
" to http://bugs.mysql.com\n", " to http://bugs.mysql.com\n",
(ulong) ut_dulint_get_high(old_lsn), old_lsn, new_lsn);
(ulong) ut_dulint_get_low(old_lsn),
(ulong) ut_dulint_get_high(new_lsn),
(ulong) ut_dulint_get_low(new_lsn));
} }
old_lsn = new_lsn; old_lsn = new_lsn;
...@@ -2265,7 +2262,7 @@ srv_master_thread( ...@@ -2265,7 +2262,7 @@ srv_master_thread(
buffer pool under the limit wished by the user */ buffer pool under the limit wished by the user */
n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100, n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
ut_dulint_max); IB_ULONGLONG_MAX);
/* If we had to do the flush, it may have taken /* If we had to do the flush, it may have taken
even more than 1 second, and also, there may be more even more than 1 second, and also, there may be more
...@@ -2302,7 +2299,7 @@ srv_master_thread( ...@@ -2302,7 +2299,7 @@ srv_master_thread(
if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) { if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
srv_main_thread_op_info = "flushing buffer pool pages"; srv_main_thread_op_info = "flushing buffer pool pages";
buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max); buf_flush_batch(BUF_FLUSH_LIST, 100, IB_ULONGLONG_MAX);
srv_main_thread_op_info = "flushing log"; srv_main_thread_op_info = "flushing log";
log_buffer_flush_to_disk(); log_buffer_flush_to_disk();
...@@ -2353,14 +2350,14 @@ srv_master_thread( ...@@ -2353,14 +2350,14 @@ srv_master_thread(
the time it requires to flush 100 pages */ the time it requires to flush 100 pages */
n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100, n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
ut_dulint_max); IB_ULONGLONG_MAX);
} else { } else {
/* Otherwise, we only flush a small number of pages so that /* Otherwise, we only flush a small number of pages so that
we do not unnecessarily use much disk i/o capacity from we do not unnecessarily use much disk i/o capacity from
other work */ other work */
n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10, n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10,
ut_dulint_max); IB_ULONGLONG_MAX);
} }
srv_main_thread_op_info = "making checkpoint"; srv_main_thread_op_info = "making checkpoint";
...@@ -2463,7 +2460,7 @@ srv_master_thread( ...@@ -2463,7 +2460,7 @@ srv_master_thread(
if (srv_fast_shutdown < 2) { if (srv_fast_shutdown < 2) {
n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100, n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
ut_dulint_max); IB_ULONGLONG_MAX);
} else { } else {
/* In the fastest shutdown we do not flush the buffer pool /* In the fastest shutdown we do not flush the buffer pool
to data files: we set n_pages_flushed to 0 artificially. */ to data files: we set n_pages_flushed to 0 artificially. */
......
...@@ -57,9 +57,9 @@ Created 2/16/1996 Heikki Tuuri ...@@ -57,9 +57,9 @@ Created 2/16/1996 Heikki Tuuri
#include "que0que.h" #include "que0que.h"
/* Log sequence number immediately after startup */ /* Log sequence number immediately after startup */
dulint srv_start_lsn; ib_ulonglong srv_start_lsn;
/* Log sequence number at shutdown */ /* Log sequence number at shutdown */
dulint srv_shutdown_lsn; ib_ulonglong srv_shutdown_lsn;
#ifdef HAVE_DARWIN_THREADS #ifdef HAVE_DARWIN_THREADS
# include <sys/utsname.h> # include <sys/utsname.h>
...@@ -693,14 +693,17 @@ open_or_create_data_files( ...@@ -693,14 +693,17 @@ open_or_create_data_files(
ibool* create_new_db, /* out: TRUE if new database should be ibool* create_new_db, /* out: TRUE if new database should be
created */ created */
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
ulint* min_arch_log_no,/* out: min of archived log numbers in data ulint* min_arch_log_no,/* out: min of archived log
files */ numbers in data files */
ulint* max_arch_log_no,/* out: */ ulint* max_arch_log_no,/* out: max of archived log
numbers in data files */
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
dulint* min_flushed_lsn,/* out: min of flushed lsn values in data ib_ulonglong* min_flushed_lsn,/* out: min of flushed lsn
files */ values in data files */
dulint* max_flushed_lsn,/* out: */ ib_ulonglong* max_flushed_lsn,/* out: max of flushed lsn
ulint* sum_of_new_sizes)/* out: sum of sizes of the new files added */ values in data files */
ulint* sum_of_new_sizes)/* out: sum of sizes of the
new files added */
{ {
ibool ret; ibool ret;
ulint i; ulint i;
...@@ -967,8 +970,8 @@ innobase_start_or_create_for_mysql(void) ...@@ -967,8 +970,8 @@ innobase_start_or_create_for_mysql(void)
ibool log_file_created; ibool log_file_created;
ibool log_created = FALSE; ibool log_created = FALSE;
ibool log_opened = FALSE; ibool log_opened = FALSE;
dulint min_flushed_lsn; ib_ulonglong min_flushed_lsn;
dulint max_flushed_lsn; ib_ulonglong max_flushed_lsn;
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
ulint min_arch_log_no; ulint min_arch_log_no;
ulint max_arch_log_no; ulint max_arch_log_no;
...@@ -978,7 +981,8 @@ innobase_start_or_create_for_mysql(void) ...@@ -978,7 +981,8 @@ innobase_start_or_create_for_mysql(void)
ulint tablespace_size_in_header; ulint tablespace_size_in_header;
ulint err; ulint err;
ulint i; ulint i;
ibool srv_file_per_table_original_value = srv_file_per_table; ibool srv_file_per_table_original_value
= srv_file_per_table;
mtr_t mtr; mtr_t mtr;
#ifdef HAVE_DARWIN_THREADS #ifdef HAVE_DARWIN_THREADS
# ifdef F_FULLFSYNC # ifdef F_FULLFSYNC
...@@ -1366,7 +1370,7 @@ innobase_start_or_create_for_mysql(void) ...@@ -1366,7 +1370,7 @@ innobase_start_or_create_for_mysql(void)
&& !srv_archive_recovery && !srv_archive_recovery
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
) { ) {
if (ut_dulint_cmp(max_flushed_lsn, min_flushed_lsn) != 0 if (max_flushed_lsn != min_flushed_lsn
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
|| max_arch_log_no != min_arch_log_no || max_arch_log_no != min_arch_log_no
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
...@@ -1381,8 +1385,7 @@ innobase_start_or_create_for_mysql(void) ...@@ -1381,8 +1385,7 @@ innobase_start_or_create_for_mysql(void)
return(DB_ERROR); return(DB_ERROR);
} }
if (ut_dulint_cmp(max_flushed_lsn, ut_dulint_create(0, 1000)) if (max_flushed_lsn < (ib_ulonglong) 1000) {
< 0) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Cannot initialize created" "InnoDB: Cannot initialize created"
" log files because\n" " log files because\n"
...@@ -1450,7 +1453,7 @@ innobase_start_or_create_for_mysql(void) ...@@ -1450,7 +1453,7 @@ innobase_start_or_create_for_mysql(void)
been shut down normally: this is the normal startup path */ been shut down normally: this is the normal startup path */
err = recv_recovery_from_checkpoint_start(LOG_CHECKPOINT, err = recv_recovery_from_checkpoint_start(LOG_CHECKPOINT,
ut_dulint_max, IB_ULONGLONG_MAX,
min_flushed_lsn, min_flushed_lsn,
max_flushed_lsn); max_flushed_lsn);
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
...@@ -1676,9 +1679,8 @@ innobase_start_or_create_for_mysql(void) ...@@ -1676,9 +1679,8 @@ innobase_start_or_create_for_mysql(void)
if (srv_print_verbose_log) { if (srv_print_verbose_log) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Started; log sequence number %lu %lu\n", " InnoDB: Started; log sequence number %llu\n",
(ulong) ut_dulint_get_high(srv_start_lsn), srv_start_lsn);
(ulong) ut_dulint_get_low(srv_start_lsn));
} }
if (srv_force_recovery > 0) { if (srv_force_recovery > 0) {
...@@ -1938,9 +1940,8 @@ innobase_shutdown_for_mysql(void) ...@@ -1938,9 +1940,8 @@ innobase_shutdown_for_mysql(void)
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Shutdown completed;" " InnoDB: Shutdown completed;"
" log sequence number %lu %lu\n", " log sequence number %llu\n",
(ulong) ut_dulint_get_high(srv_shutdown_lsn), srv_shutdown_lsn);
(ulong) ut_dulint_get_low(srv_shutdown_lsn));
} }
return((int) DB_SUCCESS); return((int) DB_SUCCESS);
......
...@@ -149,7 +149,7 @@ trx_sys_mark_upgraded_to_multiple_tablespaces(void) ...@@ -149,7 +149,7 @@ trx_sys_mark_upgraded_to_multiple_tablespaces(void)
mtr_commit(&mtr); mtr_commit(&mtr);
/* Flush the modified pages to disk and make a checkpoint */ /* Flush the modified pages to disk and make a checkpoint */
log_make_checkpoint_at(ut_dulint_max, TRUE); log_make_checkpoint_at(IB_ULONGLONG_MAX, TRUE);
trx_sys_multiple_tablespace_format = TRUE; trx_sys_multiple_tablespace_format = TRUE;
} }
...@@ -322,7 +322,7 @@ trx_sys_create_doublewrite_buf(void) ...@@ -322,7 +322,7 @@ trx_sys_create_doublewrite_buf(void)
mtr_commit(&mtr); mtr_commit(&mtr);
/* Flush the modified pages to disk and make a checkpoint */ /* Flush the modified pages to disk and make a checkpoint */
log_make_checkpoint_at(ut_dulint_max, TRUE); log_make_checkpoint_at(IB_ULONGLONG_MAX, TRUE);
fprintf(stderr, "InnoDB: Doublewrite buffer created\n"); fprintf(stderr, "InnoDB: Doublewrite buffer created\n");
......
...@@ -743,7 +743,7 @@ trx_commit_off_kernel( ...@@ -743,7 +743,7 @@ trx_commit_off_kernel(
trx_t* trx) /* in: transaction */ trx_t* trx) /* in: transaction */
{ {
page_t* update_hdr_page; page_t* update_hdr_page;
dulint lsn; ib_ulonglong lsn;
trx_rseg_t* rseg; trx_rseg_t* rseg;
trx_undo_t* undo; trx_undo_t* undo;
ibool must_flush_log = FALSE; ibool must_flush_log = FALSE;
...@@ -1621,7 +1621,7 @@ trx_commit_complete_for_mysql( ...@@ -1621,7 +1621,7 @@ trx_commit_complete_for_mysql(
/* out: 0 or error number */ /* out: 0 or error number */
trx_t* trx) /* in: trx handle */ trx_t* trx) /* in: trx handle */
{ {
dulint lsn = trx->commit_lsn; ib_ulonglong lsn = trx->commit_lsn;
ut_a(trx); ut_a(trx);
...@@ -1799,7 +1799,7 @@ trx_prepare_off_kernel( ...@@ -1799,7 +1799,7 @@ trx_prepare_off_kernel(
page_t* update_hdr_page; page_t* update_hdr_page;
trx_rseg_t* rseg; trx_rseg_t* rseg;
ibool must_flush_log = FALSE; ibool must_flush_log = FALSE;
dulint lsn; ib_ulonglong lsn;
mtr_t mtr; mtr_t mtr;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
......
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