From 7322270a0514883b62f4148e6acc039a5e1b7fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 4 Mar 2014 17:14:08 +0200 Subject: [PATCH] Set actual compressed page size also on read code path to buffer pool so that we can later use it to avoid unnecessary trim operations. --- storage/innobase/buf/buf0rea.cc | 2 +- storage/innobase/fil/fil0pagecompress.cc | 10 +++++++++- storage/innobase/include/fil0pagecompress.h | 4 +++- storage/innobase/os/os0file.cc | 12 +++++++----- storage/xtradb/buf/buf0rea.cc | 2 +- storage/xtradb/fil/fil0pagecompress.cc | 10 +++++++++- storage/xtradb/include/fil0pagecompress.h | 4 +++- storage/xtradb/os/os0file.cc | 14 ++++++++------ 8 files changed, 41 insertions(+), 17 deletions(-) diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index e2578b7f6b7..ec76c9923fe 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -185,7 +185,7 @@ buf_read_page_low( *err = fil_io(OS_FILE_READ | wake_later | ignore_nonexistent_pages, sync, space, zip_size, offset, 0, zip_size, - bpage->zip.data, bpage, 0); + bpage->zip.data, bpage, &bpage->write_size); } else { ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE); diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index dfa216d0ae2..8ecb5317088 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -226,7 +226,9 @@ fil_decompress_page( byte* page_buf, /*!< in: preallocated buffer or NULL */ byte* buf, /*!< out: buffer from which to read; in aio this must be appropriately aligned */ - ulint len) /*!< in: length of output buffer.*/ + ulint len, /*!< in: length of output buffer.*/ + ulint* write_size) /*!< in/out: Actual payload size of + the compressed data. */ { int err = 0; ulint actual_size = 0; @@ -277,6 +279,12 @@ fil_decompress_page( ut_error; } + /* Store actual payload size of the compressed data. This pointer + points to buffer pool. */ + if (write_size) { + *write_size = actual_size; + } + if (compression_alg == FIL_PAGE_COMPRESSION_ZLIB) { #ifdef UNIV_DEBUG diff --git a/storage/innobase/include/fil0pagecompress.h b/storage/innobase/include/fil0pagecompress.h index 342b105401c..c362c0ddcd2 100644 --- a/storage/innobase/include/fil0pagecompress.h +++ b/storage/innobase/include/fil0pagecompress.h @@ -97,7 +97,9 @@ fil_decompress_page( byte* page_buf, /*!< in: preallocated buffer or NULL */ byte* buf, /*!< out: buffer from which to read; in aio this must be appropriately aligned */ - ulint len); /*!< in: length of output buffer.*/ + ulint len, /*!< in: length of output buffer.*/ + ulint* write_size); /*!< in/out: Actual payload size of + the compressed data. */ /****************************************************************//** Get space id from fil node diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index f0ca05b7faa..376aa244bc9 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -2821,7 +2821,7 @@ try_again: if (ret && len == n) { if (fil_page_is_compressed((byte *)buf)) { - fil_decompress_page(NULL, (byte *)buf, len); + fil_decompress_page(NULL, (byte *)buf, len, NULL); } return(TRUE); } @@ -2836,7 +2836,7 @@ try_again: if ((ulint) ret == n) { if (fil_page_is_compressed((byte *)buf)) { - fil_decompress_page(NULL, (byte *)buf, n); + fil_decompress_page(NULL, (byte *)buf, n, NULL); } return(TRUE); @@ -5164,7 +5164,7 @@ os_aio_windows_handle( if (slot->type == OS_FILE_READ) { if (fil_page_is_compressed(slot->buf)) { - fil_decompress_page(slot->page_buf, slot->buf, slot->len); + fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size); } } else { if (slot->page_compress_success && fil_page_is_compressed(slot->page_buf)) { @@ -5278,7 +5278,7 @@ retry: if (slot->type == OS_FILE_READ) { if (fil_page_is_compressed(slot->buf)) { - fil_decompress_page(slot->page_buf, slot->buf, slot->len); + fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size); } } else { if (slot->page_compress_success && @@ -6219,7 +6219,9 @@ os_file_trim( " InnoDB: [Warning] fallocate not supported on this installation." " InnoDB: Disabling fallocate for now."); os_fallocate_failed = TRUE; - slot->write_size = NULL; + if (slot->write_size) { + *slot->write_size = 0; + } #endif /* HAVE_FALLOCATE ... */ diff --git a/storage/xtradb/buf/buf0rea.cc b/storage/xtradb/buf/buf0rea.cc index 3dec3df6f2b..7a79958c136 100644 --- a/storage/xtradb/buf/buf0rea.cc +++ b/storage/xtradb/buf/buf0rea.cc @@ -237,7 +237,7 @@ not_to_recover: *err = _fil_io(OS_FILE_READ | wake_later | ignore_nonexistent_pages, sync, space, 0, offset, 0, UNIV_PAGE_SIZE, - ((buf_block_t*) bpage)->frame, bpage, 0, trx); + ((buf_block_t*) bpage)->frame, bpage, &bpage->write_size, trx); } if (sync) { diff --git a/storage/xtradb/fil/fil0pagecompress.cc b/storage/xtradb/fil/fil0pagecompress.cc index 05dcf372112..eac889cf7c6 100644 --- a/storage/xtradb/fil/fil0pagecompress.cc +++ b/storage/xtradb/fil/fil0pagecompress.cc @@ -222,7 +222,9 @@ fil_decompress_page( byte* page_buf, /*!< in: preallocated buffer or NULL */ byte* buf, /*!< out: buffer from which to read; in aio this must be appropriately aligned */ - ulint len) /*!< in: length of output buffer.*/ + ulint len, /*!< in: length of output buffer.*/ + ulint* write_size) /*!< in/out: Actual payload size of + the compressed data. */ { int err = 0; ulint actual_size = 0; @@ -273,6 +275,12 @@ fil_decompress_page( ut_error; } + /* Store actual payload size of the compressed data. This pointer + points to buffer pool. */ + if (write_size) { + *write_size = actual_size; + } + if (compression_alg == FIL_PAGE_COMPRESSION_ZLIB) { #ifdef UNIV_DEBUG diff --git a/storage/xtradb/include/fil0pagecompress.h b/storage/xtradb/include/fil0pagecompress.h index 342b105401c..c362c0ddcd2 100644 --- a/storage/xtradb/include/fil0pagecompress.h +++ b/storage/xtradb/include/fil0pagecompress.h @@ -97,7 +97,9 @@ fil_decompress_page( byte* page_buf, /*!< in: preallocated buffer or NULL */ byte* buf, /*!< out: buffer from which to read; in aio this must be appropriately aligned */ - ulint len); /*!< in: length of output buffer.*/ + ulint len, /*!< in: length of output buffer.*/ + ulint* write_size); /*!< in/out: Actual payload size of + the compressed data. */ /****************************************************************//** Get space id from fil node diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc index 933690dfefa..1b094bfa1f3 100644 --- a/storage/xtradb/os/os0file.cc +++ b/storage/xtradb/os/os0file.cc @@ -3009,7 +3009,7 @@ try_again: if (ret && len == n) { if (fil_page_is_compressed((byte *)buf)) { - fil_decompress_page(NULL, (byte *)buf, len); + fil_decompress_page(NULL, (byte *)buf, len, NULL); } return(TRUE); } @@ -3025,7 +3025,7 @@ try_again: if ((ulint) ret == n) { if (fil_page_is_compressed((byte *)buf)) { - fil_decompress_page(NULL, (byte *)buf, n); + fil_decompress_page(NULL, (byte *)buf, n, NULL); } return(TRUE); @@ -3129,7 +3129,7 @@ try_again: if ((ulint) ret == n) { if (fil_page_is_compressed((byte *)buf)) { - fil_decompress_page(NULL, (byte *)buf, n); + fil_decompress_page(NULL, (byte *)buf, n, NULL); } return(TRUE); @@ -5223,7 +5223,7 @@ os_aio_windows_handle( if (slot->type == OS_FILE_READ) { if (fil_page_is_compressed(slot->buf)) { - fil_decompress_page(slot->page_buf, slot->buf, slot->len); + fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size); } } else { if (slot->page_compress_success && fil_page_is_compressed(slot->page_buf)) { @@ -5337,7 +5337,7 @@ retry: if (slot->type == OS_FILE_READ) { if (fil_page_is_compressed(slot->buf)) { - fil_decompress_page(slot->page_buf, slot->buf, slot->len); + fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size); } } else { if (slot->page_compress_success && @@ -6284,7 +6284,9 @@ os_file_trim( " InnoDB: [Warning] fallocate not supported on this installation." " InnoDB: Disabling fallocate for now."); os_fallocate_failed = TRUE; - slot->write_size = NULL; + if (slot->write_size) { + *slot->write_size = 0; + } #endif /* HAVE_FALLOCATE ... */