summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2015-10-06 15:11:24 +0300
committerJan Lindström <jan.lindstrom@mariadb.com>2015-10-06 15:11:24 +0300
commit5a95f5c3a80c3f37b33a6c761855be628b18ce70 (patch)
tree08ce3f7a960fd439b7b9145979929e3fb96c9d71
parent4c106daf7eba86c36c29ff528b9dd274dcb27972 (diff)
downloadmariadb-git-5a95f5c3a80c3f37b33a6c761855be628b18ce70.tar.gz
Fixed database corruption caused by innodb-use-trim
-rw-r--r--storage/innobase/fil/fil0fil.cc3
-rw-r--r--storage/innobase/include/os0file.h10
-rw-r--r--storage/innobase/include/os0file.ic3
-rw-r--r--storage/innobase/os/os0file.cc23
-rw-r--r--storage/xtradb/fil/fil0fil.cc3
-rw-r--r--storage/xtradb/include/os0file.h10
-rw-r--r--storage/xtradb/include/os0file.ic3
-rw-r--r--storage/xtradb/os/os0file.cc23
8 files changed, 36 insertions, 42 deletions
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 3d583a6df15..db304203a18 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -5225,7 +5225,7 @@ retry:
#else
success = os_aio(OS_FILE_WRITE, 0, OS_AIO_SYNC,
node->name, node->handle, buf,
- offset, page_size * n_pages,
+ offset, page_size * n_pages, page_size,
node, NULL, 0);
#endif /* UNIV_HOTBACKUP */
@@ -5879,6 +5879,7 @@ fil_io(
buf,
offset,
len,
+ zip_size ? zip_size : UNIV_PAGE_SIZE,
node,
message,
write_size);
diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h
index 005b44108db..c630e91e815 100644
--- a/storage/innobase/include/os0file.h
+++ b/storage/innobase/include/os0file.h
@@ -312,9 +312,9 @@ The wrapper functions have the prefix of "innodb_". */
pfs_os_file_close_func(file, __FILE__, __LINE__)
# define os_aio(type, is_log, mode, name, file, buf, offset, \
- n, message1, message2, write_size) \
+ n, page_size, message1, message2, write_size) \
pfs_os_aio_func(type, is_log, mode, name, file, buf, offset, \
- n, message1, message2, write_size, \
+ n, page_size, message1, message2, write_size, \
__FILE__, __LINE__)
@@ -357,10 +357,10 @@ to original un-instrumented file I/O APIs */
# define os_file_close(file) os_file_close_func(file)
-# define os_aio(type, is_log, mode, name, file, buf, offset, n, message1, \
+# define os_aio(type, is_log, mode, name, file, buf, offset, n, page_size, message1, \
message2, write_size) \
os_aio_func(type, is_log, mode, name, file, buf, offset, n, \
- message1, message2, write_size)
+ page_size, message1, message2, write_size)
# define os_file_read(file, buf, offset, n) \
os_file_read_func(file, buf, offset, n)
@@ -758,6 +758,7 @@ pfs_os_aio_func(
to write */
os_offset_t offset, /*!< in: file offset where to read or write */
ulint n, /*!< in: number of bytes to read or write */
+ ulint page_size, /*!< in: page size in bytes */
fil_node_t* message1,/*!< in: message for the aio handler
(can be used to identify a completed
aio operation); ignored if mode is
@@ -1129,6 +1130,7 @@ os_aio_func(
to write */
os_offset_t offset, /*!< in: file offset where to read or write */
ulint n, /*!< in: number of bytes to read or write */
+ ulint page_size, /*!< in: page size in bytes */
fil_node_t* message1,/*!< in: message for the aio handler
(can be used to identify a completed
aio operation); ignored if mode is
diff --git a/storage/innobase/include/os0file.ic b/storage/innobase/include/os0file.ic
index bafa3976763..6ca8b371093 100644
--- a/storage/innobase/include/os0file.ic
+++ b/storage/innobase/include/os0file.ic
@@ -208,6 +208,7 @@ pfs_os_aio_func(
to write */
os_offset_t offset, /*!< in: file offset where to read or write */
ulint n, /*!< in: number of bytes to read or write */
+ ulint page_size, /*!< in: page size in bytes */
fil_node_t* message1,/*!< in: message for the aio handler
(can be used to identify a completed
aio operation); ignored if mode is
@@ -236,7 +237,7 @@ pfs_os_aio_func(
src_file, src_line);
result = os_aio_func(type, is_log, mode, name, file, buf, offset,
- n, message1, message2, write_size);
+ n, page_size, message1, message2, write_size);
register_pfs_file_io_end(locker, n);
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index 606437486e3..03beeca6591 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -204,7 +204,8 @@ struct os_aio_slot_t{
write */
byte* buf; /*!< buffer used in i/o */
ulint type; /*!< OS_FILE_READ or OS_FILE_WRITE */
- ulint is_log; /*!< in: 1 is OS_FILE_LOG or 0 */
+ ulint is_log; /*!< 1 if OS_FILE_LOG or 0 */
+ ulint page_size; /*!< UNIV_PAGE_SIZE or zip_size */
os_offset_t offset; /*!< file offset in bytes */
os_file_t file; /*!< file where to read or write */
@@ -4484,6 +4485,7 @@ os_aio_array_reserve_slot(
to write */
os_offset_t offset, /*!< in: file offset */
ulint len, /*!< in: length of the block to read or write */
+ ulint page_size, /*!< in: page size in bytes */
ulint* write_size)/*!< in/out: Actual write size initialized
after fist successfull trim
operation for this page and if
@@ -4579,6 +4581,7 @@ found:
slot->io_already_done = FALSE;
slot->write_size = write_size;
slot->is_log = is_log;
+ slot->page_size = page_size;
if (message1) {
slot->file_block_size = fil_node_get_block_size(message1);
@@ -4856,6 +4859,7 @@ os_aio_func(
to write */
os_offset_t offset, /*!< in: file offset where to read or write */
ulint n, /*!< in: number of bytes to read or write */
+ ulint page_size, /*!< in: page size in bytes */
fil_node_t* message1,/*!< in: message for the aio handler
(can be used to identify a completed
aio operation); ignored if mode is
@@ -4983,7 +4987,7 @@ try_again:
}
slot = os_aio_array_reserve_slot(type, is_log, array, message1, message2, file,
- name, buf, offset, n, write_size);
+ name, buf, offset, n, page_size, write_size);
if (type == OS_FILE_READ) {
if (srv_use_native_aio) {
@@ -6226,19 +6230,13 @@ os_file_trim(
{
size_t len = slot->len;
- size_t trim_len = UNIV_PAGE_SIZE - len;
+ size_t trim_len = slot->page_size - len;
os_offset_t off = slot->offset + len;
size_t bsize = slot->file_block_size;
- // len here should be alligned to sector size
- ut_ad((trim_len % bsize) == 0);
- ut_ad((len % bsize) == 0);
- ut_ad(bsize != 0);
- ut_ad((off % bsize) == 0);
-
#ifdef UNIV_TRIM_DEBUG
fprintf(stderr, "Note: TRIM: write_size %lu trim_len %lu len %lu off %lu bz %lu\n",
- *slot->write_size, trim_len, len, off, bsize);
+ slot->write_size ? *slot->write_size : 0, trim_len, len, off, bsize);
#endif
// Nothing to do if trim length is zero or if actual write
@@ -6253,11 +6251,6 @@ os_file_trim(
*slot->write_size > 0 &&
len >= *slot->write_size)) {
-#ifdef UNIV_PAGECOMPRESS_DEBUG
- fprintf(stderr, "Note: TRIM: write_size %lu trim_len %lu len %lu\n",
- *slot->write_size, trim_len, len);
-#endif
-
if (slot->write_size) {
if (*slot->write_size > 0 && len >= *slot->write_size) {
srv_stats.page_compressed_trim_op_saved.inc();
diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc
index 2f0cebf0522..70f0ee14ab5 100644
--- a/storage/xtradb/fil/fil0fil.cc
+++ b/storage/xtradb/fil/fil0fil.cc
@@ -5255,7 +5255,7 @@ retry:
#else
success = os_aio(OS_FILE_WRITE, 0, OS_AIO_SYNC,
node->name, node->handle, buf,
- offset, page_size * n_pages,
+ offset, page_size * n_pages, page_size,
node, NULL, space_id, NULL, 0);
#endif /* UNIV_HOTBACKUP */
@@ -5925,6 +5925,7 @@ _fil_io(
buf,
offset,
len,
+ zip_size ? zip_size : UNIV_PAGE_SIZE,
node,
message,
space_id,
diff --git a/storage/xtradb/include/os0file.h b/storage/xtradb/include/os0file.h
index b16738e28fa..b1058f07c8e 100644
--- a/storage/xtradb/include/os0file.h
+++ b/storage/xtradb/include/os0file.h
@@ -322,10 +322,10 @@ The wrapper functions have the prefix of "innodb_". */
pfs_os_file_close_func(file, __FILE__, __LINE__)
# define os_aio(type, is_log, mode, name, file, buf, offset, \
- n, message1, message2, space_id, \
+ n, page_size, message1, message2, space_id, \
trx, write_size) \
pfs_os_aio_func(type, is_log, mode, name, file, buf, offset, \
- n, message1, message2, space_id, trx, write_size, \
+ n, page_size, message1, message2, space_id, trx, write_size, \
__FILE__, __LINE__)
# define os_file_read(file, buf, offset, n) \
@@ -372,10 +372,10 @@ to original un-instrumented file I/O APIs */
# define os_file_close(file) os_file_close_func(file)
-# define os_aio(type, is_log, mode, name, file, buf, offset, n, message1, \
+# define os_aio(type, is_log, mode, name, file, buf, offset, n, page_size, message1, \
message2, space_id, trx, write_size) \
os_aio_func(type, is_log, mode, name, file, buf, offset, n, \
- message1, message2, space_id, trx, write_size)
+ page_size, message1, message2, space_id, trx, write_size)
# define os_file_read(file, buf, offset, n) \
os_file_read_func(file, buf, offset, n, NULL)
@@ -781,6 +781,7 @@ pfs_os_aio_func(
to write */
os_offset_t offset, /*!< in: file offset where to read or write */
ulint n, /*!< in: number of bytes to read or write */
+ ulint page_size,/*!< in: page size in bytes */
fil_node_t* message1,/*!< in: message for the aio handler
(can be used to identify a completed
aio operation); ignored if mode is
@@ -1161,6 +1162,7 @@ os_aio_func(
to write */
os_offset_t offset, /*!< in: file offset where to read or write */
ulint n, /*!< in: number of bytes to read or write */
+ ulint page_size, /*!< in: page size in bytes */
fil_node_t* message1,/*!< in: message for the aio handler
(can be used to identify a completed
aio operation); ignored if mode is
diff --git a/storage/xtradb/include/os0file.ic b/storage/xtradb/include/os0file.ic
index cfce273882c..b284d7ea9ac 100644
--- a/storage/xtradb/include/os0file.ic
+++ b/storage/xtradb/include/os0file.ic
@@ -211,6 +211,7 @@ pfs_os_aio_func(
to write */
os_offset_t offset, /*!< in: file offset where to read or write */
ulint n, /*!< in: number of bytes to read or write */
+ ulint page_size, /*!< in: page size in bytes */
fil_node_t* message1,/*!< in: message for the aio handler
(can be used to identify a completed
aio operation); ignored if mode is
@@ -241,7 +242,7 @@ pfs_os_aio_func(
src_file, src_line);
result = os_aio_func(type, is_log, mode, name, file, buf, offset,
- n, message1, message2, space_id, trx,
+ n, page_size, message1, message2, space_id, trx,
write_size);
register_pfs_file_io_end(locker, n);
diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc
index 26accb84e40..e87ce888e10 100644
--- a/storage/xtradb/os/os0file.cc
+++ b/storage/xtradb/os/os0file.cc
@@ -216,7 +216,8 @@ struct os_aio_slot_t{
write */
byte* buf; /*!< buffer used in i/o */
ulint type; /*!< OS_FILE_READ or OS_FILE_WRITE */
- ulint is_log; /*!< in: 1 is OS_FILE_LOG or 0 */
+ ulint is_log; /*!< 1 is OS_FILE_LOG or 0 */
+ ulint page_size; /*!< UNIV_PAGE_SIZE or zip_size */
os_offset_t offset; /*!< file offset in bytes */
os_file_t file; /*!< file where to read or write */
@@ -4583,6 +4584,7 @@ os_aio_array_reserve_slot(
to write */
os_offset_t offset, /*!< in: file offset */
ulint len, /*!< in: length of the block to read or write */
+ ulint page_size, /*!< in: page size in bytes */
ulint space_id,
ulint* write_size)/*!< in/out: Actual write size initialized
after first successfull trim
@@ -4680,6 +4682,7 @@ found:
slot->io_already_done = FALSE;
slot->space_id = space_id;
slot->is_log = is_log;
+ slot->page_size = page_size;
if (message1) {
slot->file_block_size = fil_node_get_block_size(message1);
@@ -4954,6 +4957,7 @@ os_aio_func(
to write */
os_offset_t offset, /*!< in: file offset where to read or write */
ulint n, /*!< in: number of bytes to read or write */
+ ulint page_size, /*!< in: page size in bytes */
fil_node_t* message1,/*!< in: message for the aio handler
(can be used to identify a completed
aio operation); ignored if mode is
@@ -5073,7 +5077,7 @@ try_again:
}
slot = os_aio_array_reserve_slot(type, is_log, array, message1, message2, file,
- name, buf, offset, n, space_id,
+ name, buf, offset, n, page_size, space_id,
write_size);
if (type == OS_FILE_READ) {
@@ -6305,19 +6309,13 @@ os_file_trim(
os_aio_slot_t* slot) /*!< in: slot structure */
{
size_t len = slot->len;
- size_t trim_len = UNIV_PAGE_SIZE - slot->len;
+ size_t trim_len = slot->page_size - slot->len;
os_offset_t off __attribute__((unused)) = slot->offset + len;
size_t bsize = slot->file_block_size;
- // len here should be alligned to sector size
- ut_ad((trim_len % bsize) == 0);
- ut_ad((len % bsize) == 0);
- ut_ad(bsize != 0);
- ut_ad((off % bsize) == 0);
-
#ifdef UNIV_TRIM_DEBUG
fprintf(stderr, "Note: TRIM: write_size %lu trim_len %lu len %lu off %lu bz %lu\n",
- *slot->write_size, trim_len, len, off, bsize);
+ slot->write_size ? *slot->write_size : 0, trim_len, len, off, bsize);
#endif
// Nothing to do if trim length is zero or if actual write
@@ -6332,11 +6330,6 @@ os_file_trim(
*slot->write_size > 0 &&
len >= *slot->write_size)) {
-#ifdef UNIV_PAGECOMPRESS_DEBUG
- fprintf(stderr, "Note: TRIM: write_size %lu trim_len %lu len %lu\n",
- *slot->write_size, trim_len, len);
-#endif
-
if (slot->write_size) {
if (*slot->write_size > 0 && len >= *slot->write_size) {
srv_stats.page_compressed_trim_op_saved.inc();