Commit 97c78130 authored by marko's avatar marko

branches/zip: Add parameter zip_size to fil_io().

fil_read(), fil_write(): Make these inlined functions in fil0fil.c.

fil_write_lsn_and_arch_no_to_file(): Remove the parameter space_id and
note that this function is to be called on the system tablespace, which
is uncompressed.
parent 11fefe4d
......@@ -305,7 +305,7 @@ buf_flush_buffered_writes(void)
write_buf = trx_doublewrite->write_buf;
i = 0;
fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE,
fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0,
trx_doublewrite->block1, 0, len,
(void*) write_buf, NULL);
......@@ -335,7 +335,7 @@ buf_flush_buffered_writes(void)
+ TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE;
ut_ad(i == TRX_SYS_DOUBLEWRITE_BLOCK_SIZE);
fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE,
fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0,
trx_doublewrite->block2, 0, len,
(void*) write_buf, NULL);
......@@ -367,14 +367,10 @@ buf_flush_buffered_writes(void)
block = trx_doublewrite->buf_block_arr[i];
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
if (UNIV_UNLIKELY(block->page_zip.size)) {
ulint blk_size
= UNIV_PAGE_SIZE / block->page_zip.size;
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE, block->space,
block->offset / blk_size,
(block->offset % blk_size)
* block->page_zip.size,
block->page_zip.size,
block->offset, 0,
block->page_zip.size,
(void*)block->page_zip.data,
(void*)block);
......@@ -395,8 +391,9 @@ buf_flush_buffered_writes(void)
}
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE,
(void*)block->frame, (void*)block);
FALSE, block->space, 0,
block->offset, 0, UNIV_PAGE_SIZE,
(void*)block->frame, (void*)block);
}
/* Wake possible simulated aio thread to actually post the
......@@ -605,8 +602,10 @@ buf_flush_write_block_low(
block->space, block->offset);
if (!srv_use_doublewrite_buf || !trx_doublewrite) {
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE,
(void*)block->frame, (void*)block);
FALSE, block->space, block->page_zip.size,
block->offset, 0, block->page_zip.size
? block->page_zip.size : UNIV_PAGE_SIZE,
(void*)block->frame, (void*)block);
} else {
buf_flush_post_to_doublewrite_buf(block);
}
......
......@@ -142,17 +142,12 @@ buf_read_page_low(
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
if (zip_size) {
ulint zip_blk = UNIV_PAGE_SIZE / zip_size;
*err = fil_io(OS_FILE_READ | wake_later,
sync, space,
offset / zip_blk, (offset % zip_blk)
* zip_size, zip_size,
sync, space, zip_size, offset, 0, zip_size,
(void*)block->page_zip.data, (void*)block);
} else {
*err = fil_io(OS_FILE_READ | wake_later,
sync, space,
offset, 0, UNIV_PAGE_SIZE,
sync, space, 0, offset, 0, UNIV_PAGE_SIZE,
(void*)block->frame, (void*)block);
}
ut_a(*err == DB_SUCCESS);
......
......@@ -294,6 +294,65 @@ fil_get_space_id_for_table(
found */
const char* name); /* in: table name in the standard
'databasename/tablename' format */
/************************************************************************
Reads data from a space to a buffer. Remember that the possible incomplete
blocks at the end of file are ignored: they are not taken into account when
calculating the byte offset within a space. */
UNIV_INLINE
ulint
fil_read(
/*=====*/
/* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
if we are trying to do i/o on a tablespace
which does not exist */
ibool sync, /* in: TRUE if synchronous aio is desired */
ulint space_id, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes;
0 for uncompressed pages */
ulint block_offset, /* in: offset in number of blocks */
ulint byte_offset, /* in: remainder of offset in bytes; in aio
this must be divisible by the OS block size */
ulint len, /* in: how many bytes to read; this must not
cross a file boundary; in aio this must be a
block size multiple */
void* buf, /* in/out: buffer where to store data read;
in aio this must be appropriately aligned */
void* message) /* in: message for aio handler if non-sync
aio used, else ignored */
{
return(fil_io(OS_FILE_READ, sync, space_id, zip_size, block_offset,
byte_offset, len, buf, message));
}
/************************************************************************
Writes data to a space from a buffer. Remember that the possible incomplete
blocks at the end of file are ignored: they are not taken into account when
calculating the byte offset within a space. */
UNIV_INLINE
ulint
fil_write(
/*======*/
/* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
if we are trying to do i/o on a tablespace
which does not exist */
ibool sync, /* in: TRUE if synchronous aio is desired */
ulint space_id, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes;
0 for uncompressed pages */
ulint block_offset, /* in: offset in number of blocks */
ulint byte_offset, /* in: remainder of offset in bytes; in aio
this must be divisible by the OS block size */
ulint len, /* in: how many bytes to write; this must
not cross a file boundary; in aio this must
be a block size multiple */
void* buf, /* in: buffer from which to write; in aio
this must be appropriately aligned */
void* message) /* in: message for aio handler if non-sync
aio used, else ignored */
{
return(fil_io(OS_FILE_WRITE, sync, space_id, zip_size, block_offset,
byte_offset, len, buf, message));
}
/***********************************************************************
......@@ -1526,12 +1585,12 @@ fil_ibuf_init_at_db_start(void)
/********************************************************************
Writes the flushed lsn and the latest archived log number to the page header
of the first page of a data file. */
of the first page of a data file of the system tablespace (space 0),
which is uncompressed. */
static
ulint
fil_write_lsn_and_arch_no_to_file(
/*==============================*/
ulint space_id, /* in: space number */
ulint sum_of_sizes, /* in: combined size of previous files in
space, in database pages */
dulint lsn, /* in: lsn to write */
......@@ -1544,11 +1603,11 @@ fil_write_lsn_and_arch_no_to_file(
buf1 = mem_alloc(2 * UNIV_PAGE_SIZE);
buf = ut_align(buf1, UNIV_PAGE_SIZE);
fil_read(TRUE, space_id, 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);
fil_write(TRUE, space_id, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
fil_write(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
return(DB_SUCCESS);
}
......@@ -1589,7 +1648,7 @@ fil_write_flushed_lsn_to_data_files(
mutex_exit(&(fil_system->mutex));
err = fil_write_lsn_and_arch_no_to_file(
space->id, sum_of_sizes,
sum_of_sizes,
lsn, arch_log_no);
if (err != DB_SUCCESS) {
......@@ -3993,6 +4052,8 @@ fil_io(
caution! */
ibool sync, /* in: TRUE if synchronous aio is desired */
ulint space_id, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes;
0 for uncompressed pages */
ulint block_offset, /* in: offset in number of blocks */
ulint byte_offset, /* in: remainder of offset in bytes; in
aio this must be divisible by the OS block
......@@ -4023,15 +4084,19 @@ fil_io(
type = type & ~OS_AIO_SIMULATED_WAKE_LATER;
ut_ad(byte_offset < UNIV_PAGE_SIZE);
ut_ad(!zip_size || !byte_offset);
ut_ad(ut_is_2pow(zip_size));
ut_ad(buf);
ut_ad(len > 0);
ut_a((1 << UNIV_PAGE_SIZE_SHIFT) == UNIV_PAGE_SIZE);
#if (1 << UNIV_PAGE_SIZE_SHIFT) != UNIV_PAGE_SIZE
# error "(1 << UNIV_PAGE_SIZE_SHIFT) != UNIV_PAGE_SIZE"
#endif
ut_ad(fil_validate());
#ifndef UNIV_LOG_DEBUG
/* ibuf bitmap pages must be read in the sync aio mode: */
ut_ad(recv_no_ibuf_operations || (type == OS_FILE_WRITE)
|| !ibuf_bitmap_page(fil_space_get_zip_size(space_id),
block_offset) || sync || is_log);
|| !ibuf_bitmap_page(zip_size, block_offset)
|| sync || is_log);
#ifdef UNIV_SYNC_DEBUG
ut_ad(!ibuf_inside() || is_log || (type == OS_FILE_WRITE)
|| ibuf_page(space_id, block_offset));
......@@ -4121,12 +4186,30 @@ fil_io(
/* Calculate the low 32 bits and the high 32 bits of the file offset */
offset_high = (block_offset >> (32 - UNIV_PAGE_SIZE_SHIFT));
offset_low = ((block_offset << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL)
+ byte_offset;
if (!zip_size) {
offset_high = (block_offset >> (32 - UNIV_PAGE_SIZE_SHIFT));
offset_low = ((block_offset << UNIV_PAGE_SIZE_SHIFT)
& 0xFFFFFFFFUL) + byte_offset;
ut_a(node->size - block_offset >=
(byte_offset + len + (UNIV_PAGE_SIZE - 1)) / UNIV_PAGE_SIZE);
ut_a(node->size - block_offset
>= (byte_offset + len + (UNIV_PAGE_SIZE - 1))
/ UNIV_PAGE_SIZE);
} else {
ulint zip_size_shift;
switch (zip_size) {
case 1024: zip_size_shift = 10; break;
case 2048: zip_size_shift = 11; break;
case 4096: zip_size_shift = 12; break;
case 8192: zip_size_shift = 13; break;
case 16384: zip_size_shift = 14; break;
default: ut_error;
}
offset_high = block_offset >> (32 - zip_size_shift);
offset_low = (block_offset << zip_size_shift & 0xFFFFFFFFUL)
+ byte_offset;
ut_a(node->size - block_offset
>= (len + (zip_size - 1)) / zip_size);
}
/* Do aio */
......@@ -4165,62 +4248,6 @@ fil_io(
return(DB_SUCCESS);
}
/************************************************************************
Reads data from a space to a buffer. Remember that the possible incomplete
blocks at the end of file are ignored: they are not taken into account when
calculating the byte offset within a space. */
ulint
fil_read(
/*=====*/
/* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
if we are trying to do i/o on a tablespace
which does not exist */
ibool sync, /* in: TRUE if synchronous aio is desired */
ulint space_id, /* in: space id */
ulint block_offset, /* in: offset in number of blocks */
ulint byte_offset, /* in: remainder of offset in bytes; in aio
this must be divisible by the OS block size */
ulint len, /* in: how many bytes to read; this must not
cross a file boundary; in aio this must be a
block size multiple */
void* buf, /* in/out: buffer where to store data read;
in aio this must be appropriately aligned */
void* message) /* in: message for aio handler if non-sync
aio used, else ignored */
{
return(fil_io(OS_FILE_READ, sync, space_id, block_offset,
byte_offset, len, buf, message));
}
/************************************************************************
Writes data to a space from a buffer. Remember that the possible incomplete
blocks at the end of file are ignored: they are not taken into account when
calculating the byte offset within a space. */
ulint
fil_write(
/*======*/
/* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
if we are trying to do i/o on a tablespace
which does not exist */
ibool sync, /* in: TRUE if synchronous aio is desired */
ulint space_id, /* in: space id */
ulint block_offset, /* in: offset in number of blocks */
ulint byte_offset, /* in: remainder of offset in bytes; in aio
this must be divisible by the OS block size */
ulint len, /* in: how many bytes to write; this must
not cross a file boundary; in aio this must
be a block size multiple */
void* buf, /* in: buffer from which to write; in aio
this must be appropriately aligned */
void* message) /* in: message for aio handler if non-sync
aio used, else ignored */
{
return(fil_io(OS_FILE_WRITE, sync, space_id, block_offset,
byte_offset, len, buf, message));
}
/**************************************************************************
Waits for an aio operation to complete. This function is used to write the
handler for completed requests. The aio array of pending requests is divided
......
......@@ -603,6 +603,8 @@ fil_io(
caution! */
ibool sync, /* in: TRUE if synchronous aio is desired */
ulint space_id, /* in: space id */
ulint zip_size, /* in: compressed page size in bytes;
0 for uncompressed pages */
ulint block_offset, /* in: offset in number of blocks */
ulint byte_offset, /* in: remainder of offset in bytes; in
aio this must be divisible by the OS block
......@@ -615,52 +617,6 @@ fil_io(
appropriately aligned */
void* message); /* in: message for aio handler if non-sync
aio used, else ignored */
/************************************************************************
Reads data from a space to a buffer. Remember that the possible incomplete
blocks at the end of file are ignored: they are not taken into account when
calculating the byte offset within a space. */
ulint
fil_read(
/*=====*/
/* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
if we are trying to do i/o on a tablespace
which does not exist */
ibool sync, /* in: TRUE if synchronous aio is desired */
ulint space_id, /* in: space id */
ulint block_offset, /* in: offset in number of blocks */
ulint byte_offset, /* in: remainder of offset in bytes; in aio
this must be divisible by the OS block size */
ulint len, /* in: how many bytes to read; this must not
cross a file boundary; in aio this must be a
block size multiple */
void* buf, /* in/out: buffer where to store data read;
in aio this must be appropriately aligned */
void* message); /* in: message for aio handler if non-sync
aio used, else ignored */
/************************************************************************
Writes data to a space from a buffer. Remember that the possible incomplete
blocks at the end of file are ignored: they are not taken into account when
calculating the byte offset within a space. */
ulint
fil_write(
/*======*/
/* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
if we are trying to do i/o on a tablespace
which does not exist */
ibool sync, /* in: TRUE if synchronous aio is desired */
ulint space_id, /* in: space id */
ulint block_offset, /* in: offset in number of blocks */
ulint byte_offset, /* in: remainder of offset in bytes; in aio
this must be divisible by the OS block size */
ulint len, /* in: how many bytes to write; this must
not cross a file boundary; in aio this must
be a block size multiple */
void* buf, /* in: buffer from which to write; in aio
this must be appropriately aligned */
void* message); /* in: message for aio handler if non-sync
aio used, else ignored */
/**************************************************************************
Waits for an aio operation to complete. This function is used to write the
handler for completed requests. The aio array of pending requests is divided
......
......@@ -1146,7 +1146,7 @@ log_group_file_header_flush(
srv_os_log_pending_writes++;
fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->space_id,
fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->space_id, 0,
dest_offset / UNIV_PAGE_SIZE,
dest_offset % UNIV_PAGE_SIZE,
OS_FILE_LOG_BLOCK_SIZE,
......@@ -1266,7 +1266,7 @@ log_group_write_buf(
srv_os_log_pending_writes++;
fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->space_id,
fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE, group->space_id, 0,
next_offset / UNIV_PAGE_SIZE,
next_offset % UNIV_PAGE_SIZE, write_len, buf, group);
......@@ -1791,7 +1791,7 @@ log_group_checkpoint(
added with 1, as we want to distinguish between a normal log
file write and a checkpoint field write */
fil_io(OS_FILE_WRITE | OS_FILE_LOG, FALSE, group->space_id,
fil_io(OS_FILE_WRITE | OS_FILE_LOG, FALSE, group->space_id, 0,
write_offset / UNIV_PAGE_SIZE,
write_offset % UNIV_PAGE_SIZE,
OS_FILE_LOG_BLOCK_SIZE,
......@@ -1868,7 +1868,7 @@ log_group_read_checkpoint_info(
log_sys->n_log_ios++;
fil_io(OS_FILE_READ | OS_FILE_LOG, TRUE, group->space_id,
fil_io(OS_FILE_READ | OS_FILE_LOG, TRUE, group->space_id, 0,
field / UNIV_PAGE_SIZE, field % UNIV_PAGE_SIZE,
OS_FILE_LOG_BLOCK_SIZE, log_sys->checkpoint_buf, NULL);
}
......@@ -2172,7 +2172,7 @@ log_group_read_log_seg(
log_sys->n_log_ios++;
fil_io(OS_FILE_READ | OS_FILE_LOG, sync, group->space_id,
fil_io(OS_FILE_READ | OS_FILE_LOG, sync, group->space_id, 0,
source_offset / UNIV_PAGE_SIZE, source_offset % UNIV_PAGE_SIZE,
len, buf, NULL);
......
......@@ -2670,7 +2670,7 @@ recv_recovery_from_checkpoint_start(
/* Read the first log file header to print a note if this is
a recovery from a restored InnoDB Hot Backup */
fil_io(OS_FILE_READ | OS_FILE_LOG, TRUE, max_cp_group->space_id,
fil_io(OS_FILE_READ | OS_FILE_LOG, TRUE, max_cp_group->space_id, 0,
0, 0, LOG_FILE_HDR_SIZE,
log_hdr_buf, max_cp_group);
......@@ -2691,7 +2691,7 @@ recv_recovery_from_checkpoint_start(
' ', 4);
/* Write to the log file to wipe over the label */
fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE,
max_cp_group->space_id,
max_cp_group->space_id, 0,
0, 0, OS_FILE_LOG_BLOCK_SIZE,
log_hdr_buf, max_cp_group);
}
......
......@@ -360,7 +360,7 @@ trx_sys_doublewrite_init_or_restore_pages(
/* Read the trx sys header to check if we are using the doublewrite
buffer */
fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, TRX_SYS_PAGE_NO, 0,
fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO, 0,
UNIV_PAGE_SIZE, read_buf, NULL);
doublewrite = read_buf + TRX_SYS_DOUBLEWRITE;
......@@ -397,10 +397,10 @@ trx_sys_doublewrite_init_or_restore_pages(
/* Read the pages from the doublewrite buffer to memory */
fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, block1, 0,
fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, 0, block1, 0,
TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
buf, NULL);
fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, block2, 0,
fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, 0, block2, 0,
TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
buf + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
NULL);
......@@ -429,7 +429,7 @@ trx_sys_doublewrite_init_or_restore_pages(
+ i - TRX_SYS_DOUBLEWRITE_BLOCK_SIZE;
}
fil_io(OS_FILE_WRITE, TRUE, 0, source_page_no, 0,
fil_io(OS_FILE_WRITE, TRUE, 0, 0, source_page_no, 0,
UNIV_PAGE_SIZE, page, NULL);
/* printf("Resetting space id in page %lu\n",
source_page_no); */
......@@ -464,28 +464,13 @@ trx_sys_doublewrite_init_or_restore_pages(
/* It is an unwritten doublewrite buffer page:
do nothing */
} else {
ulint zip_size;
ulint zip_blk;
ulint zip_size = fil_space_get_zip_size(space_id);
if (space_id) {
zip_size = fil_space_get_zip_size(space_id);
if (UNIV_LIKELY(!zip_size)) {
goto read_uncompressed;
}
zip_blk = UNIV_PAGE_SIZE / zip_size;
/* Read in the actual page from the file */
fil_io(OS_FILE_READ, TRUE, space_id,
page_no / zip_blk,
(page_no % zip_blk)
* zip_size, zip_size, read_buf, NULL);
} else {
read_uncompressed:
zip_size = 0;
zip_blk = 1;
/* Read in the actual page from the file */
fil_io(OS_FILE_READ, TRUE, space_id, page_no,
0, UNIV_PAGE_SIZE, read_buf, NULL);
}
/* Read in the actual page from the file */
fil_io(OS_FILE_READ, TRUE, space_id, zip_size,
page_no, 0, zip_size
? zip_size : UNIV_PAGE_SIZE,
read_buf, NULL);
/* Check if the page is corrupt */
......@@ -519,17 +504,10 @@ trx_sys_doublewrite_init_or_restore_pages(
doublewrite buffer to the intended
position */
if (zip_size) {
fil_io(OS_FILE_WRITE, TRUE, space_id,
page_no / zip_blk,
(page_no % zip_blk)
* zip_size, zip_size,
fil_io(OS_FILE_WRITE, TRUE, space_id, zip_size,
page_no, 0, zip_size
? zip_size : UNIV_PAGE_SIZE,
page, NULL);
} else {
fil_io(OS_FILE_WRITE, TRUE, space_id,
page_no, 0,
UNIV_PAGE_SIZE, page, NULL);
}
fprintf(stderr,
"InnoDB: Recovered the page from the doublewrite buffer.\n");
}
......
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